cancel
Showing results for 
Search instead for 
Did you mean: 

error: E00001 An error occurred during processing. Please try again.

working on getHostedPaymentPageRequest API with my sandbox account.

 

getting this error:

 

ErrorE00001An error occurred during processing. Please try again.

 

Here's the xml post:

 

<getHostedPaymentPageRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
    <merchantAuthentication>
        <name>name</name>
        <transactionKey>transactionkey</transactionKey>
    </merchantAuthentication>
    <transactionRequest>
        <transactionType>authCaptureTransaction</transactionType>
        <amount>20.00</amount>
    </transactionRequest>
    <hostedPaymentSettings>
        <setting>
            <settingName>hostedPaymentBillingAddressOptions</settingName>
            <settingValue>{"show": true, "required":true}</settingValue>
        </setting>
        <setting>
            <settingName>hostedPaymentButtonOptions</settingName>
            <settingValue>{"text": "Pay"}</settingValue>
        </setting>
        <setting>
            <settingName>hostedPaymentReturnOptions</settingName>
            <settingValue>{"url":"https://testurl.com/good","urlText":"Continue","cancelUrl":"https://testurl.com/cancel","cancelUrlTe...>
        </setting>
    </hostedPaymentSettings>
</getHostedPaymentPageRequest>

ansherina
Contributor
21 REPLIES 21

Hi @ansherina,

 

Can you verify the url you're posting this too? Also, are you sending a Content-Type: header in your HTTP post? If so, what is it set to?

 

One other thing is to check the "hostedPaymentReturnOptions". It looks like from what you pasted, the closing curly brace is url encoded as %7D, although I don't know if it's our forum software that did that. Make sure that in your code that section looks like:

 

        <setting>
            <settingName>hostedPaymentReturnOptions</settingName>
            <settingValue>{"url":"https://testurl.com/good","urlText":"Continue","cancelUrl":"https://testurl.com/cancel","cancelUrlText":"cancel"}</settingValue>
        </setting>

 

If there's any way to capture the full HTTP request and post it here, that would be helpful.

Aaron
All Star

Hi @Aaron,

 

I'm using application/xml as content type. Kindly check the code below. I got it from your documentation on github just for testing.

 

<?php

$xmlStr = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<getHostedPaymentPageRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
    <merchantAuthentication></merchantAuthentication>
    <transactionRequest>
        <transactionType>authCaptureTransaction</transactionType>
        <amount>20.00</amount>
    </transactionRequest>
    <hostedPaymentSettings>
        <setting>
            <settingName>hostedPaymentBillingAddressOptions</settingName>
            <settingValue>{"show": true, "required":true}</settingValue>
        </setting>
        <setting>
            <settingName>hostedPaymentButtonOptions</settingName>
            <settingValue>{"text": "Pay"}</settingValue>
        </setting>
    </hostedPaymentSettings>
</getHostedPaymentPageRequest>
XML;
$xml = simplexml_load_string($xmlStr,'SimpleXMLElement', LIBXML_NOWARNING);

$xml->merchantAuthentication->addChild('name','name');
$xml->merchantAuthentication->addChild('transactionKey','transactionkey');

$commUrl = json_encode(array('url' => thisPageURL()."iCommunicator.html" ),JSON_UNESCAPED_SLASHES);
$xml->hostedPaymentSettings->setting[0]->addChild('settingValue',$commUrl);

$retUrl = json_encode(array("showReceipt" => false ,'url' => thisPageURL()."return.html","urlText"=>"Continue to site", "cancelUrl" => thisPageURL()."return.html", "cancelUrlText" => "Cancel" ),JSON_UNESCAPED_SLASHES);
$xml->hostedPaymentSettings->setting[2]->addChild('settingValue',$retUrl);

$url = "https://apitest.authorize.net/xml/v1/request.api";

    try{
        $ch = curl_init();
        if (FALSE === $ch)
        	throw new Exception('failed to initialize');
        curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml'));
        curl_setopt($ch, CURLOPT_POSTFIELDS, $xml->asXML());
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false );
        
        $content = curl_exec($ch);
        $content = str_replace('xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"', '', $content);

        $hostedPaymentResponse = new SimpleXMLElement($content);
        if (FALSE === $content)
        	throw new Exception(curl_error($ch), curl_errno($ch));
        curl_close($ch);

    }catch(Exception $e) {
    	trigger_error(sprintf('Curl failed with error #%d: %s', $e->getCode(), $e->getMessage()), E_USER_ERROR);
	}

    function thisPageURL() {
     $pageURL = 'http';
     if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
     $pageURL .= "://";
     if ($_SERVER["SERVER_PORT"] != "80") {
      $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
     } else {
      $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
     }

     $pageLocation = str_replace('index.php', '', $pageURL);

     return $pageLocation;
    }

