Warm tip: This article is reproduced from serverfault.com, please click

ruby on rails-ActiveMerchant网络资源授权错误原因102

(ruby on rails - ActiveMerchant Cybersource Authorization Error Reason 102)

发布于 2020-11-22 16:20:12

我在调试当前运行中的应用程序的工作Ruby 2.5.8ActiveMerchant 1.117.0

我能够成功创建和保存订阅。但是,当我尝试授权已保存的卡时,我会不断获得reasonCode 102来自Cyber​​source网关端的错误是the subscription () could not be found

我正在尝试使用以下功能进行授权:

  def authorize(token, amount, order_id, line_items)
    response = gateway.authorize(amount, token, order_id: order_id, line_items: line_items)
    if !response.success?
      raise Exceptions::ChargeFailed.new(response.message, response: response)
    end
    response
  end

该错误会使我相信这里的格式不正确。谁能指出我一些有效的ActiveMerchant Cyber​​Source示例来授权订阅,或者指出这里可能有什么问题?

Questioner
Aaron A
Viewed
0
Aaron A 2020-12-24 23:54:21

经过一番挖掘后,似乎在ActiveMerchant Cyber​​Source gem内部更改了令牌分配的逻辑

原始逻辑是:

if reference
    _, subscription_id, _ = reference.split(";")
    xml.tag! 'subscriptionID',  subscription_id
end

最新版本转向:

if reference
    subscription_id = reference.split(";")[6]
    xml.tag! 'subscriptionID',  subscription_id
end

我以前使用的应用程序已将Cyber​​Source配置文件/订阅ID格式化为;#{token};为了使用这些最新更新,令牌需要格式化为;;;;;;#{token}