3

I need to implement Stripe Connect in my project, So i am following this guide

OAuth flow worked perfectly and I received the JSON response as expected in my /stripe/callback endpoint -

{
     "token_type": "bearer",
     "stripe_publishable_key": PUBLISHABLE_KEY,
     "scope": "read_write",
     "livemode": false,
     "stripe_user_id": USER_ID,
     "refresh_token": REFRESH_TOKEN,
     "access_token": ACCESS_TOKEN
}

Now my question is : How do i associate this returned object with the user in my application ?

I am not using cookies in my application as all of my routes are for REST API that's client agnostic. I usually use a token in header to identify the client user.

But in this case when Stripe redirects, i don't get any information that tells me which user registered in Stripe.

Koder
  • 1,794
  • 3
  • 22
  • 41
  • I did not get any thing, can you help to give sample code for access token and strip user id. thanks in advance. – Gautam Jan 09 '16 at 12:49
  • Did you ever solve this? – Hese Apr 09 '18 at 14:44
  • 1
    @Hese : Yes. use state query parameter. { response_type: "code", scope: "read_write", client_id: Settings.StripeConnectClientId, state: user_id } – Koder Apr 17 '18 at 09:54

1 Answers1

1

I am facing similar problem. I don't know yet what do do (plus it is probably way too late to be of any use for you) but i suspect we could use the state key provided by Stripe's oauth api, that is used to prevent exploit. This value is provided in the first request and send again on the callback redirect. Inside this you could send then capture your internal user reference then save the bearer token to its document.

Another way to do that would be to create an empty standalone account (with country and currency), connect it and let the user confirm it later.

EDIT : This is actually the way hinted by Stripe's very people. https://support.stripe.com/questions/can-i-dynamically-set-the-redirect-url-for-my-connect-application

olup otilapan
  • 464
  • 4
  • 13