#Gyan
1 messages ยท Page 1 of 1 (latest)
Hello! It's the same API, but it has different results because we return different things depending on whether you use a secret key vs a publishable key
You can see in our API reference there are some things that are labeled as "retrievable with publishable key ") https://stripe.com/docs/api/payment_intents/object
got it, i am interested in getting "payment_method_details"
Yeah I don't think that's someting you'd get client-side (since it's on the charge, and we don't return that client-side)
You should be able to find the same info in payment_method though
Hmm.. how can i get payment method details then just after the payment? I know we can get more info in the webhook but i need something on the client side to display in the receipt immediately after the payment is made.
payment_method is coming as null in the response.
Here is the sample response of retrievePaymentIntent() method.
{
"paymentIntent": {
"amount": 100,
"canceledAt": null,
"captureMethod": "Automatic",
"clientSecret": "pi_3NVfU1IoChmUfsNA23lHBruq_secret_GwFpTAGoPZoqesZwuzjWDQQhQ",
"confirmationMethod": "Automatic",
"created": "1689792741000",
"currency": "usd",
"description": "<StripePayments.STPPaymentIntent: 0x7ff34e18e360; stripeId = pi_3NVfU1IoChmUfsNA23lHBruq; amount = 100; canceledAt = nil; captureMethod = Optional("automatic"); clientSecret = <redacted>; confirmationMethod = Optional("automatic"); countryCode = nil; created = 2023-07-19 18:52:21 +0000; currency = usd; description = nil; lastPaymentError = nil; linkSettings = nil; livemode = false; nextAction = nil; paymentMethodId = Optional("pm_1NVfUEIoChmUfsNAtnXgQwsU"); paymentMethod = nil; paymentMethodOptions = Optional(<StripePayments.STPPaymentMethodOptions: 0x600001c45920>); paymentMethodTypes = Optional(["card", "link", "us_bank_account"]); receiptEmail = nil; setupFutureUsage = nil; shipping = nil; sourceId = nil; status = Optional("succeeded"); unactivatedPaymentMethodTypes = []>",
"id": "pi_3NVfU1IoChmUfsNA23lHBruq",
"lastPaymentError": null,
"livemode": false,
"nextAction": null,
"paymentMethod": null,
"paymentMethodId": "pm_1NVfUEIoChmUfsNAtnXgQwsU",
"receiptEmail": null,
"shipping": null,
"status": "Succeeded"
}
}
The Payment Method ID is right there - "paymentMethodId": "pm_1NVfUEIoChmUfsNAtnXgQwsU",
To get the full payment method you'd have to expand it
I need to head out, but if you need more help @barren oriole is around and can answer questions
๐
WIth the PK + PI client_secret you should be able to retrieve the PaymentIntent with the payment_method expanded using expand[]=payment_method
https://stripe.com/docs/expand
I'm not clear on the syntax for this with the react native method, though, trying to find that
Ok it doesn't look like retrievePaymentIntent supports any params for expansion, unfortunately
https://github.com/stripe/stripe-react-native/blob/dc50050dccab5d0433d5fade80214463763c1438/src/functions.ts#L97
So you'd need to either retrieve this via your own server or craft a manual API request
NP ๐