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

前端 未结 4 1977
孤城傲影
孤城傲影 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:36

    Elements does not support collecting the cardholder's name at the moment. It focuses on collecting:

    • Card number
    • Expiration date
    • CVC
    • ZIP code (in some countries)

    If you want to collect the cardholder's name you have to build your own field for the name and submit it to the API during token creation:

    var card_name = document.getElementById('card_name').value;
    stripe.createToken(card, {name: card_name}).then(setOutcome);
    

    You can see a live example on jsfiddle here: https://jsfiddle.net/7w2vnyb5/

提交回复
热议问题