尝试使用ActiveMerchant设置Paypal定期付款时,"令牌无效"

Log*_*man 5 paypal ruby-on-rails activemerchant

我觉得很多文档都已经过时了,但这是我到目前为止所尝试的内容:

我正在使用ActiveMerchant::Billing::PaypalExpressGateway网关.

首先,我设置购买并将用户重定向到Paypal:

response = gateway.setup_purchase price,
  return_url: <confirm url>,
  cancel_return_url: <cancel url>,
  items: [
    {
      name: 'My Item',
      quantity: 1,
      description: "My Item Description",
      amount: price
    }
  ]
redirect_to gateway.redirect_url_for(response.token)
Run Code Online (Sandbox Code Playgroud)

这是有效的,我可以作为沙盒买家登录并确认付款,这让我<confirm url>从上面回来.在确认中,我做:

response = gateway.recurring price, nil,
  token: params[:token],
  period: 'Year',
  frequency: 1,
  start_date: Time.now,
  description: 'My Item Subscription'
Run Code Online (Sandbox Code Playgroud)

当我这样做时,我从response变量中的Paypal收到无效的令牌错误.令牌似乎没问题,当我被带回确认网址时,它会出现在网址中.我然后直接(params[:token])将其发送回Paypal.

我做错了什么吗?就像我说的,似乎很多这类过程的文档已经过时(或者我正在尝试的是过时的东西...)

Log*_*man 1

在查看了 ActiveMerchant 的 Paypal 快速结账网关的源代码后,我得出的结论是,它在处理定期付款时已经过时了。我改用贝宝经常性宝石,一切正常。