Purchase with iCard mobile application

Include SDK loader

This will autoload necessary library files and classes

require_once './IPC/Loader.php';


Create Config object and set API configuration params

Note that IpcURL is different for sandbox and production environment

You can set RSA keys for request signatures by setting key content using setPrivateKey and setAPIPublicKey or by setting a file path using setPrivateKeyPath and setAPIPublicKeyPath

For more information please refer to IPCPurchaseByIcard method documentation.

$cnf = new \Mypos\IPC\Config(); 
$cnf->setPrivateKeyPath(dirname(__FILE__) . '/keys/store_private_key.pem'); 
$cnf->setAPIPublicKeyPath(dirname(__FILE__) . '/keys/api_public_key.pem'); 

Create Cart object and set cart items

$cart = new \Mypos\IPC\Cart; 
$cart->add('Some Book', 1, 9.99); //name, quantity, price 
$cart->add('Some other book', 1, 4.56); 
$cart->add('Discount', 1, -2.05);

Create PurchaseByIcard object using Config object and set required params

$purchase = new \Mypos\IPC\PurchaseByIcard($cnf); 
$purchase->setUrlCancel('http://mysite.com/ipc_cancel'); //User comes here after purchase cancelation 
$purchase->setUrlOk('http://mysite.com/ipc_ok'); //User comes here after purchase success 
$purchase->setUrlNotify('https://mysite.com/ipc_notify'); //IPC sends POST reuquest to this address with purchase status 
$purchase->setOrderID(uniqid()); //Some unique ID 

}catch(\Mypos\IPC\IPC_Exception $ex){ 
    echo $ex->getMessage(); 
    //Invalid params. To see details use "echo $ex->getMessage();"