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.
You can access a customer from two places. On the initial payment form, and later against a completed Charge Model.
craft.charge.customer
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="{{ card.id }}" checked="checked"/>
{% endfor %}
Pay with a new Card?
<input type="radio" name="useSavedCard" value="false"/> // etc..
{% endif %}
{% endif %}
charge.customer
ChargeModel
for all charges.id
NumberstripeId
Stringcus_00000000000
.mode
String, live
or test
userId
Numberemail
String, requiredname
StringstripeLink
Stringhttps://dashbaord.stripe.com/test/customers/cus_0000000000
.getSavedCards