How to get info from a redirection from instamojo payment gateway

(Prakhar Monga) #1

I want to redirect my users to a flow after making a successful payment at instamojo payment gateway for example
https://m.me/223827441331771?ref=fxo_widget:123abc
but according to the docs in instamojo

If your redirect_url was http://www.example.com then the user will be redirected to something like: http://www.example.com?payment_id=MOJO5a06005J21512197&payment_status=Credit&payment_request_id=d66cb29dd059482e8072999f995c4eef

It means the redirect url will be
https://m.me/223827441331771?ref=fxo_widget:123abc?payment_id=MOJO5a06005J21512197&payment_status=Credit&payment_request_id=d66cb29dd059482e8072999f995c4eef

I don’t think this is right

How can i extract the info like payment_id, payment_status and payment_request_id
from the above URL and save into attributes?

(Daniel Beckett) #2

Hi @Prakhar_Monga

When using Facebook Messenger the m.me links only pick up a single parameter from the URL. This means that, unfortunately, the entire string in your example redirect URL will be cut off after the ‘ref’ value.

You could, instead, look at using webhooks to receive data about the transactions. That information could be saved to a Google Sheet or another database. If you drop the ‘ref’ part of the URL and just leave ‘payment_id’ you could then search for the information in your flow to pull it through.

(Prakhar Monga) #3

I did not understand this:

can you explain it a bit?

and using webhooks:

You mean I should create a flow which triggers on a webhook received and in the redirection URL instead of example.com I would put that webhook URL.
will it work?

(Daniel Beckett) #4

There’s two ways of going about it (in theory). If you just want to start a flow and know the payment_id then you can redirect to the m.me link. You just want to make sure that the only appended data on the URL is the one for payment_id.

The alternative method is to create a webhook trigger and to send out the transaction information to the webhook URL once a transaction is completed. On the webhook flow, you’d then save the information into something like Google Sheets. Once that’s done you’d want to redirect the user to your bot with the payment_id in the URL so that you can use the metadata to lookup the correct information from the Google Sheet.

It’s all just a workaround, in theory, so there’s no particular easy set of steps I can share, unfortunately. It’s likely going to take some trial and error to get working how you’d like.