简体   繁体   中英

Razorpay recurring payment in Android

I am using Razorpay for the payment purpose in my Android app.

compile project(':razorpay-android-2.0.1')

Currently, payments are working fine.

Now I need to implement recurring payment (Auto-renew / subscription) using Razorpay.

I couldn't find any clean docs for the same. Please feel free to update me with valuable info.

Finally, I found it myself.

There are 3 main steps:

  1. Define a plan that sets what amount should be billed and how often.
  2. Create a subscription for the selected plan with the start and end details.
  3. Create an authentication transaction (auth transaction).

But, All of these three steps are to be implemented from the backend.

From the front end side (Android app) we need to do the following:

  1. Need to fetch all the plan_id from the backend
  2. Send the particular plan id for which we need the subscription and backend will generate a subscription_id.
  3. Fetch the subscription_id created in the backend
  4. During razorpay payment, add two extra parameters "subscription_id" & "recurring". Set recurring as 1.
  5. Send the transaction_id to backend which we get on payment success.

FYI. I used the sdk " com.razorpay:checkout:1.4.5 "

Happy Coding.

Thanks for posting the question. You can find the API Reference here.

To explain the flow in simple steps:

  1. Define a plan that sets what amount should be billed and how often.
  2. Create a subscription for the selected plan with the start and end details.
  3. Create an authentication transaction (auth transaction). The auth transaction is an approval process that grants permission to charge the customer's card on a periodic basis. This is an important and mandatory step while creating a subscription.

Let me know if this was helpful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM