Integration Steps
Following are the two steps of integration:- Create an Invoice on your server.
- Pass the
invoice_idto Razorpay’s Android SDK.
Payment Flow
The overall payment flow is explained below:- The delivery executive selects an order on your (merchant) app.
- The delivery executive clicks on Initiate Payment.
- Your app makes a request to your server.
- Your server calls the create invoice request on Razorpay’s API.
- Razorpay’s API returns an
invoice_id. This is passed on to your app by your server. - Your app invokes Razorpay’s Android SDK and passes the
invoice_id. - Razorpay’s SDK displays a UI for selecting payment mode.
- The customer selects a payment mode.
- After the payment is completed, Razorpay’s Android SDK passes back the control to your app with the result, success or failure.
Create an Invoice (Server Side)
Step 4 described above involves creating an Invoice using Razorpay’s API. For creating an Invoice, you require the amount and the contact number of the customer. Know more about the Invoice APIs.Mandatory Fields for eCODFor eCOD, you need to pass the following fields mandatorily to Create Invoice API:
- type: ecod
- view_less: true Without these fields, the eCOD functionality may not work properly.
invoice_id. This needs to be passed to your mobile app.Invoke Razorpay’s Android SDK
Step 6 involves invoking Razorpay’s Android SDK. The standard documentation for integration the android SDK apply here too and is available here. You can use the latest SDK available. In the JSON object options that you pass to the SDK, you must pass the following fields:- invoice_id: “
- ecod: true
Complete Payment
The delivery executive and the customer need to interact with the special eCOD checkout form displayed by the SDK. The customer has various options for completing the payment. In all the cases, after the payment is complete, the android SDK calls your app’s onPaymentSuccess method and passes over thepayment_id.