James Doherty
James Doherty

Reputation: 1411

Accepted Host form does not display

1) Using The Redirect Method 2) Accepted Host 3) Using SDK(PHP) from GitHub

I request token and all seems to work just fine. But When I redirect to the PAYMENT PAGE I get the following response

When I redirect to https://test.authorize.net/payment/payment

I get a page with only Order Summary at the top, the rest of the page is empty.

Any help greatly appreciated.

Jim

Here is the code I use to set the form details etc.

function set_hosted_form_options($mbrobj,$x_realy_url,$x_cancel_url)
     {
        $this->seting_incr = 0;
        $setting = array();
        $setting[$this->seting_incr] = new AnetAPI\SettingType();
        $setting[$this->seting_incr]->setSettingName("hostedPaymentButtonOptions");
        $setting[$this->seting_incr]->setSettingValue("{\"text\": \"Submit Payment\"}");

        $this->seting_incr++;

        $setting[$this->seting_incr] = new AnetAPI\SettingType();
        $setting[$this->seting_incr]->setSettingName("hostedPaymentStyleOptions");
        $setting[$this->seting_incr]->setSettingValue("{\"bgColor\": \"red\"}");

        $this->seting_incr++;

        $setting[$this->seting_incr] = new AnetAPI\SettingType();
        $setting[$this->seting_incr]->setSettingName("hostedPaymentOrderOptions");
        $setting[$this->seting_incr]->setSettingValue("{\"show\": true,\"merchantName\":\"Texas Girls Coaches Assoc.\"}");

        $this->seting_incr++;

        $setting[$this->seting_incr] = new AnetAPI\SettingType();
        $setting[$this->seting_incr]->setSettingName("hostedPaymentReturnOptions");
        $x_relay_url = $this->anobj->get_field('x_relay_url');
        $x_relay_url .= "&invid=";
        $x_relay_url .= $this->get_invoice();
        $x_cancel_url = $this->anobj->get_field('x_cancel_url');
        $x_cancel_url .= "&invid=";
        $x_cancel_url .= $this->get_invoice();
        $setting[$this->seting_incr]->setSettingValue("{\"url\": \"".$x_relay_url."\", \"cancelUrl\": \"".$x_cancel_url."\", \"showReceipt\": true}");

        $this->seting_incr++;
        $setting[$this->seting_incr] = new AnetAPI\SettingType();
        $setting[$this->seting_incr]->setSettingName("hostedPaymentPaymentOptions");
        $setting[$this->seting_incr]->setSettingValue("{\"cardCodeRequired\":true,\"showCreditCard\": true,\"showBankAccount\":true}");

        $this->seting_incr++;

        $setting[$this->seting_incr] = new AnetAPI\SettingType();
        $setting[$this->seting_incr]->setSettingName("hostedPaymentSecurityOptions");
        $setting[$this->seting_incr]->setSettingValue("{\"captcha\":true}");

        $this->seting_incr++;

        $setting[$this->seting_incr] = new AnetAPI\SettingType();
        $setting[$this->seting_incr]->setSettingName("hostedPaymentBillingAddressOptions");
        $setting[$this->seting_incr]->setSettingValue("{\"show\":true}");

        $this->seting_incr++;

        $setting[$this->seting_incr] = new AnetAPI\SettingType();
        $setting[$this->seting_incr]->setSettingName("hostedPaymentCustomerOptions");
        $setting[$this->seting_incr]->setSettingValue("{\"showEmail\":true,\"requiredEmail\":true}");
        $this->seting_incr++;

        $this->set_form_options($setting);
        return($setting);

This is the code for the create_transaction

function create_transaction($amount)
     {
            $this->transactionRequestType = new AnetAPI\TransactionRequestType();
            $this->transactionRequestType->setTransactionType( "authCaptureTransaction");
            $this->transactionRequestType->setAmount($amount);
            //$transactionRequestType->setOrder($order);
            //$transactionRequestType->setPayment($paymentOne);
            $lineItems = $this->get_line_items();
            $this->transactionRequestType->setLineItems($lineItems);
        return($this->transactionRequestType);
     }

Here is the code for the add_line_items to the invoice:

function add_line_item($item_id,$name,$desc,$qty,$unit_price,$taxable=0)
     {
        if($this->DEBUG)
        {
            $this->logEvent("INFO: ITEM ID [".$item_id."]");
            $this->logEvent("INFO: NAMe    [".$name."]");
            $this->logEvent("INFO: DESC    [".$desc."]");
            $this->logEvent("INFO: QTY     [".$qty."]");
            $this->logEvent("INFO: UNIT PR [".$unit_price."]");
            $this->logEvent("INFO: TAXABLE [".$taxable."]");
        }
            $lineItem1 = new AnetAPI\LineItemType();
            $lineItem1->setItemId($item_id);
            $lineItem1->setName($name);
            $lineItem1->setDescription($desc);
            $lineItem1->setQuantity($qty);
            $lineItem1->setUnitPrice($unit_price);
            $lineItem1->setTaxable(0); // 1 Yes 0 for no
            $this->lineItems_ary[$this->liinc++] = $lineItem1;
      }

Upvotes: 0

Views: 122

Answers (1)

shmeeps
shmeeps

Reputation: 7833

For anyone finding this through Google, in my case the error is caused by using a url or cancelUrl parameter value in hostedPaymentReturnOptions that contains an ampersand. For some reason this works when requesting a form token, but not when actually loading the form with the given token.

More information on the underlying issue here.

Upvotes: 0

Related Questions