for Developers
These examples are created to experiment with the
myPOS Virtual Checkout API capabilities.
require_once './IPC/Loader.php';
$cnf = new \Mypos\IPC\Config();
$cnf->setIpcURL('https://mypos.eu/vmp/checkout-test/');
$cnf->setLang('en');
$cnf->setPrivateKeyPath(dirname(__FILE__) . '/keys/store_private_key.pem');
$cnf->setAPIPublicKeyPath(dirname(__FILE__) . '/keys/api_public_key.pem');
$cnf->setKeyIndex(1);
$cnf->setSid('000000000000010');
$cnf->setVersion('1.3');
$cnf->setWallet('61938166610');
$customer = new \Mypos\IPC\Customer();
$customer->setFirstName('John');
$customer->setLastName('Smith');
$customer->setEmail('demo@demo.demo');
$customer->setPhone('+359111111111');
$customer->setCountry('BGR');
$customer->setAddress('Business Park Varna');
$customer->setCity('Varna');
$customer->setZip('9000');
$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);
$purchase = new \Mypos\IPC\Purchase($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
$purchase->setCurrency('EUR');
$purchase->setNote('Some note'); //Not required
$purchase->setCustomer($customer);
$purchase->setCart($cart);
$purchase->setCardTokenRequest(\Mypos\IPC\Purchase::CARD_TOKEN_REQUSET_PAY_AND_STORE);
$purchase->setPaymentParametersRequired(\Mypos\IPC\Purchase::PURCHASE_TYPE_FULL);
try{
$purchase->process();
}catch(\Mypos\IPC\IPC_Exception $ex){
echo $ex->getMessage();
//Invalid params. To see details use "echo $ex->getMessage();"
}
require_once './IPC/Loader.php';
$cnf = new \Mypos\IPC\Config();
$cnf->setIpcURL('https://mypos.eu/vmp/checkout-test/');
$cnf->setLang('en');
$cnf->setPrivateKeyPath(dirname(__FILE__) . '/keys/store_private_key.pem');
$cnf->setAPIPublicKeyPath(dirname(__FILE__) . '/keys/api_public_key.pem');
$cnf->setKeyIndex(1);
$cnf->setSid('000000000000010');
$cnf->setVersion('1.3');
$cnf->setWallet('61938166610');
$purchase = new \Mypos\IPC\Purchase($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
$purchase->setCurrency('EUR');
$purchase->setNote('Some note'); //Not required
$purchase->setCardTokenRequest(\Mypos\IPC\Purchase::CARD_TOKEN_REQUSET_ONLY_STORE);
$purchase->setPaymentParametersRequired(\Mypos\IPC\Purchase::PURCHASE_TYPE_SIMPLIFIED_PAYMENT_PAGE);
try{
$purchase->process();
}catch(\Mypos\IPC\IPC_Exception $ex){
echo $ex->getMessage();
//Invalid params. To see details use "echo $ex->getMessage();"
}
require_once './IPC/Loader.php';
$cnf = new \Mypos\IPC\Config();
$cnf->setIpcURL('https://mypos.eu/vmp/checkout/');
$cnf->setLang('en');
$cnf->setPrivateKeyPath(dirname(__FILE__) . '/keys/store_private_key.pem');
$cnf->setAPIPublicKeyPath(dirname(__FILE__) . '/keys/api_public_key.pem');
$cnf->setEncryptPublicKeyPath(dirname(__FILE__) . '/keys/encrypt_key.pem');
$cnf->setKeyIndex(1);
$cnf->setSid('000000000000010');
$cnf->setVersion('1.3');
$cnf->setWallet('61938166610');
$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);
$card = new \Mypos\IPC\Card();
$card->setCardType(\Mypos\IPC\Card::CARD_TYPE_MASTERCARD);
$card->setCardNumber('5555555555554444');
$card->setExpMM('12');
$card->setExpYY('21');
$card->setCvc('111');
$card->setCardHolder('John Doe');
$card->setEci(6);
$card->setAvv('');
$card->setXid('');
$purchase = new \Mypos\IPC\IAPurchase($cnf);
$purchase->setOrderID(uniqid()); //Some unique ID
$purchase->setCurrency('EUR');
$purchase->setNote('Some note'); //Not required
$purchase->setCard($card);
$purchase->setAccountSettlement('11111111119');//Not required
$purchase->setCart($cart);
$purchase->setOutputFormat(Mypos\IPC\Defines::COMMUNICATION_FORMAT_JSON);
$result = $purchase->process();
if ($result->getStatus() == \Mypos\IPC\Defines::STATUS_SUCCESS) {
echo 'success';
//success
} else {
//Show error.
}
require_once './IPC/Loader.php';
$cnf = new \Mypos\IPC\Config();
$cnf->setIpcURL('https://mypos.eu/vmp/checkout/');
$cnf->setLang('en');
$cnf->setPrivateKeyPath(dirname(__FILE__) . '/keys/store_private_key.pem');
$cnf->setAPIPublicKeyPath(dirname(__FILE__) . '/keys/api_public_key.pem');
$cnf->setEncryptPublicKeyPath(dirname(__FILE__) . '/keys/encrypt_key.pem');
$cnf->setKeyIndex(1);
$cnf->setSid('000000000000010');
$cnf->setVersion('1.3');
$cnf->setWallet('61938166610');
$card = new \Mypos\IPC\Card();
$card->setCardType(\Mypos\IPC\Card::CARD_TYPE_MASTERCARD);
$card->setCardNumber('5555555555554444');
$card->setExpMM('12');
$card->setExpYY('21');
$card->setCvc('111');
$card->setCardHolder('John Doe');
$card->setEci(6);
$card->setAvv('');
$card->setXid('');
$store = new \Mypos\IPC\IAStoreCard($cnf);
$store->setCardVerification(\Mypos\IPC\IAStoreCard::CARD_VERIFICATION_YES);
$store->setAmount(1.00);
$store->setCurrency('EUR');
$store->setCard($card);
$store->setOutputFormat(Mypos\IPC\Defines::COMMUNICATION_FORMAT_JSON);
$result = $store->process();
if ($result->getStatus() == \Mypos\IPC\Defines::STATUS_SUCCESS) {
//success
echo $result->getData(CASE_LOWER)['cardtoken'];
} else {
//Show error.
}
require_once './IPC/Loader.php';
$cnf = new \Mypos\IPC\Config();
$cnf->setIpcURL('https://mypos.eu/vmp/checkout/');
$cnf->setLang('en');
$cnf->setPrivateKeyPath(dirname(__FILE__) . '/keys/store_private_key.pem');
$cnf->setAPIPublicKeyPath(dirname(__FILE__) . '/keys/api_public_key.pem');
$cnf->setEncryptPublicKeyPath(dirname(__FILE__) . '/keys/encrypt_key.pem');
$cnf->setKeyIndex(1);
$cnf->setSid('000000000000010');
$cnf->setVersion('1.3');
$cnf->setWallet('61938166610');
$card = new \Mypos\IPC\Card();
$card->setCardToken('1041333312721BC752C1AB7743D0821AA1C9CA09');
$card->setCardHolder('John Doe');
$card->setCardType(\Mypos\IPC\Card::CARD_TYPE_MASTERCARD);
$card->setExpMM('12');
$card->setExpYY('21');
$card->setCvc('111');
$card->setEci(6);
$card->setAvv('');
$card->setXid('');
$store = new \Mypos\IPC\IAStoredCardUpdate($cnf);
$store->setCardVerification(\Mypos\IPC\IAStoreCard::CARD_VERIFICATION_YES);
$store->setAmount(1.00);
$store->setCurrency('EUR');
$store->setCard($card);
$store->setOutputFormat(Mypos\IPC\Defines::COMMUNICATION_FORMAT_JSON);
$result = $store->process();
if ($result->getStatus() == \Mypos\IPC\Defines::STATUS_SUCCESS) {
//success
echo $result->getData(CASE_LOWER)['cardtoken'];
} else {
//Show error.
}
require_once './IPC/Loader.php';
$cnf = new \Mypos\IPC\Config();
$cnf->setIpcURL('https://mypos.eu/vmp/checkout-test/');
$cnf->setLang('en');
$cnf->setPrivateKeyPath(dirname(__FILE__) . '/keys/store_private_key.pem');
$cnf->setAPIPublicKeyPath(dirname(__FILE__) . '/keys/api_public_key.pem');
$cnf->setKeyIndex(1);
$cnf->setSid('000000000000010');
$cnf->setVersion('1.3');
$cnf->setWallet('61938166610');
$refund = new \Mypos\IPC\Refund($cnf);
$refund->setAmount(10);
$refund->setCurrency('EUR');
$refund->setOrderID(uniqid());
$refund->setTrnref('123456');
$refund->setOutputFormat(Mypos\IPC\Defines::COMMUNICATION_FORMAT_XML);
if($refund->process()){
//Refund successful! Do something
}else{
//Do something else
}
require_once './IPC/Loader.php';
$cnf = new \Mypos\IPC\Config();
$cnf->setIpcURL('https://mypos.eu/vmp/checkout-test/');
$cnf->setLang('en');
$cnf->setPrivateKeyPath(dirname(__FILE__) . '/keys/store_private_key.pem');
$cnf->setAPIPublicKeyPath(dirname(__FILE__) . '/keys/api_public_key.pem');
$cnf->setKeyIndex(1);
$cnf->setSid('000000000000010');
$cnf->setVersion('1.3');
$cnf->setWallet('61938166610');
$reversal = new \Mypos\IPC\Reversal($cnf);
$reversal->setTrnref('12345678923');
$reversal->setOutputFormat(Mypos\IPC\Defines::COMMUNICATION_FORMAT_XML);
$result = $reversal->process();
if ($result->getStatus() == \Mypos\IPC\Defines::STATUS_SUCCESS) {
echo 'success';
//success
} else {
//Show error.
}
require_once './IPC/Loader.php';
$cnf = new \Mypos\IPC\Config();
$cnf->setIpcURL('https://mypos.eu/vmp/checkout-test/');
$cnf->setLang('en');
$cnf->setPrivateKeyPath(dirname(__FILE__) . '/keys/store_private_key.pem');
$cnf->setAPIPublicKeyPath(dirname(__FILE__) . '/keys/api_public_key.pem');
$cnf->setKeyIndex(1);
$cnf->setSid('000000000000010');
$cnf->setVersion('1.3');
$cnf->setWallet('61938166610');
$rm = new \Mypos\IPC\RequestMoney($cnf);
$rm->setAmount(10);
$rm->setCurrency('EUR');
$rm->setOrderID(uniqid());
$rm->setMandateReferece('126ca831-93d2-4dfc-ab1f-0cce1d0abe9e');
$rm->setCustomerWalletNumber('61938166612');
$rm->setReason('Here comes the reason');
$rm->setOutputFormat(Mypos\IPC\Defines::COMMUNICATION_FORMAT_XML);
$result = $rm->process();
if ($result->getStatus() == \Mypos\IPC\Defines::STATUS_SUCCESS) {
//Success. Save IPC_Trnref for transaction
echo $result->getData()['IPC_Trnref'];
} else {
//Show error.
}
require_once './IPC/Loader.php';
$cnf = new \Mypos\IPC\Config();
$cnf->setIpcURL('https://mypos.eu/vmp/checkout-test/');
$cnf->setLang('en');
$cnf->setPrivateKeyPath(dirname(__FILE__) . '/keys/store_private_key.pem');
$cnf->setAPIPublicKeyPath(dirname(__FILE__) . '/keys/api_public_key.pem');
$cnf->setKeyIndex(1);
$cnf->setSid('000000000000010');
$cnf->setVersion('1.3');
$cnf->setWallet('61938166610');
$mandateManagement = new \Mypos\IPC\MandateManagement($cnf);
$mandateManagement->setMandateReferece('126ca831-93d2-4dfc-ab1f-0cce1d0abe9e');
$mandateManagement->setCustomerWalletNumber('61938166612');
$mandateManagement->setAction(\Mypos\IPC\MandateManagement::MANDATE_MANAGEMENT_ACTION_REGISTER);
$mandateManagement->setMandateText('Here comes the mandate text');
$mandateManagement->setOutputFormat(Mypos\IPC\Defines::COMMUNICATION_FORMAT_XML);
$result = $mandateManagement->process();
if ($result->getStatus() == \Mypos\IPC\Defines::STATUS_SUCCESS) {
echo 'success';
//success
} else {
//Show error.
}
require_once './IPC/Loader.php';
$cnf = new \Mypos\IPC\Config();
$cnf->setIpcURL('https://mypos.eu/vmp/checkout-test/');
$cnf->setLang('en');
$cnf->setPrivateKeyPath(dirname(__FILE__) . '/keys/store_private_key.pem');
$cnf->setAPIPublicKeyPath(dirname(__FILE__) . '/keys/api_public_key.pem');
$cnf->setKeyIndex(1);
$cnf->setSid('000000000000010');
$cnf->setVersion('1.3');
$cnf->setWallet('61938166610');
$ipcLog = new \Mypos\IPC\IPCGetTxnLog($cnf);
$ipcLog->setOrderID('1440');
$ipcLog->setOutputFormat(\Mypos\IPC\Defines::COMMUNICATION_FORMAT_JSON);
$result = $ipcLog->process();
switch($result->getStatus()){
case \Mypos\IPC\Defines::STATUS_SUCCESS:
//Display returned data in the site interfase.
//Loop and display in table or just print_r response
print_r(\Mypos\IPC\Helper::getArrayVal($result->getData(CASE_LOWER), 'log'));
break;
case \Mypos\IPC\Defines::STATUS_INVALID_PARAMS:
//Order not found or set params are invalid.
//Show error.
break;
}
try{
$ipcLog = new \Mypos\IPC\IPCGetTxnLog($cnf);
$ipcLog->setOrderID('1440');
$ipcLog->setOutputFormat(\Mypos\IPC\Defines::COMMUNICATION_FORMAT_JSON);
$result = $ipcLog->process();
switch($result->getStatus()){
case \Mypos\IPC\Defines::STATUS_SUCCESS:
print_r(\Mypos\IPC\Helper::getArrayVal($result->getData(CASE_LOWER), 'log'));
break;
case \Mypos\IPC\Defines::STATUS_INVALID_PARAMS:
echo 'Not found!';
break;
}
}catch(\Mypos\IPC\IPC_Exception $ex){
//Display exception message
echo $ex->getMessage();
}
require_once './IPC/Loader.php';
$cnf = new \Mypos\IPC\Config();
$cnf->setIpcURL('https://mypos.eu/vmp/checkout-test/');
$cnf->setLang('en');
$cnf->setPrivateKeyPath(dirname(__FILE__) . '/keys/store_private_key.pem');
$cnf->setAPIPublicKeyPath(dirname(__FILE__) . '/keys/api_public_key.pem');
$cnf->setKeyIndex(1);
$cnf->setSid('000000000000010');
$cnf->setVersion('1.0');
$cnf->setWallet('61938166610');
$ipcStatus = new Mypos\IPC\GetTxnStatus($cnf);
$ipcStatus->setOrderID('1440');
$ipcStatus->setOutputFormat(\Mypos\IPC\Defines::COMMUNICATION_FORMAT_JSON);
$result = $ipcStatus->process();
switch($result->getStatus()){
case \Mypos\IPC\Defines::STATUS_SUCCESS:
//Display returned data in the site interfase.
//Loop and display in table or just print_r response
print_r(\Mypos\IPC\Helper::getArrayVal($result->getData(CASE_LOWER), 'orderstatus'));
break;
case \Mypos\IPC\Defines::STATUS_INVALID_PARAMS:
//Order not found or set params are invalid.
//Show error.
break;
}
try{
$ipcStatus = new \Mypos\IPC\GetTxnStatus($cnf);
$ipcStatus->setOrderID('1440');
$ipcStatus->setOutputFormat(\Mypos\IPC\Defines::COMMUNICATION_FORMAT_JSON);
$result = $ipcStatus->process();
switch($result->getStatus()){
case \Mypos\IPC\Defines::STATUS_SUCCESS:
print_r(\Mypos\IPC\Helper::getArrayVal($result->getData(CASE_LOWER), 'orderstatus'));
break;
case \Mypos\IPC\Defines::STATUS_INVALID_PARAMS:
echo 'Not found!';
break;
}
}catch(\Mypos\IPC_Exception $ex){
//Display exception message
echo $ex->getMessage();
}
require_once './IPC/Loader.php';
$cnf = new \Mypos\IPC\Config();
$cnf->setIpcURL('https://mypos.eu/vmp/checkout-test/');
$cnf->setLang('en');
$cnf->setPrivateKeyPath(dirname(__FILE__) . '/keys/store_private_key.pem');
$cnf->setAPIPublicKeyPath(dirname(__FILE__) . '/keys/api_public_key.pem');
$cnf->setKeyIndex(1);
$cnf->setSid('000000000000010');
$cnf->setVersion('1.3');
$cnf->setWallet('61938166610');
try{
$responce = Mypos\IPC\Response::getInstance($cnf, $_POST, \Mypos\IPC\Defines::COMMUNICATION_FORMAT_POST);
}catch(\Mypos\IPC\IPC_Exception $e){
echo 'Error';
}
$data = $responce->getData(CASE_LOWER);
if('...check and update order'){
echo 'OK';
}else{
echo 'Error';
}
require_once './IPC/Loader.php';
$cnf = new \Mypos\IPC\Config();
$cnf->setIpcURL('https://mypos.eu/vmp/checkout-test/');
$cnf->setLang('en');
$cnf->setPrivateKeyPath(dirname(__FILE__) . '/keys/store_private_key.pem');
$cnf->setAPIPublicKeyPath(dirname(__FILE__) . '/keys/api_public_key.pem');
$cnf->setKeyIndex(1);
$cnf->setSid('000000000000010');
$cnf->setVersion('1.3');
$cnf->setWallet('61938166610');
try{
$responce = Mypos\IPC\Response::getInstance($cnf, $_POST, \Mypos\IPC\Defines::COMMUNICATION_FORMAT_POST);
}catch(\Mypos\IPC\IPC_Exception $e){
//Display Some general error or redirect to merchant store home page
}
$data = $responce->getData(CASE_LOWER);
if('...order is found in merchant store DB'){
//Display "Your order has been successfully paid" for example.
}else{
//Display Some general error or redirect to merchant store home page
}
require_once './IPC/Loader.php';
$cnf = new \Mypos\IPC\Config();
$cnf->setIpcURL('https://mypos.eu/vmp/checkout-test/');
$cnf->setLang('en');
$cnf->setPrivateKeyPath(dirname(__FILE__) . '/keys/store_private_key.pem');
$cnf->setAPIPublicKeyPath(dirname(__FILE__) . '/keys/api_public_key.pem');
$cnf->setKeyIndex(1);
$cnf->setSid('000000000000010');
$cnf->setVersion('1.3');
$cnf->setWallet('61938166610');
try{
$responce = Mypos\IPC\Response::getInstance($cnf, $_POST, \Mypos\IPC\Defines::COMMUNICATION_FORMAT_POST);
}catch(\Mypos\IPC\IPC_Exception $e){
//Display Some general error or redirect to merchant store home page
}
$data = $responce->getData(CASE_LOWER);
if('...order is found in merchant store DB'){
//Display "Your order has been canceled" for example.
}else{
//Display Some general error or redirect to merchant store home page
}
require_once './IPC/Loader.php';
$cnf = new \Mypos\IPC\Config();
$cnf->setIpcURL('https://mypos.eu/vmp/checkout-test/');
$cnf->setLang('en');
$cnf->setPrivateKeyPath(dirname(__FILE__) . '/keys/store_private_key.pem');
$cnf->setAPIPublicKeyPath(dirname(__FILE__) . '/keys/api_public_key.pem');
$cnf->setKeyIndex(1);
$cnf->setSid('000000000000010');
$cnf->setVersion('1.3');
$cnf->setWallet('61938166610');
try{
$responce = Mypos\IPC\Response::getInstance($cnf, $_POST, \Mypos\IPC\Defines::COMMUNICATION_FORMAT_POST);
}catch(\Mypos\IPC\IPC_Exception $e){
echo 'Error';
}
$data = $responce->getData(CASE_LOWER);
if('...check and update order'){
echo 'OK';
}else{
echo 'Error';
}