0

我从 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 沙盒帐户的凭据。因此,即使我有正确的数据,我认为我的问题是原始交易中的数据在我的沙盒帐户中不存在。帮助将不胜感激。

4

2 回答 2

4

您可以在沙盒中测试退款,但它必须满足与生产环境相同的所有标准。他们的示例可能有陈旧的数据,但如果您使用新数据,它将对您有用。

要发出退款,必须满足以下条件:

  1. 该交易最初是通过支付网关 (Authorize.Net) 处理并成功结算的。
  2. x_trans_id交易是使用原始成功结算交易的有效交易 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."
         }
      ]
   }
}
于 2020-04-15T17:29:10.497 回答
1

我尝试使用 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"
    }
  }
}
于 2021-04-30T20:28:39.027 回答