Professional Documents
Culture Documents
Adding A Payment Processor Via An Add-On: The Fields of The Payment - Processors
Adding A Payment Processor Via An Add-On: The Fields of The Payment - Processors
User Guide
Add-on
A payment processor is a group of several PHP and TPL "les and an entry in the payment_processors
Upgrade CS-Cart
table.
Developer Guide
Getting Started
Core
Hook Database
Add-on Development
The Fields of the payment_processors Table
Hooking processor (string)—the name of the payment processor. It is the same for all languages, so it’s better to
Tutorials "ll in this "eld in English or at least use the letters of the Latin alphabet.
Hello World
processor_script (string)—the name of the PHP "le that contains the logic of the payment processor.
Add-on Tutorial
Specify only the name of the "le here, for example, foo_bar.php. Don’t put directories or any other
Advanced Add-
symbols here.
on Tutorial
Adding a By default, that "le will be loaded from app/payments. If the payment processor is added by an add-on
Payment and the addon "eld in the payment_processors table is "lled in correctly, the "le will be loaded from
Processor via app/addons/{$addon_name}/payments.
an Add-on
processor_template (string)—the relative path without the "rst slash to the TPL "le of the template that
How To: Create
appears to a customer who places an order. The path must be relative to
Custom
design/themes/{$theme_name}/templates. For example: views/orders/components/payments/cc.tpl.
Templates for
Product List and If the processor was added by an add-on and requires a custom template, you can specify the path to
Product Detail the template from the add-on’s template folder.
Page
For example, this is the template path for the PayPal add-on:
Developing an
addons/paypal/views/orders/components/payments/paypal_express.tpl.
Add-on in a Git
Repository The responsive theme includes several standard templates. You can use them by specifying them in the
Using the processor_template "eld. As an alternative, you can use those templates as a base for your own
Marketplace custom template added by an add-on. The templates of the responsive theme are stored in
Add-on design/themes/responsive/templates/views/orders/components/payments.
Management
admin_template (string)—the name of the TPL "le of the template that appears when creating and
Processes
editing the payment method on a separate tab. This template may include "elds and forms where
Add-on Scheme
administrators specify payment processor properties, such as access tokens, etc.
Extending API
Add-on Directories Enter the name of the TPL "le without any directories and other symbols. It should look like
Language foo_processor_template.tpl. By default, this "le will be loaded from
Variables in Add- design/backend/templates/views/payments/components/cc_processors.
ons
If the processor was added by an addon, and the addon "eld in the payment_processors table is "lled
Adapting Add-ons
in correctly, the "le will be loaded from
to the Responsive
design/backend/templates/addons/{$addon_name}/views/payments/components/cc_processors;
Theme
{$addon_name} stands for the name of the addon.
How to Adapt an
Add-on to Work callback (ENUM(‘Y’,’N’))—determines how the payment step of the order placement will work:
with Responsive
Y—the processor will send the request to the processing server without redirecting the customer to
Admin Panel
that server. For example, this can be done via cURL.
Extending a
Scheme
FAQ: How to O!er PayPal Pro and Authorize.Net processors work that way.
Upgrades for My
Add-on via N—the customer who places an order will be redirected to the processing server to make the
Upgrade Center payment.
Version
Compatibility
That’s how DPS PX Access and Player processors work.
Developer Tools
REST API
type (ENUM(‘P’,’C’,’B’))—determines where exactly the template speci"ed in the processor_template
Designer Guide "eld will appear.
Version History P (Payment gateway)—the template will appear in the Billing Options section at checkout.
Edit on GitHub
<?php
Report a problem // app/addons/sample_payment/payments/sample_payment_processor.php
// Preventing direct access to the script, because it must be included by the "include"
directive. The "BOOTSTRAP" constant is declared during system initialization.
defined('BOOTSTRAP') or die
die('Access denied');
Checking the data entered by the customer when placing the order.
For example, checking the expiration date of the credit card speci"ed by the customer.
Changing the order status to Failed if the data doesn’t pass a check.
Gathering and preparing the data to be passed to the server of the third-party payment system.
Acquiring various one-use tokens and access keys from the payment systems.
Generating the URL where the customer will be taken after he/she performs the necessary actions at
the payment service website.
Redirecting the customer to the payment system website so that he/she can provide additional data or
con"rm the payment.
Let’s study the processes that take place before and after the payment processor script is run:
The customer chooses the payment method and clicks the Submit my order button. Doing that sends a
POST request to index.php?dispatch=checkout.place_order .
Apart from other arguments, this function accepts the $_REQUEST array. If the function "nds an
element with the payment_info key in that array ( $_REQUEST['payment_info'] ), it copies the value
of that element to the $cart array with the same key— $cart['payment_info'] .
This allows the processor script to work with the data entered by the customer when he/she chooses
the payment method. For example, the credit card number is one of the kinds of that data. You can
declare such "elds in the processor_template template.
After that the function performs various checks required before creating the order. Then the function
creates the order itself, which has the Incomplete status. This status is referred to by its letter code N
in the database.
The logic of the payment process initiation begins with calling the fn_start_payment() function.
When this function is run, important variables are declared. These variables can later be used in the
payment processor script:
Then the processor script is included and executed via the include directive.
The script must have the $pp_response variable declared. This variable is later used in the
fn_start_payment() function and passed to the fn_finish_payment() function call.
There is the payment_noti!cation controller (with callback = "N" ) for accepting requests like these.
This controller expects two mandatory GET parameters:
The value of this parameter will be available in the processor script in the $mode variable. The values
can be something like success, error, redirect, etc.
payment (string)—the name of the "le with the processor script to be executed.
The name shouldn’t include the .php extension. For example, it can be sample_payment_processor.
This provides a way to discern this context from the other context in the processor script by logical
branching.
A check is performed to verify whether the payment method that uses the payment processor passed in
the GET parameter is active.
<?php
// Preventing direct access to the script, because it must be included by the "include"
directive.
defined('BOOTSTRAP') or die
die('Access denied');
<?php
// Preventing direct access to the script, because it must be included by the "include"
directive.
defined('BOOTSTRAP') or die
die('Access denied');
} else {
fn_print_r("Sending data");
Now if you choose the payment method that uses this processor and click Submit my order at checkout,
you’ll get a message “Sending data”, followed by “Processing the answer”.
You can use the code of any payment processor in app/payments as an example.
For example, if the value of processor_script is foo_bar_processor.php, the name of the language variable
will be processor_description_foo_bar_processor.
When this language variable with the payment processor description is added to the language_values
table, the description of the foo_bar_processor will appear in the Administration panel.
To work in iframe mode, a payment processor must have a setting called iframe_mode with the value set
to Y . Here’s an example for the method that works only in the iframe mode:
<input
type="hidden"
name="payment_data[processor_params][iframe_mode]"
value="Y"
/>
When the customer selects an iframe payment method at the Billing Options step at checkout, the Submit
my order button won’t show up. That’s why the processors in the checkout.post.php controllers won’t be
executed. For example, the customer won’t be able to subscribe for newsletters at checkout.
Because the order is not yet created, the order nonce serves to identify the order instead of order_id .
The order nonce is created from the TIME constant and user_id .
The payment gateway in the iframe is loaded via the process_payment mode of the checkout.php
controller, where the processor script is included via the include directive.
The processor script sends all the necessary information to the payment gateway, including the order
nonce and the session identi"er.
Once the payment noti"cation from the gateway is received, the order is placed, and the information about
the order is retrieved from the session.
Here are the entries added to the order_data table when payment_notification is received:
E Order nonce
Have any questions that weren't answered here? Need help with solving a problem in your online
store? Want to report a bug in our software? Find out how to contact us.