Authorize.Net 沙盒帐户中的交易可以退款吗?

Is it possible to refund a transaction in Authorize.Net sandbox account?

我正在从 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)处理并成功结算的。
  2. 使用原始成功结算交易的有效交易 ID (x_trans_id) 提交交易。
  3. 申请退款金额小于等于原结算金额
  4. 原交易提交的多笔Credit交易之和小于或等于原结算金额
  5. 至少提交用于原始成功结算交易的信用卡号 (x_card_num) 的最后四位数字。不需要到期日期。
  6. 交易在原交易结算日起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."
         }
      ]
   }
}

我尝试使用 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"
    }
  }
}