【问题标题】:Paypal - Recurring payments with checkout.jsPaypal - 使用 checkout.js 进行定期付款
【发布时间】:2018-06-16 06:33:45
【问题描述】:

是否可以使用 checkout.js 触发定期付款(订阅/计费协议)?

如果是这样,您能否提供一个工作示例?

【问题讨论】:

  • 如果您的应用程序使用payment(...) 调用您的服务器,您的服务器从该服务器调用 PayPal REST api 以创建计费协议并返回特定令牌,似乎是可能的。请参阅 GitHub 上的以下问题:github.com/paypal/paypal-checkout/issues/131

标签: paypal checkout billing


【解决方案1】:

是的,这是可能的。我刚刚为此创建了一个 POC。

  1. 创建一个 BillingPlan 并激活它

    plan = Plan.new(PlanAttributes)
    plan.create 
    patch = Patch.new
    patch.op = "replace"
    patch.path = "/";
    patch.value = { :state => "ACTIVE" }
    plan.update( patch )
    
  2. paypal.Button 的支付功能内部调用你的服务器来创建一个BillingAgreement。然后用户将授权付款。

    agreement = Agreement.new(agreement_attributes)
    agreement.plan =  Plan.new( :id => "<the_plan_id>" )
    agreement.create
    
  3. 在paypal.Button的onAuthorize函数中调用你的服务器来执行BillingAgreement

    agreement.execute
    

按照中的示例 结帐https://github.com/chibeepatag/paypal_poc

【讨论】:

    猜你喜欢
    • 2018-12-12
    • 2013-10-17
    • 2016-02-21
    • 2012-07-22
    • 2014-06-20
    • 2013-06-02
    • 2020-01-03
    • 2013-02-15
    相关资源
    最近更新 更多