简体   繁体   English

Android 中的 Razorpay 定期付款

[英]Razorpay recurring payment in Android

I am using Razorpay for the payment purpose in my Android app.我在我的 Android 应用程序中使用Razorpay进行付款。

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

Currently, payments are working fine.目前,付款工作正常。

Now I need to implement recurring payment (Auto-renew / subscription) using Razorpay.现在我需要使用 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:主要有3个步骤:

  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).创建身份验证事务(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:从前端(Android 应用程序),我们需要执行以下操作:

  1. Need to fetch all the plan_id from the backend需要从后端获取所有的plan_id
  2. Send the particular plan id for which we need the subscription and backend will generate a subscription_id.发送我们需要订阅的特定计划 ID,后端将生成一个 subscription_id。
  3. Fetch the subscription_id created in the backend获取后台创建的subscription_id
  4. During razorpay payment, add two extra parameters "subscription_id" & "recurring".在 razorpay 付款期间,添加两个额外的参数“subscription_id”和“recurring”。 Set recurring as 1.将重复设置为 1。
  5. Send the transaction_id to backend which we get on payment success.将 transaction_id 发送到我们在付款成功时获得的后端。

FYI.仅供参考。 I used the sdk " com.razorpay:checkout:1.4.5 "我使用了 sdk “ com.razorpay:checkout:1.4.5

Happy Coding.快乐编码。

Thanks for posting the question.感谢您发布问题。 You can find the API Reference here.您可以在此处找到API 参考

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).创建身份验证事务(auth transaction)。 The auth transaction is an approval process that grants permission to charge the customer's card on a periodic basis. auth 交易是一个批准过程,它授予定期从客户的卡上收费的权限。 This is an important and mandatory step while creating a subscription.这是创建订阅时的一个重要且强制性的步骤。

Let me know if this was helpful.让我知道这是否有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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