user24602006
user24602006

Reputation: 1

For stripe setupintent element how to show apple pay option

On Web, To accept payment details from customer, I am using stripe setupIntent clientsecret key to show payment method popup.

Here is the code that I have used.

<script>
async function createSetupIntent(customerId)
{
    let setupIntentSecret = "";
    try
    {

        const setupIntent = await stripe.setupIntents.create({
        customer: customerId,

            automatic_payment_methods: {
                enabled: true,
                allow_redirects: 'always'
            },
        });
        
        setupIntentSecret = setupIntent.client_secret
        
    }
    catch(error)
    {
            throw error;
    }
    return setupIntentSecret;
}

let setupIntentSecret = createSetupIntent(custId)
        const appearance = {
          theme: 'stripe',
        };

        const options = {
          clientSecret: setupIntentSecret,
          appearance,
        };

        elements = stripe.elements(options);
        paymentElement = elements.create("payment");
        paymentElement.mount("#payment-element");  
        
 </script>      
<html>
    <div  style="width:100%;height:100%;;padding:10px;overflow:auto">
      <form id="payment-form">
        <div id="payment-element" ></div>
      </form>
        </div>
</html>
   

The Setup element popup still does not show me the option for Apple Pay. What should I do to see the Apple Pay option on the setupIntent popup? I have already configured and verified the domain in Stripe settings.

Upvotes: 0

Views: 399

Answers (1)

Pompey
Pompey

Reputation: 1354

Apple Pay should show up in the Payment element as long as:

  1. Your domain is registered for Apple Pay as a Payment Method Domain through Stripe[1] in live mode. Keep in mind that subdomains need to be registered so https://example.com and https://payments.example.com would require separate registrations and registering one would not register the other.
  2. Your current device has an apple pay wallet set up. To check this, check if Apple Pay shows up for you on the same device in the same browser when you go to a Stripe page with a live Payment Element[2]. If Apple Pay shows up as an option for you in the Payment Element on that page, then it should show up on your page once the domain is registered properly.

If you have checked both of those things and Apple Pay is still not showing up on your page, you can reach out to Stripe's support[3]. It will be helpful for debugging if you provide URL of the domain that you are trying to get Apple Pay to show up on. If you have a public test page with the Payment Element, that can be helpful for debugging as well.

[1] https://docs.stripe.com/payments/payment-methods/pmd-registration

[2] https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=elements

Upvotes: 0

Related Questions