0

I'm building a bot and for the premium version I would like to charge the user a specific amount. I'm using stripe to process the payment.

The payment flow works like this: Bot shows a generic template with a web url button which takes the user to my check out page. After the check out has completed I'd like to add the users messenger userID to my database.

Now the problem here is that I don't know how to send the userID to the checkout page. I'm using stripe checkout to show the payment form. I tried using a webhook and send the userID from messeneger to the stripe checkout page but that too didn't work(should I use stripe webhook api? If yes how do I do it?).

I'm not sure how to do it. Is there any other way? Or am I missing something or doing something wrong? I just need to get the userId from messenger then store it in the db. I've searched everywhere on the internet but couldn't find anything.I'm using python and flask to do this. Thanks in advance!

Joel Benjamin
  • 209
  • 4
  • 15
  • Maybe [this question](https://stackoverflow.com/questions/3546677/how-to-get-the-facebook-user-id-using-the-access-token) might give you some insights but I rather think it is related to one's own account. Anyway have you checked [facebook for developers](http://developers.facebook.com)? – Revolucion for Monica Dec 25 '17 at 10:50
  • Yes I checked facebook for devs, it wasn't helpful lol. I did some more digging and found that there isn't any way to do it. Since stripe's checkout page is really secure they don't let anyone send any kind of data to the page lol. But thanks anyway! :) @Marine1 – Joel Benjamin Dec 25 '17 at 10:59

1 Answers1

1

On the URL button, set messenger_extensions: true, then you can call MessengerExtensions.getContext() to retrieve the user's PSID on your site.

https://developers.facebook.com/docs/messenger-platform/reference/messenger-extensions-sdk/getContext

amuramoto
  • 2,838
  • 1
  • 11
  • 15
  • Thank you so much! So I have to call the getContext() function on my website right and Then the users info will be sent to my page? But it's a stripe check out page can the data still be received? – Joel Benjamin Dec 27 '17 at 18:03
  • Not a problem. As long as you own the checkout page and can include the Messenger Extensions SDK and call getContext you can get the PSID. – amuramoto Dec 27 '17 at 18:12