?>

Thank You,

Ansherina

Hi @ansherina,

 

The way your code is constructed in the sample below, the part that adds $commUrl and $retUrl to the XML request isn't putting them in the right place. For example, it's trying to add $commUrl to the first <setting> element, but that's not a "hostedPaymentIFrameCommunicatorUrl" setting. Instead, it's adding a JSON string for the IFrame communicator URL to the hostedPaymentBillingAddressOptions setting, resulting in a malformed setting string. Once our system gets that, it doesn't know what to make of it, so it returns E00001.

 

If you replaced the XML part of the code with the following, everything would work correctly with that code sample:

<getHostedPaymentPageRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
    <merchantAuthentication></merchantAuthentication>
    <transactionRequest>
        <transactionType>authCaptureTransaction</transactionType>
        <amount>20.00</amount>
    </transactionRequest>
    <hostedPaymentSettings>
        <setting>
            <settingName>hostedPaymentIFrameCommunicatorUrl</settingName>
        </setting>
        <setting>
            <settingName>hostedPaymentBillingAddressOptions</settingName>
            <settingValue>{"show": true, "required":true}</settingValue>
        </setting>
        <setting>
            <settingName>hostedPaymentReturnOptions</settingName>
        </setting>
        <setting>
            <settingName>hostedPaymentButtonOptions</settingName>
            <settingValue>{"text": "Pay"}</settingValue>
        </setting>
    </hostedPaymentSettings>
</getHostedPaymentPageRequest>

The XML above has 2 more setting elements and has everything in the right order, so when the code tries to add strings to setting[0] and setting[2], it's adding those strings to the right settings.

 

By the way, was the XML in your post adapted from some of the things on GitHub, or is it something you copied directly out of one of our samples. If it's something you copied directly, please let us know where from so we can fix it!

 

Hi @Aaron,

 

Thank you very much for the help. Yup i got this from one of your github.

 

https://github.com/AuthorizeNet/accept-sample-app

 

- this file : getHostedPaymentForm.php

 

- Ansherina

 

The getHostedPaymentForm.php file appears to have all the right <setting> elements in it, so fortunately we don't have to fix anything there. It appears that you may have just pared it down for your use without updating the array references where the code was trying to modify settings.

 

No worries, though. If anything else isn't working for you, please let us know! We're happy to walk you through it.

By the way @Aaron, i also tested the one on your samples and it also gave me the same error.

 

Get an Accept Payment Page

 

- Ansherina

Shoot, that's frustrating, because the same part on the same page works fine for me.

 

Do you still get E000001 on that page now?

What happens if you try using the default credentials on that page instead of your credentials?

 

The default credentials are:

	<merchantAuthentication>
		<name>5KP3u95bQpv</name>
		<transactionKey>346HZ32z3fP4hTG2</transactionKey>
	</merchantAuthentication>

Can you copy and post the exact request out of that page that gives you an error?

Hi @Aaron,

 

Its weird cause it works using your default credentials, however it still gives me the same error whenever i use mine.

 

- Ansherina

Hi Ansherina,


ansherina wrote: 

Its weird cause it works using your default credentials, however it still gives me the same error whenever i use mine.


 

Ugh, that's frustrating. Are you using sandbox credentials or production credentials? Using production credentials to request a token in the sandbox won't work, but I assume it would give a different error than that.