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've shoot an email two days ago. I'm going to forward that email to you again.

 

Thanks!