cancel
Showing results for 
Search instead for 
Did you mean: 

Accept Hosted not working.

Hello,

 

we are on a time constraint to have our site working and Accept Hosted is not working upon using the name and transactionKey begin generated in my merchant admin whether if I toggle it in LIVE or TEST.

 

It doesn't  even work in my sandbox generated account.

 

Can somebody pretty please look into this.

 

Thanks!

 

for your reference:

/** Authorize **/

    public function get_payment_request_token() {

        $request = $_POST;
        $errorMessage = array();

        if($request) {

            parse_str($request['formdata'], $formdata);

            $this->load->model("System_model");

            $authorize = $this->system_model->get_authorize_credentials(array('auth_active'=>1));

            $loginID = $authorize['auth_client'];
            $transKey = $authorize['auth_key'];
            $url = $authorize['auth_url'];

	    $state = isset($formdata['cust_billing_state'])?$formdata['cust_billing_state']:"";

            $jsonStr = '{
                        "getHostedPaymentPageRequest": {
                            "merchantAuthentication": {
                                "name": "'.$loginID.'",
                                "transactionKey": "'.$transKey.'"
                            },
                            "transactionRequest": {
                                "transactionType": "authCaptureTransaction",
                                "amount": "'.$formdata['or_total_amount'].'",
                                "customer": {
                                    "email": "'.$formdata['cust_billing_email'].'"
                                },
                                "billTo": {
                                    "firstName": "'.ucwords($formdata['cust_billing_first_name']).'",
                                    "lastName": "'.ucwords($formdata['cust_billing_last_name']).'",
                                    "company": "",
                                    "address": "'.$formdata['cust_billing_address1'].' '.$formdata['cust_billing_address2'].'",
                                    "city": "'.$formdata['cust_billing_city'].'",
                                    "state": "'.$state.'",
                                    "zip": "'.$formdata['cust_billing_postal_code'].'",
                                    "country": "USA",
                                    "phoneNumber": "'.$formdata['cust_billing_phone_number'].'",
                                }
                            },
                            "hostedPaymentSettings": {
                                "setting": [{
                                    "settingName": "hostedPaymentIFrameCommunicatorUrl",
                                    "settingValue": "{\"url\": \"http://lyfelite.com/beta/cart.php\"}"
                                }, {
                                    "settingName": "hostedPaymentBillingAddressOptions",
                                    "settingValue": "{\"show\": true, \"required\":true}"
                                }, {
                                    "settingName": "hostedPaymentButtonOptions",
                                    "settingValue": "{\"text\": \"Pay Now\"}"
                                }, {
                                    "settingName": "hostedPaymentCustomerOptions",
                                    "settingValue": "{\"showEmail\":true,\"requiredEmail\":true}"
                                }, {
                                    "settingName": "hostedPaymentPaymentOptions",
                                    "settingValue": "{\"cardCodeRequired\":true}"
                                }, {
                                    "settingName": "hostedPaymentReturnOptions",
                                    "settingValue": "{\"showReceipt\": true,\"url\":\"http://lyfelite.com/beta/continue\",\"urlText\":\"Continue\",\"cancelUrl\":\"http://lyfelite.com/beta/cancel\",\"cancelUrlText\":\"Cancel\"}"
                                }, {
                                    "settingName": "hostedPaymentSecurityOptions",
                                    "settingValue": "{\"captcha\": true}"
                                }, {
                                    "settingName": "hostedPaymentShippingAddressOptions",
                                    "settingValue": "{\"show\":true,\"required\":true}"
                                }, {
                                    "settingName": "hostedPaymentStyleOptions",
                                    "settingValue": "{\"bgColor\": \"blue\"}"
                                }]
                            }
                        }
                    }';

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

                    try{                                                                                                                     
                        $ch = curl_init($url);

                        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
                        curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr);                                                                  
                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
                        curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
                            'Content-Type: application/json',                                                                                
                            'Content-Length: ' . strlen($jsonStr))                                                                       
                        ); 
                        
                        $content = curl_exec($ch);
                        echo $content;die;
                        $data = $content;
                        
                        curl_close($ch);

                    }catch(Exception $e) {
                        trigger_error(sprintf('Curl failed with error #%d: %s', $e->getCode(), $e->getMessage()), E_USER_ERROR);
                    }
        } else {
            $errorMessage[] = "Invalid Request";
        }

        echo json_encode(array('data'=>json_decode($data, true), 'error'=>implode(". <br>", $errorMessage)));

    }
ferdie33
Contributor
10 REPLIES 10

I got my sandbox account working:

 

 

ID: 84EG2H9Sdv3

Tkey: 22q9jK5aEEmwj245

SKey: E7F5827B76A8FC82C6F67B20F2BE1004F7F6924A5E11BB07021D0E82E7C19F3FE5B85B0E0AA0BD6F9B1EE62F454F825AFE27094F6FE35D83AEB2602719AD538B

 

url: https://apitest.authorize.net/xml/v1/request.api

 

However, production in TEST or LIVE mode doesn't work:

 

ID: lemmeknow
Tkey: generated
Skey: and also generated

 

url: https://api.authorize.net/xml/v1/request.api

 

Please let me know if you need me to post at least the API Login ID. Thanks!

 

 

 

ferdie33
Contributor

Hi @ferdie33,

 

