I am trying to change some of the settings in the hostedPaymentSettings and whenever I try to add any settingValue I always get an error.
Here is my request:
<getHostedPaymentPageRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication></merchantAuthentication>
<transactionRequest>
<transactionType>authCaptureTransaction</transactionType>
<amount>22.50</amount>
<order>
<invoiceNumber>INV-12345</invoiceNumber>
<description>Product Description</description>
</order>
<lineItems>
<lineItem>
<itemId>2</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>1812940934</id>
<email>my@email.com</email>
</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>
<phoneNumber>1231231234</phoneNumber>
</billTo>
<customerIP>192.168.1.1</customerIP>
<userFields>
<userField>
<name>sessionID</name>
<value>ABC123</value>
</userField>
</userFields>
</transactionRequest>
<hostedPaymentSettings>
<setting>
<settingName>hostedPaymentIFrameCommunicatorUrl</settingName>
</setting>
<setting>
<settingName>hostedPaymentButtonOptions</settingName>
<settingValue>{"text": "Pay"}</settingValue>
</setting>
<setting>
<settingName>hostedPaymentReturnOptions</settingName>
<settingValue>{"url": https://www.mytestsite.com/done.php}</settingValue>
</setting>
<setting>
<settingName>hostedPaymentOrderOptions</settingName>
<settingValue>{"show": false}</settingValue>
</setting>
<setting>
<settingName>hostedPaymentPaymentOptions</settingName>
<settingValue>{"cardCodeRequired": true}</settingValue>
</setting>
<setting>
<settingName>hostedPaymentShippingAddressOptions</settingName>
<settingValue>{"show": false, "required":true}</settingValue>
</setting>
<setting>
<settingName>hostedPaymentBillingAddressOptions</settingName>
<settingValue>{"show": true, "required":true}</settingValue>
</setting>
<setting>
<settingName>hostedPaymentSecurityOptions</settingName>
<settingValue>{"captcha": false}</settingValue>
</setting>
<setting>
<settingName>hostedPaymentStyleOptions</settingName>
<settingValue>{"bgColor": "green"}</settingValue>
</setting>
<setting>
<settingName>hostedPaymentCustomerOptions</settingName>
<settingValue>{"showEmail": true, "requiredEmail":true}</settingValue>
</setting>
</hostedPaymentSettings>
</getHostedPaymentPageRequest>
Here is the error:
The element 'setting' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'settingValue' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.
09-05-2017 01:03 PM
Hi @PcDudes524,
You're missing a <settingValue> entry in your first setting (for hostedPaymentIFrameCommunicatorUrl). Can you add a <settingValue> and see if it works now?
09-05-2017 01:27 PM
I have tried adding the settingValue for hostedPaymentIFrameCommunicatorUrl and am still getting the same error.
The crazy thing about it is that the code works without the settingValues that I added.
If I send it like the code below it works fine:
<getHostedPaymentPageRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication></merchantAuthentication>
<transactionRequest>
<transactionType>authCaptureTransaction</transactionType>
<amount>22.50</amount>
<order>
<invoiceNumber>INV-12345</invoiceNumber>
<description>Product Description</description>
</order>
<lineItems>
<lineItem>
<itemId>2</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>1812940934</id>
<email>my@email.com</email>
</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>
<phoneNumber>1231231234</phoneNumber>
</billTo>
<customerIP>192.168.1.1</customerIP>
<userFields>
<userField>
<name>sessionID</name>
<value>ABC123</value>
</userField>
</userFields>
</transactionRequest>
<hostedPaymentSettings>
<setting>
<settingName>hostedPaymentIFrameCommunicatorUrl</settingName>
</setting>
<setting>
<settingName>hostedPaymentButtonOptions</settingName>
<settingValue>{"text": "Pay"}</settingValue>
</setting>
<setting>
<settingName>hostedPaymentReturnOptions</settingName>
</setting>
<setting>
<settingName>hostedPaymentOrderOptions</settingName>
<settingValue>{"show": false}</settingValue>
</setting>
<setting>
<settingName>hostedPaymentPaymentOptions</settingName>
<settingValue>{"cardCodeRequired": true}</settingValue>
</setting>
<setting>
<settingName>hostedPaymentShippingAddressOptions</settingName>
<settingValue>{"show": false, "required":true}</settingValue>
</setting>
<setting>
<settingName>hostedPaymentBillingAddressOptions</settingName>
<settingValue>{"show": true, "required":true}</settingValue>
</setting>
<setting>
<settingName>hostedPaymentSecurityOptions</settingName>
<settingValue>{"captcha": false}</settingValue>
</setting>
<setting>
<settingName>hostedPaymentStyleOptions</settingName>
<settingValue>{"bgColor": "green"}</settingValue>
</setting>
<setting>
<settingName>hostedPaymentCustomerOptions</settingName>
<settingValue>{"showEmail": true, "requiredEmail":true}</settingValue>
</setting>
</hostedPaymentSettings>
</getHostedPaymentPageRequest>
09-05-2017 02:15 PM
Ah, I see it now. Your URL needs to be in quotes in the hostedPaymentReturnOptions setting. The settingValue entries all need to be valid JSON objects, and the value in a JSON object needs to be in quotes unless it's something like false.
I'll bet if you put that in quotes, it'll work.
09-06-2017 04:30 PM
Ok, I have added in the quotation marks and am still getting the same error. Here is the new request I am sending
<getHostedPaymentPageRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication></merchantAuthentication>
<transactionRequest>
<transactionType>authCaptureTransaction</transactionType>
<amount>22.50</amount>
<order>
<invoiceNumber>INV-12345</invoiceNumber>
<description>Product Description</description>
</order>
<lineItems>
<lineItem>
<itemId>2</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>1812940934</id>
<email>my@email.com</email>
</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>
<phoneNumber>1231231234</phoneNumber>
</billTo>
<customerIP>192.168.1.1</customerIP>
<userFields>
<userField>
<name>sessionID</name>
<value>ABC123</value>
</userField>
</userFields>
</transactionRequest>
<hostedPaymentSettings>
<setting>
<settingName>hostedPaymentIFrameCommunicatorUrl</settingName>
</setting>
<setting>
<settingName>hostedPaymentButtonOptions</settingName>
<settingValue>{"text": "Pay"}</settingValue>
</setting>
<setting>
<settingName>hostedPaymentReturnOptions</settingName>
<settingValue>{"url": "https://mysite.com/receipt"}</settingValue>
</setting>
<setting>
<settingName>hostedPaymentOrderOptions</settingName>
<settingValue>{"show": false}</settingValue>
</setting>
<setting>
<settingName>hostedPaymentPaymentOptions</settingName>
<settingValue>{"cardCodeRequired": true}</settingValue>
</setting>
<setting>
<settingName>hostedPaymentShippingAddressOptions</settingName>
<settingValue>{"show": false, "required":true}</settingValue>
</setting>
<setting>
<settingName>hostedPaymentBillingAddressOptions</settingName>
<settingValue>{"show": true, "required":true}</settingValue>
</setting>
<setting>
<settingName>hostedPaymentSecurityOptions</settingName>
<settingValue>{"captcha": false}</settingValue>
</setting>
<setting>
<settingName>hostedPaymentStyleOptions</settingName>
<settingValue>{"bgColor": "green"}</settingValue>
</setting>
<setting>
<settingName>hostedPaymentCustomerOptions</settingName>
<settingValue>{"showEmail": true, "requiredEmail":true}</settingValue>
</setting>
</hostedPaymentSettings>
</getHostedPaymentPageRequest>
09-07-2017 09:26 AM
Place a hostedPaymentIFrameCommunicatorUrl value and you should be good to go.
<settingName>hostedPaymentIFrameCommunicatorUrl</settingName> <settingValue>{"url": "https://YOURSITE.com/Communicator.html"}</settingValue>
09-07-2017 09:41 AM - edited 09-07-2017 09:42 AM
My bad, I have added the hostedPaymentIFrameCommunicatorUrl url setting and am still receiving an error.
09-07-2017 10:31 AM
The following is what works:
<getHostedPaymentPageRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"> <merchantAuthentication> <name>API_LOGIN</name> <transactionKey>TRANSACTION_KEY</transactionKey> </merchantAuthentication> <transactionRequest> <transactionType>authCaptureTransaction</transactionType> <amount>22.50</amount> <order> <invoiceNumber>INV-12345</invoiceNumber> <description>Product Description</description> </order> <lineItems> <lineItem> <itemId>2</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>1812940934</id> <email>my@email.com</email> </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> <phoneNumber>1231231234</phoneNumber> </billTo> <customerIP>192.168.1.1</customerIP> <userFields> <userField> <name>sessionID</name> <value>ABC123</value> </userField> </userFields> </transactionRequest> <hostedPaymentSettings> <setting> <settingName>hostedPaymentIFrameCommunicatorUrl</settingName> <settingValue>{"url": "https://mysite.com/IFrameCommunicatorUrl.html"}</settingValue> </setting> <setting> <settingName>hostedPaymentButtonOptions</settingName> <settingValue>{"text": "Pay"}</settingValue> </setting> <setting> <settingName>hostedPaymentReturnOptions</settingName> <settingValue>{"url": "https://mysite.com/receipt"}</settingValue> </setting> <setting> <settingName>hostedPaymentOrderOptions</settingName> <settingValue>{"show": false}</settingValue> </setting> <setting> <settingName>hostedPaymentPaymentOptions</settingName> <settingValue>{"cardCodeRequired": true}</settingValue> </setting> <setting> <settingName>hostedPaymentShippingAddressOptions</settingName> <settingValue>{"show": false, "required":true}</settingValue> </setting> <setting> <settingName>hostedPaymentBillingAddressOptions</settingName> <settingValue>{"show": true, "required":true}</settingValue> </setting> <setting> <settingName>hostedPaymentSecurityOptions</settingName> <settingValue>{"captcha": false}</settingValue> </setting> <setting> <settingName>hostedPaymentStyleOptions</settingName> <settingValue>{"bgColor": "green"}</settingValue> </setting> <setting> <settingName>hostedPaymentCustomerOptions</settingName> <settingValue>{"showEmail": true, "requiredEmail":true}</settingValue> </setting> </hostedPaymentSettings> </getHostedPaymentPageRequest>
09-07-2017 10:59 AM - edited 09-07-2017 11:00 AM
Does it matter if I am using the default "mysite.com"?
Is there any way to tell what line of the XML request is causing the error?
I have tried your code and am still getting the invalid child element error.
Thank you for helping.
09-07-2017 11:04 AM
If you are getting an invalid child element, your application is not posting that XML. Paste the above XML into the try it tab at : http://developer.authorize.net/api/reference/index.html#payment-transactions-get-an-accept-payment-p..., using your own Sandbox Credentials.
You can use any URL in place of the default "mysite.com" .
09-07-2017 11:11 AM