How to add card holder's name to Stripe checkout using Elements?

前端 未结 4 1979
孤城傲影
孤城傲影 2021-02-04 00:43

I need to add an additional field to my custom form, I want to add the name of the credit card.

I tried in the following way:

var cardNameElement = eleme         


        
4条回答
  •  说谎
    说谎 (楼主)
    2021-02-04 01:28

    If you're using "PaymentIntents", which you probably should be if you're EU based / SCA compliant, then the format for this has changed again slightly...

    stripe.confirmCardPayment(
      '{PAYMENT_INTENT_CLIENT_SECRET}',
      {
        payment_method: {
          card: cardElement,
          billing_details: {
            name: 'Jenny Rosen'
          }
        }
      }
    ).then(function(result) {
      // Handle result.error or result.paymentIntent
    });
    

    stripe.confirmCardPayment docs:

    https://stripe.com/docs/stripe-js/reference#stripe-confirm-card-payment

    billing_details object docs:

    https://stripe.com/docs/api/payment_methods/create#create_payment_method-billing_details

提交回复
热议问题