[英]Paypal Express Checkout with ActiveMerchant as in Shopify
[英]Refund with ActiveMerchant (Paypal checkout Express)
我正在嘗試使用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參數。 method, but I'd rather use the one. 我使用的是方式,但寧願使用 。
確保在金額為“捕獲”時使用交易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>
心連心
看看這個paypal_api
這就是退款的樣子
# Refunds a transaction.
#
# For a full refund pass nil for the amount:
#
# gateway.refund nil, 'G39883289DH238'
#
# This will automatically make the :refund_type be "Full".
#
# For a partial refund just pass the amount as usual:
#
# gateway.refund 100, 'UBU83983N920'
#
def refund(money, identification, options = {})
commit 'RefundTransaction', build_refund_request(money, identification, options)
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.