ruby-on-rails - 为什么 pp-adaptive 不接受我的退款金额?

标签 ruby-on-rails ruby paypal

我正在尝试使用 pp-adaptive 实现部分 PayPal 退款,但它会全额退款,而不是我指定的金额。

我的代码:

    receiver_list = {receiver: [{ email: @transaction.email, amount: @amount}]}
    attributes = {currency_code: "USD", pay_key: @transaction.paypal_token,
                  receiver_list: receiver_list}
    response = client.execute(:Refund, attributes )

我想到问题可能是由于传递了错误的电子邮件而引起的,但我认为它实际上出在其他地方。我会用邮件解释这个问题:

API表示

The terms sender and receiver refer to sender and receivers of the original payment using the Pay API operation.

因此,接收方中的电子邮件字段应该是在原始交易中收到钱的 paypal 帐户的电子邮件字段。另一方面,在描述接收者字段的金额字段时,API 表示:

amount (Required) xs:decimal Amount to be credited to the receiver's account.

因为它说这笔金额将记入接收方,似乎 API 的编写者已经停止使用他们在开始时指定的约定,因为按照那个命名法,发件人应该是退款到他们帐户的人。

由于这种歧义,我尝试同时传递接收者的电子邮件和传递发件人的电子邮件。在这两种情况下,我都无法获得部分退款。

就像我说的,我认为问题出在其他地方,所以请考虑整个代码。

预先感谢您的回复。

最佳答案

我找到了问题的答案。我没有正确提出请求。以下代码和请求(将email替换为正确的)实现部分退款。

    receiver = {amount: @amount, email: “someone@somewhere.com"}
      receiver_list = [receiver: receiver]
      response = client.execute(:Refund, { currency_code: "USD", pay_key: @transaction.paypal_token, receiver_list: receiver_list} )

盘点一下区别,receiver列表应该是数组,receiver不应该是。

关于ruby-on-rails - 为什么 pp-adaptive 不接受我的退款金额?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24847823/

相关文章:

ruby-on-rails - 使用 RSpec 3 和 Rails 4 在 Controller 测试中查找新创建的记录

ruby - rhc 安装程序返回 "warning: constant::TimeoutError is deprecated"

Ruby SSL 通信

ruby - 字数统计( ruby )

paypal - 我的 paypal 流程接收 webhook 通知有什么问题?

api - Paypal REST API 凭据无效

jquery - Rails 3 best_in_place 编辑在不刷新页面的情况下无法工作

ruby-on-rails - 使用 has_many 关系播种

java - 操作系统对 Ruby 开发有重大影响吗?

php - Paypal 集成 HTTP 错误