简体   繁体   English

使用active_paypal_adaptive_payment gem授权preapproved_pa​​yment_key

[英]Authorizing a preapproved_payment_key with active_paypal_adaptive_payment gem

Man, I'm tearing my hair out over this one. 伙计,我要把这根头发剪掉。 Paypal's documentation is so complicated and incomplete, and there is little native ruby support for Adaptive Payments. Paypal的文档是如此复杂且不完整,并且几乎没有本地红宝石支持Adaptive Payments。

Anyway, I'm building a web app from which I want to be able to set up preapproved payments using PayPal Adaptive Payments. 无论如何,我正在构建一个Web应用程序,我希望可以使用该应用程序使用PayPal Adaptive Payments设置预先批准的付款。 I've gotten the active_paypal_adaptive_payment gem to work, but there's no documentation on the process for going from preapproval to capturing payments. 我已经使用了active_paypal_adaptive_payment gem,但是没有有关从预批准到捕获付款的流程的文档。

I can use the preapprove_payment method of the gem to get a preapproval key from PayPal: 我可以使用gem的preapprove_payment方法从PayPal获取预批准密钥:

response = ADAPTIVE_GATEWAY.preapprove_payment ({
  :return_url => admin_preapproved_payments_url,
  :cancel_url => admin_preapproved_payments_url,
  :senderEmail => @payment.sender_email,
  :start_date => @payment.start_date,
  :end_date => @payment.end_date,
  :currency_code =>"USD",
  :max_amount => @payment.max_amount.to_s,
  :maxNumberOfPayments => @payment.max_number_of_payments.to_s
  })
  puts response.preapproval_key

But the sender needs to authorize the preapproval key before I can use it to capture funds from their account. 但是,发件人需要先授权预批准密钥,然后我才能使用它从他们的帐户中提取资金。

在此处输入图片说明

Where do I redirect the sender so they can authorize the preapproval key? 我在哪里将发送方重定向到其他位置,以便他们可以授权预批准密钥? I don't want to capture funds immediately – I just need their approval so I can do so in the future. 我不想立即获得资金–我只需要获得他们的批准,这样我以后才能这样做。

The method redirect_pre_approval_url_for(token) is what you need, it returns a URL to which you should (well, obviously) redirect the user in order to authorize the preapproved payment. 方法redirect_pre_approval_url_for(token)是您所需要的,它返回一个URL,您应该(显然)将用户重定向到该URL以授权预批准的付款。

redirect_pre_approval_url_for(token) redirect_pre_approval_url_for(令牌)

So, in a rails application things should look like this: 因此,在Rails应用程序中,内容应如下所示:

redirect_to ADAPTIVE_GATEWAY.redirect_pre_approval_url_for(response.preapproval_key)

我建议与Paypal 一起试用ActiveMerchant

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

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