How to add custom fields to popup form of Stripe Checkout

后端 未结 3 1542
长发绾君心
长发绾君心 2021-02-18 23:32

How can i add custom fields to Stripe Checkout form such as First Name, Last Name and maybe even a checkbox with a custom button? So far i\'ve come up with this;



        
3条回答
  •  故里飘歌
    2021-02-19 00:13

    You can try add own filed by pass as clientReferenceId ie. => extrauserid::option2::option2 but unfortunately you don't get this in in payment_intent.succeeded same as missing SKUs.

    clientReferenceId string

    A unique string to reference the Checkout session. This can be a customer ID, a cart ID, or similar. It is included in the checkout.session.completed webhook and can be used to fulfill the purchase.

    var data = {
        customerEmail: eml,
        successUrl: 'https://...',
        cancelUrl: 'https://...',
        clientReferenceId: user + '::' + option1,
        items: [{  
           sku: sku, 
           quantity: 1
        }],
    }
    stripe.redirectToCheckout(data);
    

    checkout.session.completed

    "cancel_url": "https://....",
    "client_reference_id": "user123::somevalue",
    "customer": "cus_H1vFYbxY2XMAz6",
    

提交回复
热议问题