Info !!! To get started, you need to download the latest version of our PHP client. Download
Warning !!! For your tests, connect instead to the test platform. Connection to the test platform
By registering on the test platform, your test account will be credited with 100,000 FCFA . This will allow you to easily complete the integration tests before going into production.
Once done, follow these steps :
- Decompress the file
.zip
- For customer integration, copy the file
pay-php-gateway
in the folder containing the source code of your application
Folder tree from the decompression
>pay-php-gateway : main folder
–>demo : folder containing a demo website for testing the PHP client
—->conf.php : configuration file. Contains all configuration parameters of the demo website
—->confirm.php : return file. Contains the code that allows the demo website to check the status of the transaction. It is also the page on which the customer is returned after validation of his payment.
—->index.php : home page of the demo website. This is also the page that displays the contents of the basket, so this is where the payment process is launched.
—->redirect_checkout.php : page that refers the customer to the payment validation page, once the payment process has started
–>pay : folder containing the PHP client. For the purposes of this tutorial, it is not important to dwell on the content of this file. However, you can take a look at it to better understand how the library works
–>LICENSE.txt : license file
–>pay-php-gateway.php : PHP client
>pay-php-gateway : main folder
–>demo : folder containing a demo website for testing the PHP client
—->conf.php : configuration file. Contains all configuration parameters of the demo website
—->confirm.php : return file. Contains the code that allows the demo website to check the status of the transaction. It is also the page on which the customer is returned after validation of his payment.
—->index.php : home page of the demo website. This is also the page that displays the contents of the basket, so this is where the payment process is launched.
—->redirect_checkout.php : page that refers the customer to the payment validation page, once the payment process has started
–>pay : folder containing the PHP client. For the purposes of this tutorial, it is not important to dwell on the content of this file. However, you can take a look at it to better understand how the library works
–>LICENSE.txt : license file
–>pay-php-gateway.php : PHP client
Payment page configuration
- Initialize the PHP client, by copying and pasting
require('path_to_php_client_folder/pay-php-gateway.php');
$setup = new Pay_Setup();
$setup->setApi_key("your master key generated during the creation of the application");
$setup->setMode("mode of use (either live or test)");
$setup->setToken("token generated when the application was created");
//Configuration of your store / service information
$store = new Pay_Checkout_Store();
$store->setName("name of your shop / application");
$store->setWebsiteUrl("url of your site");
$store->setCancelUrl("sale cancellation url");
$store->setCallbackUrl("return url after validation of payment");
$store->setReturnUrl("return url after validation of payment");
// Let $co be the variable containing the command
$co = new Pay_Checkout_Invoice($store, $setup);
- Suppose your customer has purchased two items. To add these two items in the order, do like this :
$co->addItem("Jean Gucci", 3, 150, 450, "Jean bleu, de marque Gucci");
$co->addItem("Jean Prada", 2, 100, 200, "Jean noir, de marque Prada");
- To add the total and the description of the invoice, do like this :
$co->setTotalAmount($total_amount);
$co->setDescription("Purchase of two items on the Jeans Missebo site");
- To start the payment process, do like this :
// start of the payment process
// sending the request
if($co->create()) {
// Request accepted, then we redirect the customer to the payment validation page
header("Location: ".$co->getInvoiceUrl());
}else{
// Request refused, then we display the reason for rejection
echo $co->response_text;
}
Function prototype
addItem(array(name, quantity, unit_price, total_price, description)) où :
name : item name
quantity : item quantity
unit_price : unit price of the item
total_price : total price of the item
description : description of the item purchased or other item details
addItem()
addItem(array(name, quantity, unit_price, total_price, description)) où :
name : item name
quantity : item quantity
unit_price : unit price of the item
total_price : total price of the item
description : description of the item purchased or other item details
Configuration of the payment verification page (return_url page)
- Initialize the PHP client, by copying and pasting
require('path_to_php_client_folder/pay-php-gateway.php');
$setup = new Pay_Setup();
$setup->setApi_key("your master key generated during the creation of the application");
$setup->setMode("mode in which");
$setup->setToken("token generated when the application was created");
//Configuration of your store / service information
$store = new Pay_Checkout_Store();
$store->setName("name of your shop / application");
$store->setWebsiteUrl("url of your site");
$store->setCancelUrl("sale cancellation url");
$store->setCallbackUrl("return url after validation of payment cancellation of sale");
$store->setReturnUrl("return url after validation of payment");
// Let $co be the variable containing the command
$co = new Pay_Checkout_Invoice($store, $setup);
- To check the payment status, do like this :
// The confirm method returns true or false depending on the payment status
// So you can use an if - else statement and manage the result as you see fit
if ($co->confirm()) {
// successful transaction
}else{
//failed transaction
}