HOW TO: Integrate Hosted Checkout with Zen Cart

Terminology

installation root:

the file system directory where Zen Cart is installed, e.g. /var/www/html/zencart

base URL:

the URL to reach the installed Zen Cart, e.g. http://mydomain.com/zencart/

checkout process URL:

the URL for the Zen Cart handler that processes the transaction results for a payment.
on an unmodified Zen Cart installation this will be [base URL]/index.php?main_page=checkout_process

Steps

  1. Download the customized authorizenet.php.{version} file at the bottom of this article that corresponds to your Zen Cart version (1.3.8a or 1.3.9d)
  2. Replace [installation root]/includes/modules/payment/authorizenet.php with the one downloaded in Step 1 (IMPORTANT NOTE: do not leave duplicate or renamed copies of this file in this directory)
  3. Log in to your ZenCart administration panel
  4. Click on Modules → Payment
  5. Select Authorize.net (SIM) (install it if it's not already installed)
  6. Configure as in the screenshot below
  7. Press update to complete the configuration

zencart_integration.png

By default the customized authorizenet.php script is set to behave exactly the same as the original one, meaning payments are sent to Authorize.Net. To use E-xact's Hosted Checkout service, edit authorizenet.php to set the $exact_mode variable as described in the Receipting Options section.

Receipting Options

There is no Silent Post handler in the Zen Cart source code, so a customized one would be needed to use this feature.

Do not set Silent Post URL to the checkout process URL, it could result in a non-receipt being displayed at the end of a payment. If there are multiple connections for the same payment session sending transaction result data to the checkout process URL, the first will be processed and redirect to the proper receipt page while the subsequent one(s) will not as the payment session has been completed by that first connection. Since the order of when the data from Silent Post/Receipt Link/Relay Response/REDI reaches the checkout process handler is not guaranteed, it is possible for the Silent Post connection to get the proper receipt page while the user is redirected to the default main page or a session expired page.

The data that is returned to Zen Cart from E-xact is used to display and email customer receipts, as well as to update its own database. Additional actions may be performed as well depending on the configuration of Zen Cart.

Default Hosted Receipt

Shopping Cart

Using a text editor open the [installation root]/includes/modules/payment/authorizenet.php file.

Find this line:

var $exact_mode;

Change it to:

var $exact_mode = self::hosted;

payment request will include:

  • x_receipt_link_url set to checkout process URL
  • x_receipt_link_method set to POST

sample of the sent payment request parameters:

version 1.3.8a

x_login = WSP-E-XAC-8-47
x_amount = 32.49
x_version = 3.0
x_method = CC
x_type = auth_capture
x_cust_ID = 2
x_email_customer = TRUE
x_company =
x_first_name = Jane
x_last_name = Zencart
x_address = 1234 First St
x_city = Vancouver
x_state = British Columbia
x_zip = V3X 7R8
x_country = Canada
x_phone = (604) 123 1233
x_fax =
x_email = llin@e-xact.com
x_ship_to_company =
x_ship_to_first_name = Jane
x_ship_to_last_name = Zencart
x_ship_to_address = 1234 First St
x_ship_to_city = Vancouver
x_ship_to_state = British Columbia
x_ship_to_zip = V3X 7R8
x_ship_to_country = Canada
x_Customer_IP = 10.70.20.106
x_relay_form = TRUE
x_invoice_num =
x_description = Website Purchase from Zen Cart Test
x_duplicate_window = 120
x_fp_sequence = 578
x_fp_timestamp = 1271353448
x_fp_hash = b3c0e8402228fb6e6cdbf4957a1ee757
x_show_form = PAYMENT_FORM
x_receipt_link_method = POST
x_receipt_link_text = Click here to complete your order.
x_receipt_link_url = http://mydomain.com/zencart/index.php?main_page=checkout_process
x_Test_Request = TRUE
zenid = o9pfgch349otvnuc722gu627o5

version 1.3.9d

x_login = WSP-E-XAC-80-765
x_amount = 25.00
x_version = 3.1
x_method = CC
x_type = AUTH_ONLY
x_cust_ID = 2
x_email_customer = FALSE
x_company =
x_first_name = Jane
x_last_name = Zencart
x_address = 1234 Maple Drive
x_city = Vancouver
x_state = British Columbia
x_zip = V5N C3D
x_country = Canada
x_phone = 16041231234
x_fax =
x_email = llin@e-xact.com
x_ship_to_company =
x_ship_to_first_name = Jane
x_ship_to_last_name = Zencart
x_ship_to_address = 1234 Maple Drive
x_ship_to_city = Vancouver
x_ship_to_state = British Columbia
x_ship_to_zip = V5N C3D
x_ship_to_country = Canada
x_Customer_IP = 10.70.20.50
x_relay_response = TRUE
x_invoice_num =
x_duplicate_window = 120
x_allow_partial_Auth = FALSE
x_description = Website Purchase from Zen Cart Test 139d
x_fp_sequence = 239
x_fp_timestamp = 1277425023
x_fp_hash = 4e520a8595ffc644f3cc913e015c1f4b
x_show_form = PAYMENT_FORM
x_receipt_link_method = POST
x_receipt_link_text = Click here to complete your order.
x_receipt_link_url = http://mydomain.com/zencart/index.php?main_page=checkout_process
x_Test_Request = TRUE
zenid = s5bu4af6bnkrrplt2778rdui54

Payment Page

uncheck Allow Relay Response

Relay Response

The option Pass HTTP Redirects to the Customer's Browser can be enabled, since Zen Cart's checkout process handler does return a redirect (HTTP Status 302) to the destination page. The destination page would be [base URL]/index.php?main_page=checkout_success for a successful payment, or [base URL]/index.php?main_page=checkout_payment for a failed payment.

Shopping Cart

Using a text editor open the [installation root]/includes/modules/payment/authorizenet.php file.

Find this line:

var $exact_mode;

Change it to:

var $exact_mode = self::relay;

payment request will include:

  • x_relay_url set to checkout process URL

sample of the sent payment request parameters:

version 1.3.8a

x_login = WSP-E-XAC-8-47
x_amount = 57.49
x_version = 3.0
x_method = CC
x_type = auth_capture
x_cust_ID = 2
x_email_customer = TRUE
x_company =
x_first_name = Jane
x_last_name = Zencart
x_address = 1234 First St
x_city = Vancouver
x_state = British Columbia
x_zip = V3X 7R8
x_country = Canada
x_phone = (604) 123 1233
x_fax =
x_email = llin@e-xact.com
x_ship_to_company =
x_ship_to_first_name = Jane
x_ship_to_last_name = Zencart
x_ship_to_address = 1234 First St
x_ship_to_city = Vancouver
x_ship_to_state = British Columbia
x_ship_to_zip = V3X 7R8
x_ship_to_country = Canada
x_Customer_IP = 10.70.20.106
x_relay_form = TRUE
x_relay_URL = http://mydomain.com/zencart/index.php?main_page=checkout_process
x_invoice_num =
x_description = Website Purchase from Zen Cart Test
x_duplicate_window = 120
x_fp_sequence = 210
x_fp_timestamp = 1271354206
x_fp_hash = d9f697d58a6cb7e22ea2c8d7d571bc1e
x_show_form = PAYMENT_FORM
x_receipt_link_method = POST
x_receipt_link_text = Click here to complete your order.
x_receipt_link_url = http://mydomain.com/zencart/index.php?main_page=checkout_process
x_Test_Request = TRUE
zenid = o9pfgch349otvnuc722gu627o5

version 1.3.9d

x_login = WSP-E-XAC-80-765
x_amount = 32.50
x_version = 3.1
x_method = CC
x_type = AUTH_ONLY
x_cust_ID = 2
x_email_customer = FALSE
x_company =
x_first_name = Jane
x_last_name = Zencart
x_address = 1234 Maple Drive
x_city = Vancouver
x_state = British Columbia
x_zip = V5N C3D
x_country = Canada
x_phone = 16041231234
x_fax =
x_email = llin@e-xact.com
x_ship_to_company =
x_ship_to_first_name = Jane
x_ship_to_last_name = Zencart
x_ship_to_address = 1234 Maple Drive
x_ship_to_city = Vancouver
x_ship_to_state = British Columbia
x_ship_to_zip = V5N C3D
x_ship_to_country = Canada
x_Customer_IP = 10.70.20.50
x_relay_response = TRUE
x_relay_URL = http://mydomain.com/zencart/index.php?main_page=checkout_process
x_invoice_num =
x_duplicate_window = 120
x_allow_partial_Auth = FALSE
x_description = Website Purchase from Zen Cart Test 139d
x_fp_sequence = 421
x_fp_timestamp = 1277422325
x_fp_hash = 2813a3cbcdac02b7a2416e482059129b
x_show_form = PAYMENT_FORM
x_receipt_link_method = POST
x_receipt_link_text = Click here to complete your order.
x_receipt_link_url = http://mydomain.com/zencart/index.php?main_page=checkout_process
x_Test_Request = TRUE
zenid = l3n0iqq5mle8ogu09ltugsv637

Payment Page

check Allow Relay Response

set Relay Response URL to the checkout process URL

REDI

Shopping Cart

Using a text editor open the [installation root]/includes/modules/payment/authorizenet.php file.

Find this line:

var $exact_mode;

Change it to:

var $exact_mode = self::redir;

payment request will include:

  • x_receipt_link_url set to checkout process URL
  • x_receipt_link_method set to REDI

sample of the sent payment request parameters:

version 1.3.8a

x_login = WSP-E-XAC-8-47
x_amount = 32.50
x_version = 3.0
x_method = CC
x_type = auth_capture
x_cust_ID = 2
x_email_customer = TRUE
x_company =
x_first_name = Jane
x_last_name = Zencart
x_address = 1234 First St
x_city = Vancouver
x_state = British Columbia
x_zip = V3X 7R8
x_country = Canada
x_phone = (604) 123 1233
x_fax =
x_email = llin@e-xact.com
x_ship_to_company =
x_ship_to_first_name = Jane
x_ship_to_last_name = Zencart
x_ship_to_address = 1234 First St
x_ship_to_city = Vancouver
x_ship_to_state = British Columbia
x_ship_to_zip = V3X 7R8
x_ship_to_country = Canada
x_Customer_IP = 10.70.20.106
x_relay_form = TRUE
x_invoice_num =
x_description = Website Purchase from Zen Cart Test
x_duplicate_window = 120
x_fp_sequence = 978
x_fp_timestamp = 1271354677
x_fp_hash = ee569d037cb7a986dfbafbab81768a5b
x_show_form = PAYMENT_FORM
x_receipt_link_method = REDI
x_receipt_link_text = Click here to complete your order.
x_receipt_link_url = http://mydomain.com/zencart/index.php?main_page=checkout_process
x_Test_Request = TRUE
zenid = o9pfgch349otvnuc722gu627o5

 

version 1.3.9d

x_login = WSP-E-XAC-80-765
x_amount = 89.99
x_version = 3.1
x_method = CC
x_type = AUTH_ONLY
x_cust_ID = 2
x_email_customer = FALSE
x_company =
x_first_name = Jane
x_last_name = Zencart
x_address = 1234 Maple Drive
x_city = Vancouver
x_state = British Columbia
x_zip = V5N C3D
x_country = Canada
x_phone = 16041231234
x_fax =
x_email = llin@e-xact.com
x_ship_to_company =
x_ship_to_first_name =
x_ship_to_last_name =
x_ship_to_address =
x_ship_to_city =
x_ship_to_state =
x_ship_to_zip =
x_ship_to_country =
x_Customer_IP = 10.70.20.50
x_relay_response = TRUE
x_invoice_num =
x_duplicate_window = 120
x_allow_partial_Auth = FALSE
x_description = Website Purchase from Zen Cart Test 139d
x_fp_sequence = 913
x_fp_timestamp = 1277424959
x_fp_hash = e89c92d341e329c767d30bfd868f8234
x_show_form = PAYMENT_FORM
x_receipt_link_method = REDI
x_receipt_link_text = Click here to complete your order.
x_receipt_link_url = http://mydomain.com/zencart/index.php?main_page=checkout_process
x_Test_Request = TRUE
zenid = s5bu4af6bnkrrplt2778rdui54

Payment Page

uncheck Allow Relay Response

set Maximum Number of Payment Attempts to 1 (recommended)

Downloads

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk