stripe-payments

Stripe session only available to connected account, but not platform account


In our Stripe platform application using Stripe Connect, we have a Stripe account for the platform and we have a test account we are using as a connected account. In our server code using the platform API secret key we initiate a session and set StripeAccount in the RequestOptions to be the connected account. The test payment goes through and then redirects the user to the SuccessUrl which contains the sessionId as a query param. The successURL is on the platform web site and has a backend that has access to the platform API key (not the connected account API key). When we try to retrieve the session using the platform's API key to mark off the successful payment in our database, Stripe says "No such checkout.session". If we try to list all sessions with the platform API key, we get zero returned. However, in our testing, we have found that if we use the API key from the connected account to retrieve the session or list all of the checkout sessions, we can retrieve the checkout session and list all of the checkout sessions. How can the platform use the platform's API key along with the session ID in the success URL to handle the completion of the checkout session? Is there some value we should be sending across as a part of the SuccessUrl template so that the platform can handle it's part of the session completion?


Solution

  • You should be be calling the CheckoutSession retrieve endpoint using your platform secret key and the Stripe-Account option set to the connected account's ID.

    If you need to know which account the incoming success URL hit is for, consider approaches like