Card Reuse
Charge makes it drop dead simple to save allow a customer to save their card for future reuse.
When a customer is logged in during their purchase, their card is automatically saved to a customer record on Stripe. When that same member comes back to complete a different payment we can let them use that card again instead of requiring a new card. Setting this up, takes just 3 parts:
Save the Customer's Card
As part of the normal payment form, payment cards will automatically be saved for logged in members. This is the default behaviour since the 1.10.0 release, so there's nothing you explcitly need to do. As long as the user is logged in during the payemtn (or they have a member account created as part of the payment) their card will be saved.
Of course you may want to allow them to denote a card to not be saved. That's as simple as putting a checkbox on your form called 'card_save', with a value of 'no'. It'd look like this :
{exp:charge:form}
..
<input type="checkbox" value="no" name="card_save"/>
..
{/exp:charge:form}
That's all there is to it. The next step is to allow the customer to see that saved card.
< class="note">Note: On recurring payments, the card is always saved because we need those details for future recurring payments.Expose a Saved Card
Now we have the possibility of saved cards for customers, we need to be able to check if a saved card is available, and show those details if they are. This is a simple tag in the form :
{exp:charge:form}
..
{if have_payment_card}
We have a saved payment card : {saved_card_type} {saved_card_number_dotted}
{/if}
..
{/exp:charge:form}
Lastly, let's allow the customer to pick if they want to pay with this card.
Let the Customer Choose
Letting a customer use a saved card is as simple as adding a 'card_use_saved' input to the form. Like so:
{exp:charge:form}
..
{if have_payment_card}
We have a saved payment card : {saved_card_type} {saved_card_number_dotted}
Would you like to use your saved card?
<input type="checkbox" name="card_use_saved" value="yes"/>
{/if}
..
{/exp:charge:form}
Done. If the value is passed, Charge will attempt to use this saved card.
Remember - always to allow your customers to have the option to use a new card than their saved card, and never assume a saved card will be available (or preferred)
Note Saved cards can fail payments just like new cards, so there's no guarantee a payment with a saved card will go through. Always allow payment by a new card as well.