【问题标题】:Paypal - Recurring payments with checkout.jsPaypal - 使用 checkout.js 进行定期付款
【发布时间】:2018-06-16 06:33:45
【问题描述】:
是否可以使用 checkout.js 触发定期付款(订阅/计费协议)?
如果是这样,您能否提供一个工作示例?
【问题讨论】:
标签:
paypal
checkout
billing
【解决方案1】:
是的,这是可能的。我刚刚为此创建了一个 POC。
-
创建一个 BillingPlan 并激活它
plan = Plan.new(PlanAttributes)
plan.create
patch = Patch.new
patch.op = "replace"
patch.path = "/";
patch.value = { :state => "ACTIVE" }
plan.update( patch )
-
paypal.Button 的支付功能内部调用你的服务器来创建一个BillingAgreement。然后用户将授权付款。
agreement = Agreement.new(agreement_attributes)
agreement.plan = Plan.new( :id => "<the_plan_id>" )
agreement.create
-
在paypal.Button的onAuthorize函数中调用你的服务器来执行BillingAgreement
agreement.execute
按照中的示例
结帐https://github.com/chibeepatag/paypal_poc