I’m using the Stripe standard connection I can connect a user and create a payment intent as direct charge like this:
$payment = PaymentIntent::create([ 'amount' => $amount, 'currency' => 'usd', //'application_fee_amount' => 123, ], [ 'stripe_account' => $stripe_user_id, ]);
I saved in my backend the $payment->id
and the $payment->client_secret
it’s what I need to pay and refund the payments, but I need to retrieve this payment and when I do that the Stripe gives me this error: Stripe/Error/InvalidRequest with message 'No such payment_intent: pi_asdjaiudaisda
I’m retrieving the payment like this:
PaymentIntent::retrieve($payment->id);
It’s like the docs say, but don’t look like it’s working.
Advertisement
Answer
Just like how you are “making API requests on behalf of a Stripe Connect account” by passing 'stripe_account' => $stripe_user_id,
when creating the PaymentIntent
You need to do the same when retrieving the PaymentIntent too.
The reasoning is that this PaymentIntent lives on the Connect account (as it was created there), so you have to make retrieve/update API calls on behalf of the Connect account using stripe_account
parameter to access that PaymentIntent.
https://stripe.com/docs/connect/authentication#stripe-account-header