Creating A New Payment Gateway

[color=#000000]I am implementing a new Payment Gateway on CS-Cart. Using the instructions in [/color][url=“CS-Cart Documentation — CS-Cart 4.15.x documentation”]CS-Cart Documentation — CS-Cart 4.15.x documentation I have been able to create a payment script and also create a template file in the administrator skin where the payment method was configured and also updated the MySQL cscart_payment_processors table. [/color]

[color=#000000]Template file - /design/backend/templates/views/payments/components/cc_processors/fcmbpay.tpl[/color]

[color=#000000]Processor script - /app/payments/fcmbpay.php[/color]

[color=#000000]The application is not connecting to the FCMB Payment Gateway, it is returning an error - find attached the snapshot of the error.[/color]

[color=#000000]We are sending the following parameters (Merchant ID, Currency code, Amount, Order ID, Product, Email) and the processor script is- [/color]

[color=#000000][font=monospace, monospace]
[color=#000000][font=monospace, monospace]/[/font][/color]

[color=#000000][font=monospace, monospace]

[color=#000000][font=monospace, monospace]
(c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev [/font][/color]

[color=#000000][font=monospace, monospace]

[color=#000000][font=monospace, monospace]
This is commercial software, only users who have purchased a valid [/font][/color]

[color=#000000][font=monospace, monospace]
license and accept to the terms of the License Agreement can install [/font][/color]

[color=#000000][font=monospace, monospace]
and use this program. [/font][/color]

[color=#000000][font=monospace, monospace]

[color=#000000][font=monospace, monospace]

[color=#000000][font=monospace, monospace]

[color=#000000][font=monospace, monospace]

[color=#000000][font=monospace, monospace]

[color=#000000][font=monospace, monospace]if (!defined('BOOTSTRAP')) { die('Access denied'); }[/font][/color]

[color=#000000][font=monospace, monospace]if (defined('PAYMENT_NOTIFICATION')) {[/font][/color]

[color=#000000][font=monospace, monospace]if ($mode == 'process') {[/font][/color]

[color=#000000][font=monospace, monospace]//$pp_response[“order_status”] = (($_REQUEST['Result'] == “1”) ? 'P' : 'F');[/font][/color]

[color=#000000][font=monospace, monospace]$pp_response[“order_status”] = (($_REQUEST['statuscode'] == “00”) ? 'P' : 'F');[/font][/color]

[color=#000000][font=monospace, monospace]//if ($_REQUEST['Result'] == 2) {[/font][/color]

[color=#000000][font=monospace, monospace]if ($_REQUEST['statuscode'] == 03) {[/font][/color]

[color=#000000][font=monospace, monospace]$pp_response[“order_status”] = 'I';[/font][/color]

[color=#000000][font=monospace, monospace]//$pp_response[“reason_text”] = “Error”;[/font][/color]

[color=#000000][font=monospace, monospace]$pp_response[“reason_text”] = “Cancelled”;[/font][/color]

[color=#000000][font=monospace, monospace]} elseif ($_REQUEST['statuscode'] != 00) {[/font][/color]

[color=#000000][font=monospace, monospace]$pp_response[“reason_text”] = “Error”;[/font][/color]

[color=#000000][font=monospace, monospace]}[/font][/color]

[color=#000000][font=monospace, monospace]//} elseif ($_REQUEST['Result'] == 3) {[/font][/color]

[color=#000000][font=monospace, monospace]//$pp_response[“order_status”] = 'I';[/font][/color]

[color=#000000][font=monospace, monospace]//$pp_response[“reason_text”] = “Cancelled”;[/font][/color]

[color=#000000][font=monospace, monospace]//}[/font][/color]

[color=#000000][font=monospace, monospace]if (isset($_REQUEST['ErrorMessage'])) {[/font][/color]

[color=#000000][font=monospace, monospace]$pp_response[“reason_text”].= ": " . $_REQUEST['ErrorMessage'];[/font][/color]

[color=#000000][font=monospace, monospace]}[/font][/color]

[color=#000000][font=monospace, monospace]if (isset($_REQUEST['TransactionReference'])) {[/font][/color]

[color=#000000][font=monospace, monospace]$pp_response[“transaction_id”] = $_REQUEST['TransactionReference'];[/font][/color]

[color=#000000][font=monospace, monospace]}[/font][/color]

[color=#000000][font=monospace, monospace]$order_id = (strpos($REQUEST['Param1'], '')) ? substr($_REQUEST['Param1'], 0, strpos($REQUEST['Param1'], '')) : $_REQUEST['Param1'];[/font][/color]

[color=#000000][font=monospace, monospace]if (fn_check_payment_script('fcmbpay.php', $order_id)) {[/font][/color]

[color=#000000][font=monospace, monospace]fn_finish_payment($order_id, $pp_response, false);[/font][/color]

[color=#000000][font=monospace, monospace]fn_order_placement_routines('route', $order_id);[/font][/color]

[color=#000000][font=monospace, monospace]}[/font][/color]

[color=#000000][font=monospace, monospace]}[/font][/color]

[color=#000000][font=monospace, monospace]} else { //send payment to gateway[/font][/color]

[color=#000000][font=monospace, monospace]//$amount = str_replace('.', ',', $order_info[“total”]);[/font][/color]

[color=#000000][font=monospace, monospace]$amount = $order_info[“total”];[/font][/color]

[color=#000000][font=monospace, monospace]$order_id = ($order_info['repaid']) ? ($order_id . '' . $order_info['repaid']) : $order_id;[/font][/color]

//payment url it is submitting to

[color=#000000][font=monospace, monospace]$submit_url = '';[/font][/color]

[color=#000000][font=monospace, monospace]$post_data = array([/font][/color]

[color=#000000][font=monospace, monospace]'mercID' => $processor_data['processor_params']['merchant_id'],[/font][/color]

[color=#000000][font=monospace, monospace]'currCode' => $processor_data['processor_params']['currency'],[/font][/color]

[color=#000000][font=monospace, monospace]'amt' => $order_info['total'],[/font][/color]

[color=#000000][font=monospace, monospace]'order_ID' => $_order_id,[/font][/color]

[color=#000000][font=monospace, monospace]'prod' => $order_info['products'],[/font][/color]

[color=#000000][font=monospace, monospace]'email' => $order_info['email'][/font][/color]

[color=#000000][font=monospace, monospace]);[/font][/color]

[color=#000000][font=monospace, monospace]fn_create_payment_form($submit_url, $post_data, 'FCMB Pay server');[/font][/color]

[color=#000000][font=monospace, monospace]exit;[/font][/color]

[color=#000000][font=monospace, monospace]}[/font][/color]

[color=#000000]Please I would like you to look into the code and see what's wrong. I anticipate responses.[/color]

At first view, I can see that you are trying to post data to empty URL:

$submit_url = '';

Please contact fcmbpay support team and ask them to provide you with the correct URL

Hi eComLabs,

I have the URL, it is

Did you add it to the script? Do you see any changes? What CS-Cart version do you use?

Yes I did and it is not connecting to FCMB Payment Gateway, it keeps throwing an error : Improper Integration - Invalid Product

The CS-Cart version .s 4.2.4

It is required to examine their documentation in this case

I have examined their documentation but all seems fine when I hardcode values into a form I created in a PHP file(test.php) on my domain. When I open the page on my browser -, it sends the parameters of the form to the gateway -

But when I try to implement it on CS Cart, it keeps throwing the error: “Improper Integration - Invalid product”

Here is a sample script of the hardcoded form I sent to the payment gateway via

Looks like the issue in the “prod” parameter. Please add


before this line:

fn_create_payment_form($submit_url, $post_data, 'FCMB Pay server');

and make sure that all parameters are not empty

I added fn_print_die($post_data); before the line as instructed, while I opened the storefront to buy an item and I selected the FCMB payment option, an array of the transaction was printed on the web page


Apparently, what I really need is for prod parameter to pick only the Product name that will be sent to the payment gateway


  1. Array
    [mercID] => 00995
    [currCode] => 566
    [amt] => 23200.00
    [order_ID] => 111
    [prod] => Array
    [28185492] => Array
    [item_id] => 28185492
    [order_id] => 111
    [product_id] => 361
    [product_code] => EG 2619
    [price] => 23200.00
    [amount] => 1
    [extra] => Array
    [product_options] => Array

    [unlimited_download] => N
    [product] => NOKIA LUMIA 520
    [company_id] => 175
    [is_edp] => N
    [edp_shipping] => N
    [discount] => 0
    [base_price] => 23200
    [stored_price] => N

    [product] => NOKIA LUMIA 520
    [product_status] => A
    [deleted_product] =>
    [discount] => 0
    [company_id] => 175
    [base_price] => 23200
    [original_price] => 23200
    [cart_id] => 28185492
    [tax_value] => 1104.76
    [subtotal] => 23200
    [display_subtotal] => 23200
    [shipped_amount] => 0
    [shipment_amount] => 1
    [is_accessible] => 1


    [email] =>

Try this code:

$post_data = array(
'mercID' => $processor_data['processor_params']['merchant_id'],
'currCode' => $processor_data['processor_params']['currency'],
'amt' => $order_info['total'],
'order_ID' => $_order_id,
'prod' => '',
'email' => $order_info['email']
foreach ($order_info['products'] as $p) {
if (empty($post_data['prod'])) {
$post_data['prod'] = $p['product'];
} else {
$post_data['prod'] .= (',' . $p['product']);

Thanks eComLabs! It worked and the issue has been resolved, the payment processor script can now send the parameters to the payment integration environment.

Thank you once again!

We are glad to help you!

I have a little problem with the Return URL. The payment gateway is returning a Transaction reference and Order Id back to my store.

Does the success page - support arguments?

For example -

If the return URL can be generated dynamically, please use

If not, you should use:

If I use, will it update the Order table as Open and also send an Order invoice to the customer's email.

Yes, if you add a code which will parse their response correctly. Please use app\payments\dps_access.php file as example

It returned “Access Denied” on the web page while I used as the success return URL. Could you please help me out here because I am stuck on that.

Please check the example script. The following string should be moved:

if (!defined('BOOTSTRAP')) { die('Access denied'); }

Hi eComLabs,

I am a newbie to CS-Cart and I have really got my hands dirty this past few month while working on this project. I would like to know if there is something similar to the payment scripts already in CS-Cart in terms of parsing response sent from a payment gateway to update order status and send an invoice via email to the customer. I had already looked at the worldpay.php but the logic is a bit different to what I want to implement.

I would really appreciate steps that could guide me to implement it.

There is no universal solution as each payment gateway has its own way of integration and set of fields. If you are interested, our specialists can complete the integration for you on the paid basis. Feel free to contact me