Here we explain how to integrate Paytm wallet transfer through your Ruby on Rails Application. It is a very simple and easy way to integrate using Net::HTTP in Rails application.
To integrate Paytm wallet transfer through your application you need the 3 keys from your Paytm account which are as below.
1. Paytm Merchant ID
2. Paytm Merchant KEY
3. Paytm wallet GUID
The above things you get from below link. https://dashboard.paytm.com/next/apikeys
Note: First you will get paytm staging server access where you can check that your code is working fine for a dummy transaction after that you can apply for a production in the paytm dashboard.After getting above 3 keys you need to add them into environment variable like below
Now you need to create services for the paytm which accepts 2 parameter 1) Phone Number [on whom account you want to pay money] and 2) Amount [how much you want to pay]
First create a base service.
app/services/paytm/base_service.rb
Than create Paytm wallet transfer service which is derived from base_service
app/services/paytm/paytm_wallet_transfer.rb
So, when you want to transfer money from our wallet balance to any customer wallet you need to just call the transfer method of the above service like below.
It will generate an order_id using secure random hex and request to transfer money of a given amount to the given phone number.
Response looks like below:
Response to this above call having status as ACCEPTED or SUCCESS means your request is accepted or done successfully.
If it returns FAILURE, then there must be some issue with the request so please check the status message.
It will also return PENDING, which means it will get into process soon and you need to check after sometime.
To check after sometime our transactions have processed or not, please add below service under base service to check the status of the transaction. To check the status, you should have the order_id of that transaction.
Please add below service to check the status of transaction.
app/services/paytm/paytm_check_order.rb
So, When you want to check the status of some order you just have to call the check_status method of the above service like below.
Response of above check status api call look like below.
To know about paytm wallet transfer API, please visit below link: https://developer.paytm.com/docs/api/wallet-transfer-api/?ref=paytmPayouts
To know about paytm check order status API, please visit below link: https://developer.paytm.com/docs/api/disburse-status-query-api/?ref=paytmPayouts