2017-10-04 18 views
2

でトランザクション作成リクエストを使用して支払いプロファイルを作成する方法createTransactionRequestを使用して支払いプロファイルを作成したいとします。Authorize.net

ここに私が渡しているリクエストパラメータがあります。

{ 
    "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'." 
     } 
     ] 
    } 
} 

答えて

2

リクエストのフィールドの順序が重要です。ドキュメント内の内容と一致する必要があります。

{ 
    "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" 
     }, 
     } 
    } 
} 

この要求は私にこの応答が得られます:あなたはcustomeridフィールドを追加する必要があるよう

{ 
    "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." 
      } 
     ] 
    } 
} 

が見えることは、フィールドがあなたのJSONにbillToフィールドを来る必要があることを意味しますセクション:

{ 
    "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." 
      } 
     ] 
    } 
} 
+0

どの顧客IDを渡す必要がありますか?それに任意の乱数を渡すことができますか? –

+1

はい、独自のユーザーIDをお持ちでない場合は、任意の乱数を使用できます。 –

+0

すべてのジョンのおかげですごく感謝してくれました。 –