添加客户多笔支付时如何解决名称空间中元素'createCustomerProfileRequest'的错误

时间:2018-12-28 04:30:04

标签: authorize.net authorize.net-cim

我想在authorize.net中添加单个客户的多个付款资料。经过长时间的搜索,我到达了在authorize.net社区上发布的帖子,参见link。在此链接中,在接受的解决方案中有一个xml格式的数据,我将其转换并通过邮递员发送,然后遇到

的错误
  

“名称空间'AnetApi / xml / v1 / schema / AnetApiSchema.xsd'中的元素'createCustomerProfileRequest'在名称空间'AnetApi / xml / v1 / schema / AnetApiSchema.xsd'中具有无效的子元素'_xmlns'。”

我要发送的json是:-

{
  "createCustomerProfileRequest": {
    "merchantAuthentication": {
        "name": "name",
        "transactionKey": "transactionKey"
    },
    "refId": "1361101257555",
    "profile": {
        "merchantCustomerId": "2CLINC056",
        "description": "hiiiiii.",
        "email": "",
        "paymentProfiles": [
            {
                "customerType": "individual",
                "billTo": {
                    "firstName": "Joe",
                    "lastName": "Test",
                    "company": "CompanyA",
                    "address": "hello",
                    "city": "Bangalore",
                    "state": "Delhi",
                    "zip": "560078",
                    "country": "IN",
                    "phoneNumber": "415-555-1212",
                    "faxNumber": "415-555-1313"
                },
                "payment": {
                    "creditCard": {
                        "cardNumber": "370000000000002",
                        "expirationDate": "2029-12"
                    }
                }
            },
            {
                "customerType": "individual",
                "billTo": {
                    "firstName": "Joe",
                    "lastName": "Test",
                    "company": "CompanyA",
                    "address": "vel",
                    "city": "Chennai",
                    "state": "AK",
                    "zip": "560089",
                    "country": "US",
                    "phoneNumber": "415-555-1212",
                    "faxNumber": "415-555-1313"
                },
                "payment": {
                    "creditCard": {
                        "cardNumber": "38000000000006",
                        "expirationDate": "2029-12"
                    }
                }
            }
        ]
    },
    "validationMode": "testMode",
    "_xmlns": "AnetApi/xml/v1/schema/AnetApiSchema.xsd"
  }
}

开发者link

1 个答案:

答案 0 :(得分:0)

我认为您的问题不在于付款资料,而在于JSON本身。您在那里有一个无效元素,我认为是这一行:

"_xmlns": "AnetApi/xml/v1/schema/AnetApiSchema.xsd"

否则,您的请求看起来不错,因为我能够使用类似的JSON创建多个付款资料。两者之间的唯一区别是我的JSON没有该行。

请求JSON:

{
  "createCustomerProfileRequest": {
    "merchantAuthentication": {
      "name": "xxxxxxxx",
      "transactionKey": "xxxxxxxxxxxxxxxx"
    },
    "profile": {
      "merchantCustomerId": "52353345",
      "email": "user@example.com",
      "paymentProfiles": [
        {
          "customerType": "individual",
          "billTo": {
            "firstName": "John",
            "lastName": "Smith",
            "address": "12345 Main Street",
            "city": "Townsville",
            "state": "NJ",
            "zip": "12345",
            "phoneNumber": "800-555-1234"
          },
          "payment": {
            "creditCard": {
              "cardNumber": "5555555555554444",
              "expirationDate": "2023-08"
            }
          }
        },
        {
          "customerType": "individual",
          "billTo": {
            "firstName": "John",
            "lastName": "Smithberg",
            "address": "42 Main Street",
            "city": "Townsville",
            "state": "NJ",
            "zip": "12345",
            "phoneNumber": "800-555-1234"
          },
          "payment": {
            "creditCard": {
              "cardNumber": "5105105105105100",
              "expirationDate": "2023-09"
            }
          }
        }
      ],
      "shipToList": {
        "firstName": "John",
        "lastName": "Smith",
        "address": "12345 Main Street",
        "city": "Townsville",
        "state": "NJ",
        "zip": "12345",
        "phoneNumber": "800-555-1234"
      }
    },
    "validationMode": "liveMode"
  }
}

响应JSON:

{
  "customerProfileId": "1506322353",
  "customerPaymentProfileIdList": [
    "1505667207",
    "1505667208"
  ],
  "customerShippingAddressIdList": [
    "1505655763"
  ],
  "validationDirectResponseList": [
    "1,1,1,This transaction has been approved.,A2FD5O,Y,40023515435,none,Test transaction for ValidateCustomerPaymentProfile.,0.00,CC,auth_only,52353345,John,Smith,,12345 Main Street,Townsville,NJ,12345,,800-555-1234,,user@example.com,,,,,,,,,0.00,0.00,0.00,FALSE,none,32573C7D03376A9052AACA73835EDAEF,P,2,,,,,,,,,,,XXXX4444,MasterCard,,,,,,,,,,,,,,,,,",
    "1,1,1,This transaction has been approved.,AO13Y1,Y,40023515436,none,Test transaction for ValidateCustomerPaymentProfile.,0.00,CC,auth_only,52353345,John,Smithberg,,42 Main Street,Townsville,NJ,12345,,800-555-1234,,user@example.com,,,,,,,,,0.00,0.00,0.00,FALSE,none,5B937D29D29F261776859B50DC1C3CF6,P,2,,,,,,,,,,,XXXX5100,MasterCard,,,,,,,,,,,,,,,,,"
  ],
  "messages": {
    "resultCode": "Ok",
    "message": [
      {
        "code": "I00001",
        "text": "Successful."
      }
    ]
  }
}