Authorize.Net沙盒账户中的交易是不是可以退款?
Posted
技术标签:
【中文标题】Authorize.Net沙盒账户中的交易是不是可以退款?【英文标题】:Is it possible to refund a transaction in Authorize.Net sandbox account?Authorize.Net沙盒账户中的交易是否可以退款? 【发布时间】:2020-07-28 15:03:12 【问题描述】:我从 Authorize.Net 网站实时 API 控制台发布以下代码
请求
"createTransactionRequest":
"merchantAuthentication":
"name": "5KP3u95bQpv",
"transactionKey": "346HZ32z3fP4hTG2"
,
"refId": "123456",
"transactionRequest":
"transactionType": "refundTransaction",
"amount": "5.00",
"payment":
"creditCard":
"cardNumber": "0015",
"expirationDate": "XXXX"
,
"refTransId": "1234567890"
回应
"transactionResponse":
"responseCode": "3",
"authCode": "",
"avsResultCode": "P",
"cvvResultCode": "",
"cavvResultCode": "",
"transId": "0",
"refTransID": "1234567890",
"transHash": "",
"testRequest": "0",
"accountNumber": "",
"accountType": "",
"errors": [
"errorCode": "54",
"errorText": "The referenced transaction does not meet the criteria for issuing a credit."
],
"shipTo": ,
"transHashSha2": "B3BF913B110E1C82C4FB83DA0EFE096C5D383A9257123AE2A7E9582AF977A537CA2C7A78F13B6FCF0E9C83A9C7FCF16DB4FC6F999A23C9DE24AFC4BFB765E602",
"SupplementalDataQualificationIndicator": 0
,
"refId": "123456",
"messages":
"resultCode": "Error",
"message": [
"code": "E00027",
"text": "The transaction was unsuccessful."
]
API 交易密钥与 Authorize.Net 网站上的相同,但即使使用 Authorize.Net 自己的密钥,退款交易也会失败。如何在沙盒中测试退款,甚至可以在沙盒中测试退款?
编辑:我在开发时也遇到了同样的错误,我确实有正确的数据,但我的生产应用程序使用不同的 AuthNet 凭据,出于测试目的,我使用了完全来自不同的 AuthNet 沙盒帐户。所以即使我有正确的数据,我认为我的问题是来自原始交易的数据在我的沙盒帐户中不存在。帮助将不胜感激。
【问题讨论】:
【参考方案1】:您可以在沙盒中测试退款,但它必须满足与生产环境相同的所有标准。他们的示例可能包含陈旧数据,但如果您使用新数据,它会为您工作。
要退款,必须满足以下条件:
-
交易最初已通过支付网关 (Authorize.Net) 处理并成功结算。
交易提交时使用的是原始成功结算交易的有效交易 ID (
x_trans_id
)。
申请退款的金额小于或等于原结算金额。
针对原始交易提交的多个 Credit 交易的总和小于或等于原始结算金额。
至少提交用于原始成功结算交易的信用卡号 (x_card_num
) 的最后四位数字。不需要截止日期。
交易是在原始交易结算日后 120 天内提交的。
这是我刚刚做的一个测试:
AUTH_CAPTURE
"createTransactionRequest":
"merchantAuthentication":
"name":"",
"transactionKey":""
,
"refId":49782069,
"transactionRequest":
"transactionType":"authCaptureTransaction",
"amount":5,
"payment":
"creditCard":
"cardNumber":"4427802641004797",
"expirationDate":"122020",
"cardCode":"999"
,
"order":
"invoiceNumber":"1324567890",
"description":"this is a test transaction"
,
"lineItems":
"lineItem":[
"itemId":"1",
"name":"vase",
"description":"Cannes logo",
"quantity":"18",
"unitPrice":"45.00"
,
"itemId":"2",
"name":"desk",
"description":"Big Desk",
"quantity":"10",
"unitPrice":"85.00"
]
,
"tax":
"amount":"4.26",
"name":"level2 tax name",
"description":"level2 tax"
,
"duty":
"amount":"8.55",
"name":"duty name",
"description":"duty description"
,
"shipping":
"amount":"4.26",
"name":"level2 tax name",
"description":"level2 tax"
,
"poNumber":"456654",
"customer":
"id":"18",
"email":"someone@blackhole.tv"
,
"billTo":
"firstName":"Ellen",
"lastName":"Johnson",
"company":"Souveniropolis",
"address":"14 Main Street",
"city":"Pecan Springs",
"state":"TX",
"zip":"44628",
"country":"USA"
,
"shipTo":
"firstName":"China",
"lastName":"Bayles",
"company":"Thyme for Tea",
"address":"12 Main Street",
"city":"Pecan Springs",
"state":"TX",
"zip":"44628",
"country":"USA"
,
"customerIP":"192.168.1.1",
"transactionSettings":
"setting":[
"settingName":"allowPartialAuth",
"settingValue":"false"
,
"settingName":"duplicateWindow",
"settingValue":"0"
,
"settingName":"emailCustomer",
"settingValue":"false"
,
"settingName":"recurringBilling",
"settingValue":"false"
,
"settingName":"testRequest",
"settingValue":"false"
]
,
"userFields":
"userField":[
"name":"MerchantDefinedFieldName1",
"value":"MerchantDefinedFieldValue1"
,
"name":"favorite_color",
"value":"blue"
]
RESPONSE
"transactionResponse":
"responseCode":"1",
"authCode":"A2XE99",
"avsResultCode":"Y",
"cvvResultCode":"P",
"cavvResultCode":"2",
"transId":"40047374169",
"refTransID":"",
"transHash":"",
"testRequest":"0",
"accountNumber":"XXXX4797",
"accountType":"Visa",
"messages":[
"code":"1",
"description":"This transaction has been approved."
],
"userFields":[
"name":"MerchantDefinedFieldName1",
"value":"MerchantDefinedFieldValue1"
,
"name":"favorite_color",
"value":"blue"
],
"transHashSha2":"D8C48317CB529C6DFCC472F4548CAAC18F17F505BAD9077E54C117854D8791BADBC76DF6ECEA330E0462E0F9C4C60FDC13BEBDA068E5431EAA551DEB97F358DF",
"SupplementalDataQualificationIndicator":3,
"networkTransId":"A3HTA7GK9GEC0S1889A0M5O"
,
"refId":"49782069",
"messages":
"resultCode":"Ok",
"message":[
"code":"I00001",
"text":"Successful."
]
退款
"createTransactionRequest":
"merchantAuthentication":
"name":"",
"transactionKey":""
,
"refId":49782069,
"transactionRequest":
"transactionType":"refundTransaction",
"amount":5,
"payment":
"creditCard":
"cardNumber":"4427802641004797",
"expirationDate":"122020"
,
"authCode":"A2XE99"
RESPONSE
"transactionResponse":
"responseCode":"1",
"authCode":"",
"avsResultCode":"P",
"cvvResultCode":"",
"cavvResultCode":"",
"transId":"40047374178",
"refTransID":"",
"transHash":"",
"testRequest":"0",
"accountNumber":"XXXX4797",
"accountType":"Visa",
"messages":[
"code":"1",
"description":"This transaction has been approved."
],
"transHashSha2":"A5390A4933681142E2A41FEC37BF0303FC5FF30D9DF9CBD05FABEC2FA87FE3E241F0705B559924313E972E5457A633CCFA62B7C52A63D93BBB67ACC102D9984B",
"SupplementalDataQualificationIndicator":0
,
"refId":"49782069",
"messages":
"resultCode":"Ok",
"message":[
"code":"I00001",
"text":"Successful."
]
【讨论】:
我确实有正确的数据,但我在生产中的应用程序使用不同的 AuthNet 凭据,出于测试目的,我使用来自完全不同的 AuthNet 沙盒帐户的凭据。所以即使我有正确的数据,我认为我的问题是来自原始交易的数据在我的沙盒帐户中不存在。您认为这可能是问题所在吗? 这肯定是问题所在。它不会存在于您的沙盒帐户中,因此您无法针对它发出退款。 那你建议我怎么做?如何将我的沙盒帐户与我的生产帐户关联? 你不能。两者是分开的,您无法将数据从一个获取到另一个。如果您想在沙盒中发放退款以进行测试,您需要先在沙盒中重新创建这些付款,然后您可以针对这些付款测试发放退款。【参考方案2】:我尝试使用 John Conde 的方法并且它有效,但是该示例必须包括到期日期而不是 XXXX 和完整的信用卡号才能获得批准响应,至少在我的情况下是这样。 以下对我不起作用:
"createTransactionRequest":
"merchantAuthentication":
"name": "your_credentials_here",
"transactionKey": "your_credentials_here"
,
"transactionRequest":
"transactionType": "refundTransaction",
"amount": 1,
"currencyCode": "USD",
"payment":
"creditCard":
"cardNumber": "4444",
"expirationDate": "XXXX"
,
"authCode": "your_auth_code"
这对我有用:
"createTransactionRequest":
"merchantAuthentication":
"name": "your_credentials_here",
"transactionKey": "your_credentials_here"
,
"transactionRequest":
"transactionType": "refundTransaction",
"amount": 1,
"currencyCode": "USD",
"payment":
"creditCard":
"cardNumber": "4444444444444444",
"expirationDate": "1221"
,
"authCode": "your_auth_code"
【讨论】:
以上是关于Authorize.Net沙盒账户中的交易是不是可以退款?的主要内容,如果未能解决你的问题,请参考以下文章