IPSP PHP
Share links
Flexible software development kit that covers e-commerce for businesses of all types and support popular CMS modules for fast integration in existing infrastructure.
Installation
System Requirements
PHP 7.1 and later.
Dependencies
SDK require the following extension in order to work properly:
Composer
If you’re using Composer, you can run the following command:
composer require kosatyi/ipsp-php
Or add dependency manually in composer.json
{
"require": {
"ipsp-php/ipsp-php":"dev-master"
}
}
Quick Start
Import library to your project file.
<?php
// If you are install SDK with composer
require_once 'vendor/autoload.php';
Define constants in project file or import from custom location.
<?php
define('IPSP_PHP_ID' , 'your_merchant_id');
define('IPSP_PHP_PASSWORD' , 'password');
define('IPSP_GATEWAY' , 'your_ipsp_gateway');
Create IpspPhp\Client
instance by passing configuration properties:
IPSP_PHP_ID
- Checkout Merchant ID from provider admin panel.IPSP_PHP_PASSWORD
- Merchant passwordIPSP_PHP_GATEWAY
- Choose provider gateway.
<?php
$client = new IpspPhp\Client( IPSP_PHP_ID , IPSP_PHP_PASSWORD, IPSP_PHP_GATEWAY );
Create IpspPhp\Api
instance by passing IpspPhp\Client
instance:
<?php
$ipsp = new IpspPhp\Api( $client );
Finally create bootstrap file init.php
with content below:
<?php
require_once 'vendor/autoload.php';
define('IPSP_PHP_ID' , 'YOUR_MERCHANT_ID');
define('IPSP_PHP_PASSWORD' , 'PAYMENT_KEY' );
define('IPSP_PHP_GATEWAY' , 'api.fondy.eu');
$client = new IpspPhp\Client( IPSP_PHP_ID , IPSP_PHP_PASSWORD, IPSP_PHP_GATEWAY );
$ipsp = new IpspPhp\Api( $client );
Basic Usage Example
<?php
require_once('path/to/init.php');
$checkout = new IpspPhp\Resource\Checkout();
$data = $ipsp->call($checkout,[
'order_id' => 'orderid-111222333',
'order_desc' => 'Simple checkout page',
'currency' => $ipsp::USD ,
'amount' => 2000, // 20 USD
'response_url'=> sprintf('http://shop.example.com/result.php')
])->getResponse();
// redirect to checkout page
$data->redirectToCheckout();
Handling response
Create page result.php
with code below:
<?php
require_once('path/to/init.php');
$result = new IpspPhp\Resource\Result();
$response = $api->call($result);
if( $response->validResponse() ){
exit(sprintf('<pre>%s</pre>',$result->getResponse()));
}
Follow project
Author
Stepan Kosatyi, stepan@kosatyi.com