ruby-on-rails - 通过 ActiveMerchant 退款(Paypal 结帐 Express)

标签 ruby-on-rails paypal activemerchant

我正在尝试使用 ActiveMerchant gem 进行退款。读完API后,我使用这样的退款方式: response = PaymentGateway.refund(nil,transaction_id),其中 transaction_id 是我的 17 个字符的交易 ID。当我执行此代码时,我的日志中出现以下错误:

    Refund error: transaction 90C30922TK2262948, booking 5569, response= #    
   <ActiveMerchant::Billing::PaypalExpressResponse:0x00000110a4c048 @params=
   {"timestamp"=>"2013-12-28T11:58:46Z", "ack"=>"Failure", 
   "correlation_id"=>"17b440dc61a09", "version"=>"72", "build"=>"8951431",
   "refund_transaction_id"=>nil, "message"=>"The transaction id is not valid", 
   "error_codes"=>"10004", "Timestamp"=>"2013-12-28T11:58:46Z", "Ack"=>"Failure",
   "CorrelationID"=>"17b440dc61a09", "Errors"=>{"ShortMessage"=>"Transaction refused  
    because of an invalid argument. See additional error messages for details.", 
   "LongMessage"=>"The transaction id is not valid", "ErrorCode"=>"10004", 
   "SeverityCode"=>"Error"}, "Version"=>"72", "Build"=>"8951431", 
   "RefundTransactionID"=>nil}

Paypal API 似乎不接受 id 参数。 我正在使用转账方法,但我更愿意使用退款方法。

最佳答案

确保在金额为“捕获”时使用交易 ID。在我的应用程序中,我使用授权/捕获/退款 API。我“授权”时的交易ID与我“捕获”时的交易ID不同

这是我捕获金额时得到的数据。

timestamp: '2014-01-30T21:59:33Z'
ack: Success
correlation_id: 7803f5d114c45
version: '72'
build: '9285531'
authorization_id: 04G82796YE043610H
transaction_id: 9A656277C6136044L
parent_transaction_id: 04G82796YE043610H
receipt_id:
transaction_type: express-checkout
payment_type: instant
payment_date: '2014-01-30T21:59:32Z'
gross_amount: '15.97'
gross_amount_currency_id: USD
fee_amount: '0.76'
fee_amount_currency_id: USD
tax_amount: '0.00'
tax_amount_currency_id: USD
exchange_rate:
payment_status: Completed
pending_reason: none
reason_code: none
protection_eligibility: Eligible
protection_eligibility_type: ItemNotReceivedEligible,UnauthorizedPaymentEligible
AuthorizationID: 04G82796YE043610H
PaymentInfo:
  TransactionID: 9A656277C6136044L
  ParentTransactionID: 04G82796YE043610H
  ReceiptID:
  TransactionType: express-checkout
  PaymentType: instant
  PaymentDate: '2014-01-30T21:59:32Z'
  GrossAmount: '15.97'
  FeeAmount: '0.76'
  TaxAmount: '0.00'
  ExchangeRate:
  PaymentStatus: Completed
  PendingReason: none
  ReasonCode: none
  ProtectionEligibility: Eligible
  ProtectionEligibilityType: ItemNotReceivedEligible,UnauthorizedPaymentEligible

然后我调用退款方法:

Gateway.refund(798,'9A656277C6136044L')

=> #<ActiveMerchant::Billing::PaypalExpressResponse:0x007ff4e744b450
 @authorization="70L01419MK614945K",
 @avs_result=
  {"code"=>nil, "message"=>nil, "street_match"=>nil, "postal_match"=>nil},
 @cvv_result={"code"=>nil, "message"=>nil},
 @fraud_review=false,
 @message="Success",
 @params=
  {"timestamp"=>"2014-01-31T01:56:47Z",
   "ack"=>"Success",
   "correlation_id"=>"55810b5eb3c3d",
   "version"=>"72",
   "build"=>"9285531",
   "refund_transaction_id"=>"70L01419MK614945K",
   "net_refund_amount"=>"7.75",
   "net_refund_amount_currency_id"=>"USD",
   "fee_refund_amount"=>"0.23",
   "fee_refund_amount_currency_id"=>"USD",
   "gross_refund_amount"=>"7.98",
   "gross_refund_amount_currency_id"=>"USD",
   "total_refunded_amount"=>"7.98",
   "total_refunded_amount_currency_id"=>"USD",
   "Timestamp"=>"2014-01-31T01:56:47Z",
   "Ack"=>"Success",
   "CorrelationID"=>"55810b5eb3c3d",
   "Version"=>"72",
   "Build"=>"9285531",
   "RefundTransactionID"=>"70L01419MK614945K",
   "NetRefundAmount"=>"7.75",
   "FeeRefundAmount"=>"0.23",
   "GrossRefundAmount"=>"7.98",
   "TotalRefundedAmount"=>"7.98"},
 @success=true,
 @test=true>

关于ruby-on-rails - 通过 ActiveMerchant 退款(Paypal 结帐 Express),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20814577/

相关文章:

ruby-on-rails - 为什么我会收到此 TypeError - "can' t convert Symbol into Integer”?

ruby-on-rails - 为 Sandbox paypal (NVP/SOAP API) 打开 "Negative Testing"

php - PayPal-PHP-SDK 代码错误

php - 目前印度的 PayPal 账户只能发送付款。该收款人没有资格获得资金

ruby - 如果将 gem 源指定为 git,则 ActiveMerchant ActionView 帮助程序初始化会崩溃,但如果它是默认路径或本地路径,则可以正常工作

mysql - Rails 关联使用 'model' .'model_id' 而不是 'model' .'id' 触发 SQL where 子句

javascript - Rails - 如何在 View 中访问 Google map 实例?

ruby-on-rails - 如何 stub WickedPdf?

ruby-on-rails - 在网站上组织自动付款的最佳方式是什么?

ruby-on-rails - 在使用Rails中的Braintree仍符合PCI标准的同时,我可以在本地存储什么?