Customer Model

The Charge_CustomerModel holds the customer information for each unique customer in the system.

Every time a charge is created, a customer will be used for the request. If the user is logged in during the request, we'll also try to reuse any existing customer details we can find.

The model is also what's used to keep track of saved payment sources, and associate multiple different payments back to the same customer.

Accessing a Customer

You can access a customer from two places. On the initial payment form, and later against a completed Charge Model.

In the Payment Form
This returns the customer model for the currently logged in user, nor null if there is none, or the user is a guest. This is primarily used on the payment form page to offer the option to reused a saved payment card.
{% set customer = craft.charge.customer %}

{% if customer %}

     {% set cards = customer.getSavedCards %}

     {% if cards %}
          {% for card in cards %}

              Pay with Saved Card {{ card.brand }} - {{ card.formattedCard }}?
              <input type="radio" name="useSavedCard" value="{{ }}" checked="checked"/>

          {% endfor %}

          Pay with a new Card?
          <input type="radio" name="useSavedCard" value="false"/> // etc..

     {% endif %}

{% endif %}
On a Charge
The customer model associated for a charge is available on the ChargeModel for all charges.


id Number
The id of the customer model.
stripeId String
The stripe id for the customer, similar to cus_00000000000.
mode String, live or test
The mode for this customer.
userId Number
The user id of the craft user for this customer. Can be null if the user was a guest at the time of creation.
email String, required
The email supplied for the customer at time of creation. Used for email receipts, and may be different than the associated user account. All customer models will have an email.
name String
The name supplied for the customer at time of creation. Optionally included in the payment form.
stripeLink String
A helper to return a link to the Stripe dashboard for a specific customer record. Returns similar to :


Returns the saved cards for a customer. Can return an empty array if no cards have been saved.