I am currently trying to make a request to the Authorize.net AIM api. I have successfully sent the post in Post Man. The issue I am having has to do with the fact that the posted data has to be in xml. When I try to set the data to xml as shown in the sample below, I receive an error of Unexpected token ILLEGAL. Any help with this error would be great. Additionally if there is a better way to format the xml for the post please let me know I have looked around allot with no success.
$.ajax({ type : "POST", url : "https://apitest.authorize.net/xml/v1/request.api", data : "<createTransactionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"> <merchantAuthentication> <name>xxxxxxxxxxx</name> <transactionKey>xxxxxxxxxxx</transactionKey> </merchantAuthentication> <refId>123456</refId> <transactionRequest> <transactionType>authCaptureTransaction</transactionType> <amount>5</amount> <payment> <creditCard> <cardNumber>5424000000000015</cardNumber> <expirationDate>1220</expirationDate> <cardCode>999</cardCode> </creditCard> </payment> <order> <invoiceNumber>INV-12345</invoiceNumber> <description>Product Description</description> </order> <lineItems> <lineItem> <itemId>1</itemId> <name>vase</name> <description>Cannes logo </description> <quantity>18</quantity> <unitPrice>45.00</unitPrice> </lineItem> </lineItems> <tax> <amount>4.26</amount> <name>level2 tax name</name> <description>level2 tax</description> </tax> <duty> <amount>8.55</amount> <name>duty name</name> <description>duty description</description> </duty> <shipping> <amount>4.26</amount> <name>level2 tax name</name> <description>level2 tax</description> </shipping> <poNumber>456654</poNumber> <customer> <id>99999456654</id> </customer> <billTo> <firstName>Ellen</firstName> <lastName>Johnson</lastName> <company>Souveniropolis</company> <address>14 Main Street</address> <city>Pecan Springs</city> <state>TX</state> <zip>44628</zip> <country>USA</country> </billTo> <shipTo> <firstName>China</firstName> <lastName>Bayles</lastName> <company>Thyme for Tea</company> <address>12 Main Street</address> <city>Pecan Springs</city> <state>TX</state> <zip>44628</zip> <country>USA</country> </shipTo> <customerIP>192.168.1.1</customerIP> <transactionSettings> <setting> <settingName>testRequest</settingName> <settingValue>false</settingValue> </setting> </transactionSettings> <userFields> <userField> <name>MerchantDefinedFieldName1</name> <value>MerchantDefinedFieldValue1</value> </userField> <userField> <name>favorite_color</name> <value>blue</value> </userField> </userFields> </transactionRequest> </createTransactionRequest>", dataType : "xml", success : function(msg){ console.log("success"); } error : function(msg) { console.log("fail"); } });
No comments:
Post a Comment