Payments API enables businesses to accept payments from their customers through all UPI Apps installed on their device via WhatsApp. Businesses can send invoice(order_details) messages to their customers, and then get notified about payment status updates via webhook notifications from Payment Gateway.
You should have a WhatsApp Business Account with the registered WhatsApp Phone Number.
You should have a registered Payment Gateway account with PayU or RazorPay.
You should have a system integrated with the WhatsApp Payment APIs.
You should have the system to generate the order detail messages with a unique Order ID for each payment.
How It Works
To kick off the payment process, the business sends an 'order_details' message to the consumer. This special message contains four main components: header, body, footer, and action. Inside the action component, the business includes all the necessary information for the customer to complete their payment.
Unique Reference ID:
Each 'order_details' message carries a unique reference_id provided by the business. This unique number is nothing but the order id or order number which is crucial throughout the entire process, acting as a tracking ID for the order. The reference_id is obtained from the UPI intent link generated for a business order through the Payment Gateway.
Tracking Order Status:
After sending the 'order_details' message, the business patiently awaits payment or transaction status updates directly from the Payment Gateway. Once a payment signal for an order is received, the business should promptly relay this information to the consumer through an interactive 'order_status' message.
Importance of Payment Signal Update (optional):
Updating the user about the payment signal is vital. This update modifies the 'order_details' message and the consumer's order details view, confirming the order from the merchant. We illustrate this process with an example in the subsequent sections.
Steps to be followed
The Payment APIs needs to be enabled for the customer WhatsApp Business Account.
To get this enabled please raise a support ticket with the required information to Exotel support team to enable the Payment API for the Business (If you are already allowlisted for an older number, you may skip this step).
Please follow the below steps to raise the ticket
Link Payment Gateway Account
To be done by the customer: Connect your WhatsApp Business Account with the Payment Gateway
For Seller owned WABA:
Login to the WhatsApp Business Manager Account and your Payment Gateway Account.
Navigate to the Payment methods section from the LHS navigation bar.
Navigate to the relevant WABA and start the account linking process by “Adding a direct pay method”
Put in the WABA ID and select the correct WABA ID.
Put in a name, and note the payment configuration name in this step.
Set the MCC to 000 to the relevant code.
Set the Purpose code to the relevant code.
Follow the steps and select Payment Gateway in the dropdown where you are asked for the payment gateway. Please see the screenshot below for your reference.
Enter your password and you will be redirected to the payment gateway website
Login using the credentials in step (1) and authorize “Whatsapp Payments India” to access the payment gateway account. You will need a Whatsapp-enabled phone number.
Your payment gateway should now be linked to your WABA.
For BSP owned WABA (OBO)
BSP logs into the Whatsapp Manager.
Initiates creating a “Direct Pay Method”
Follow the same steps as the Seller Owned WABA method above from step 5 to step 9.
Share the link generated on submission of the above form to the seller.
The seller logs in to the FB business manager account.
The seller is redirected to PG website, where the seller will need to log in and approve allowing Meta to request payments on behalf of the seller.
To be done by the customer: Please follow the steps below to send the order details message, and send the order status:
Construct Order Details message using the example in the Postman collection shared. Postman Collection.
Set the: action.parameters.payment_configuration to the name of the payment configuration you created above.
Note “action.parameters.payment_type” → “payment_gateway:<razorpay,payu>”
Set “action.parameters.reference_id” → “some-id”
Here’s the pictorial representation of how the order message renders in the WhatsApp screen:
You can get the API Key, Token, Subdomain and SID from your Exotel Messaging Account under the Number Management section.
Configure Webhook - Go to the Webhooks section on the Exotel messaging console and
search for your Phone number.
Click on the Edit icon, paste and save your Callback URL here.
Order status (optional)
Order status information will already be available in the Webhooks but there is an alternate way to fetch the order status by calling the order status API.
The order status will be “pending” by default and needs to be changed to the right status to avoid confusing the buyer.
Once you receive the payment status for your order
Update order status to the user and set it to “processing”
Initiate order fulfillment.
Once you receive a status from your order management system, update the user about the order’s status (If order fulfillment fails, let the user know what they can do).
“action.parameters.reference_id” must match the corresponding order ID
We show supported statuses, what they mean and a finite state machine.
Test and Launch
To be done by the customer: Please follow the steps below to test and launch the payment solution!
You can now construct the Send Message API with the details.
As this is a session message, this should deliver the order details message, remember the phone needs to have interacted with this bot in the last 24 hours, for this to work as expected. Just send a “hi” from the number to not fail this check.
On the phone: Click on “Review and Pay” and Hit “Continue”
Pay using any of the UPI apps, you have.
Check your callback to look for a call from Whatsapp with payment status details for “some-id” or “reference-id” you provided.
Now update the order status to “Complete” by using the “Order Status” example in the Postman collection.
Note action.parameters.reference_id → “some-id”
Note action.parameters.order.status → “completed”
The user should now see an order status message, verify if it looks correct.
This should align with payment IDs from the PG merchant website.
Log into PG’s merchant account and match these payment IDs for reference.
For any further concerns, please write to email@example.com.