gpt4 book ai didi

authorize.net - 如何使用 Authorize.net 上的创建交易请求创建付款资料

转载 作者:行者123 更新时间:2023-12-04 03:09:12 27 4
gpt4 key购买 nike

我想使用 createTransactionRequest 创建付款资料。

这是我传递的请求参数。

{
"createTransactionRequest":{
"merchantAuthentication":{
"name":"***",
"transactionKey":"***"
},
"transactionRequest":{
"transactionType":"authCaptureTransaction",
"amount":"4.95",
"payment":{
"creditCard":{
"cardNumber":"5424000000000015",
"expirationDate":"1217",
"cardCode":123
}
},
"billTo":{
"firstName":"first name",
"lastName":"last name",
"address":"test address",
"city":"test city",
"state":"TX",
"zip":"12345",
"country":"USA"
},
"profile":{
"createProfile":true
}
}
}
}

这是响应错误。

{
"messages":{
"resultCode":"Error",
"message":[
{
"code":"E00003",
"text":"The element 'transactionRequest' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'profile' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. List of possible elements expected: 'shipTo, customerIP, cardholderAuthentication, retail, employeeId, transactionSettings, userFields, surcharge, merchantDescriptor, subMerchant, tip' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'."
}
]
}
}

最佳答案

请求中字段的顺序很重要。它们必须与文档中的内容相匹配。这意味着该字段需要位于 JSON 中的 billTo 字段之前:

{
"createTransactionRequest":{
"merchantAuthentication":{
"name":"***",
"transactionKey":"***"
},
"transactionRequest":{
"transactionType":"authCaptureTransaction",
"amount":"4.95",
"payment":{
"creditCard":{
"cardNumber":"5424000000000015",
"expirationDate":"1217",
"cardCode":123
}
},
"profile":{
"createProfile":true
},
"billTo":{
"firstName":"first name",
"lastName":"last name",
"address":"test address",
"city":"test city",
"state":"TX",
"zip":"12345",
"country":"USA"
},
}
}
}

这个请求产生了这个响应:

{
"transactionResponse": {
"responseCode": "1",
"authCode": "Y77MQH",
"avsResultCode": "Y",
"cvvResultCode": "P",
"cavvResultCode": "2",
"transId": "40007520179",
"refTransID": "",
"transHash": "94D188D090B695D7C6D47D9293840BE3",
"testRequest": "0",
"accountNumber": "XXXX0015",
"accountType": "MasterCard",
"messages": [
{
"code": "1",
"description": "This transaction has been approved."
}
],
"transHashSha2": "9768048279544EDB22BAAAC194CA3EDBA705FBC569AC9555F3A2A86E545938849CEB2D9519885A4CC69328BBB7DDC36E0852998CAD5FAC1F6CA6427599E3493B"
},
"profileResponse": {
"messages": {
"resultCode": "Error",
"message": [
{
"code": "E00102",
"text": "Customer Info is missing."
}
]
}
},
"messages": {
"resultCode": "Ok",
"message": [
{
"code": "I00001",
"text": "Successful."
}
]
}
}

看起来您需要在 customer 部分添加 id 字段:

{
"createTransactionRequest":{
"merchantAuthentication":{
"name":"***",
"transactionKey":"***"
},
"transactionRequest":{
"transactionType":"authCaptureTransaction",
"amount":"4.95",
"payment":{
"creditCard":{
"cardNumber":"5424000000000015",
"expirationDate":"1217",
"cardCode":123
}
},
"profile":{
"createProfile":true
},
"customer":{
"id":<yourIdForThisUser>
},
"billTo":{
"firstName":"first name",
"lastName":"last name",
"address":"test address",
"city":"test city",
"state":"TX",
"zip":"12345",
"country":"USA"
},
}
}
}

产生:

{
"transactionResponse": {
"responseCode": "1",
"authCode": "SCSVNX",
"avsResultCode": "Y",
"cvvResultCode": "P",
"cavvResultCode": "2",
"transId": "40007520393",
"refTransID": "",
"transHash": "DFB7FE5B8D3FAFE0A18A6B5C125838A3",
"testRequest": "0",
"accountNumber": "XXXX0015",
"accountType": "MasterCard",
"messages": [
{
"code": "1",
"description": "This transaction has been approved."
}
],
"transHashSha2": "57C6A161A948E5A7F5303FCD2FE8CDF3E1D3C38B989161675D47FD61526F3DA9EDBD497169F978860B78A2C5FEC1B6E54807086DF4B0CE346538DDDD9E25C4A8"
},
"profileResponse": {
"messages": {
"resultCode": "Ok",
"message": [
{
"code": "I00001",
"text": "Successful."
}
]
},
"customerProfileId": "1502546960",
"customerPaymentProfileIdList": [
"1502081232"
],
"customerShippingAddressIdList": []
},
"messages": {
"resultCode": "Ok",
"message": [
{
"code": "I00001",
"text": "Successful."
}
]
}
}

关于authorize.net - 如何使用 Authorize.net 上的创建交易请求创建付款资料,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46572722/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com