#Ben21
1 messages ยท Page 1 of 1 (latest)
Hello ๐
customer property on a PaymentIntent is expandable so its not included by default
https://stripe.com/docs/api/payment_intents/object?lang=node#payment_intent_object-customer
So you'd need to expand it at retrieval time
https://stripe.com/docs/api/expanding_objects?lang=node
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Thanks, when I try
$payment_intent = \Stripe\PaymentIntent::retrieve( $payment_intent_id, ['expand' => ['customer']] );
the customer key is NULL
Can you share the PaymentIntent ID you're looking at?
The PaymentIntent does not have any customers attached really that's why you're getting null
https://dashboard.stripe.com/test/logs/req_PPPFdtKuyxW6T8
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Ok so what is the way to retrieve the customer ID from a previous payment
what previous payment?
from any payment made by a user on my website
on my side i just store the payment intent ID
but i need a proper customer ID so I can create a new paymentintent for a hold of 1000โฌ
Creating a PaymentIntent does not create a customer automatically.
You'll need to call the API and create a customer first.
Then pass that customer ID to the PaymentIntent you're creating using customer param
https://stripe.com/docs/api/payment_intents/create?lang=node#create_payment_intent-customer
If you did generate the customer ID and passed it to a PaymentIntent already then the code you've shared above should work
OK, i have no control over the first paymentintent customer creation, but when i do check it on stripe i can see that a guest customer is existing pn the stripe side
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
i cannot retrieve this "gcus_1MADvADVvpMi5GcVKB2V25zC" via API ?
Guest customers are created by checkout
https://stripe.com/docs/payments/checkout/guest-customers
They aren't really retrievable.
Ok so my only chance is to create a real customer on the first payment
Yup
i am using a third party stripe gateway for the first payment so i guess it will be a headache to add that behavior
Ah gotcha, you would want to talk to them re this and see what they have to say about the behavior.
all right, thanks for your help
NP! ๐ Good luck