Again, I'm sorry about the troubles you're having. If you can answer the following questions, that would be great.

 

  • Previously you said it didn't work in sandbox, but now it does. What changed? Was it creating the signature key or something else?
  • Just to clarify, it's the E00001 error you're getting in response to the token request, right?
  • Do you have an easy way to capture the output of the curl request (the actual HTTP request that's getting sent to our server) for us to see?

Hello Aaron:

 

1. Yes the signature key passed on the header made the thing worked (on my sandbox account).

2. I et to see the payment page but as soon as I hit pay button an error authentication prompts me.

3. Now it giving me a different error:

 

 




error

 

Any way you can post the HTTP request curl is sending, either by using Fiddler or similar, or setting 'curl_setopt verbose'?

Good Morning:

 

 

Here's the report:

 

 

* About to connect() to api.authorize.net port 443 (#0)
   Trying 64.94.118.84...  connected
* Connected to api.authorize.net (64.94.118.84) port 443 (#0)
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate:
*  subject: CN=*.authorize.net,O=Authorize.Net,L=Bellevue,ST=Washington,C=US
*  start date: Mar 25 18:50:09 2015 GMT
*  expire date: May 26 04:15:57 2018 GMT
  common name: .authorize.net
*  issuer: CN=Entrust Certification Authority - L1K,OU="(c) 2012 Entrust, Inc. - for authorized use only"
,OU=See www.entrust.net/legal-terms,O="Entrust, Inc.",C=US
> POST /xml/v1/request.api HTTP/1.1
Host: api.authorize.net
Accept: /
Content-Type: application/json
Content-Length: 3377
Authorization: HHMAC; signature={$signature}
Expect: 100-continue

< HTTP/1.1 100 Continue
< HTTP/1.1 200 OK
< Cache-Control: private
< Content-Type: application/json; charset=utf-8
< Server: Microsoft-IIS/7.5
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: PUT,OPTIONS,POST,GET
< Access-Control-Allow-Headers: x-requested-with,cache-control,content-type,origin,method,SOAPAction

< X-AspNet-Version: 4.0.30319
< X-Powered-By: ASP.NET
< Date: Fri, 24 Feb 2017 14:36:03 GMT
< Connection: close
< Content-Length: 1878
< 
* Closing connection #0

So sorry, I thought verbose would get me the http post body. Can you instead maybe add a line like this after you set the curl options:

print_r($jsonStr->asXML());

Then, can you post the output?

 

I'm trying to get an example of exactly how the posted data looks after it runs through your code in exactly the same format it would be hitting our server.

 

Thanks!

{
                        "getHostedPaymentPageRequest": {
                            "merchantAuthentication": {
                                "name": "#########",
                                "transactionKey": "#############"
                            },
                            "transactionRequest": {
                                "transactionType": "authCaptureTransaction",
                                "amount": "29.95",
                                "customer": {
                                    "email": "##########"
                                },
                                "billTo": {
                                    "firstName": "Ann",
                                    "lastName": "Test",
                                    "company": "",
                                    "address": "addr ",
                                    "city": "city",
                                    "state": "ca",
                                    "zip": "34222",
                                    "country": "USA",
                                    "phoneNumber": "8756765345",
                                }
                            },
                            "hostedPaymentSettings": {
                                "setting": [{
                                    "settingName": "hostedPaymentIFrameCommunicatorUrl",
                                    "settingValue": "{\"url\": \"http://lyfelite.com/beta/cart.php\"
}"
                                }, {
                                    "settingName": "hostedPaymentBillingAddressOptions",
                                    "settingValue": "{\"show\": true, \"required\":true}"
                                }, {
                                    "settingName": "hostedPaymentButtonOptions",
                                    "settingValue": "{\"text\": \"Pay Now\"}"
                                }, {
                                    "settingName": "hostedPaymentCustomerOptions",
                                    "settingValue": "{\"showEmail\":true,\"requiredEmail\":true}"
                                }, {
                                    "settingName": "hostedPaymentPaymentOptions",
                                    "settingValue": "{\"cardCodeRequired\":true}"
                                }, {
                                    "settingName": "hostedPaymentReturnOptions",
                                    "settingValue": "{\"showReceipt\": true,\"url\":\"http://lyfelite
.com/beta/continue\",\"urlText\":\"Continue\",\"cancelUrl\":\"http://lyfelite.com/beta/cancel\",\"cancelUrlText
\":\"Cancel\"}"
                                }, {
                                    "settingName": "hostedPaymentSecurityOptions",
                                    "settingValue": "{\"captcha\": true}"
                                }, {
                                    "settingName": "hostedPaymentShippingAddressOptions",
                                    "settingValue": "{\"show\":true,\"required\":true}"
                                }, {
                                    "settingName": "hostedPaymentStyleOptions",
                                    "settingValue": "{\"bgColor\": \"blue\"}"
                                }]
                            }
                        }
                    }

 

Here's the code I've hashed out keys there.

Thanks for this. I spaced it earlier, and forgot your were using JSON instead of XML, so inappropriately suggested using asXML() in the php code. Glad you got the request anyway.

 

Good news is I can reproduce the issue with the code you posted. I'm investigating now to see what's actually triggering it. Stay tuned.

No, sorry, I spoke too soon. I introduced an error when I copied and pasted. Once I fixed that, the token request works correctly for me, and calls a payment form that works without error.

 

One more thing to double check: When you switch from test to production, you're changing all the URLs that you might hit, right? Like you're requesting the token from the production URL, and sending the token in the form request to that production URL, right? Sending a test token to build the production form and vice versa would obviously fail, although I don't think it would error out this way.

 

So, you're inadvertantly triggering some bug or error condition, but as of yet, I can't see how. I'll need to dig into this a little deeper, and I'd love it if you could help me. Can you contact me directly at aawright@authorize.net and tell me what your availability is for a phone call to work on this?