I was able to save cards by using savePaymentSource parameter in my payment form submitting at commerce/payments/pay. But how do I use these saved cards for making payments? I am using Stripe payment method and rendering the form through {{ cart.gateway.getPaymentFormHtml({})|raw }}.


You can submit a paymentSourceId to the payments/pay controller action.

<select id="paymentSourceId" name="paymentSourceId">
    {% for storedCard in storedCards %}
        <option value="{{ storedCard.id }}" {% if storedCard.id == cart.paymentSourceId %}selected{% endif %}>{{ storedCard.description }}</option>
    {% endfor %}
  • This doesn't really answer the original question. It shows how to output a list of saved cards but not how to actually submit and use them as a payment source. How does one submit this without Stripe trying to validate any card input fields on the same form (which would be a common scenario)?
    – foamcow
    Oct 29 '19 at 14:26
  • The key element is, of course, the first line of the answer. The payment source submits to a different controller to the actual payment. In short, separate forms are needed to switch payment methods and making an actual payment.
    – foamcow
    Oct 29 '19 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.