#eriktoor
1 messages · Page 1 of 1 (latest)
Can you share the Payment Intent ID (pi_xxx)?
Sure -- however, the issue is that on the client the paymentintent id is null
const { paymentIntent, error } = await confirmPlatformPayPayment(clientSecret as string, {
applePay: {
cartItems: cart,
merchantCountryCode: 'US',
currencyCode: 'USD',
requiredShippingAddressFields: [
PlatformPay.ContactField.EmailAddress,
PlatformPay.ContactField.PhoneNumber,
PlatformPay.ContactField.PostalAddress,
PlatformPay.ContactField.Name,
],
requiredBillingContactFields: [PlatformPay.ContactField.PostalAddress],
shippingType: PlatformPay.ApplePayShippingType.StorePickup,
additionalEnabledNetworks: ['JCB'],
},
})
Because this returns the error above.
On the server the payment intent id pi_3OPcdvCSVXIaq6vh1xuU3ZXm but I take the clientSecret and pass that and the ephemeral key to the client.
This is my server code
router.post(..., () => {
const ephemeralKey = await stripe.ephemeralKeys.create(
{customer: customerId},
{apiVersion: '2023-10-16'}
);
console.log(ephemeralKey)
const paymentIntent = await stripe.paymentIntents.create({
amount: 1099,
currency: 'usd',
customer: customerId,
// In the latest version of the API, specifying the `automatic_payment_methods` parameter is optional because Stripe enables its functionality by default.
automatic_payment_methods: {
enabled: true,
},
});
res.json({
clientSecret: paymentIntent.client_secret,
ephemeralKey: ephemeralKey.secret,
});
})
Does that make sense or is something I'm saying way off?
Which integration guide are you following? Using createPlatformPayToken to create a token is legacy.
The recommended integration for Apple Pay in stripe-react-native should be: https://stripe.com/docs/apple-pay?platform=react-native
to create a token i use that method so great maybe i messed something up!
i found an example github repo online
Oh isn't the only diff here just that I wouldn't use createPlatformPayToken ?
im doing everything else
because createPlatforPayToken actually succeeds its the other method createPlatformPayPayment that fails
Hey @regal ether once I took out createPlatformPayToken it worked!! Thank you so so much this is great.
I appreciate the help. I think this thread can be resolved for now.
feels good
Awesome! Great to see everything works!
Other q it looks like when I create the client secret on the backend I create an extra payment intent that never gets paid. Should I be creating the client secret a different way?
Maybe I'm accidentally calling it a second time somewhere that must be it
Yup! It's likely somewhere in your system create the Payment Intent for the second time
Oh and are ephemeral keys not really needed anymore?
because i would love to remove my calls to that
not needed for confirming a payment
Reference: https://stripe.com/docs/payments/accept-a-payment?platform=react-native&ui=payment-sheet
A Customer Ephemeral Key (optional). Information on the Customer object is sensitive, and can’t be retrieved directly from an app. An Ephemeral Key grants the SDK temporary access to the Customer.
I guess my last question is right now I have a one time payment.
I want to do one time payments and subscriptions. Are there any docs you could share on creating a payment intent for a subscription? I see stripe.subscriptions.create({ but this creates a subscription object and not a payment intent.
Here's the guide to create a Subscription: https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements
After getting the client secret at Step 4, you can follow the same one-time payment integration to collect the payment method