There are 2 different ways to introduce recurring payments. 

 

1. Store a card with IPCPurchase, charge a stored card with IPCIAPurchase


If you call IPCPurchase method with CardTokenRequest “1” or “2” parameter, your customer is first redirected to the myPOS hosted checkout page. You can use it for the following combinations:

  • You want to store and verify a card without charging it – 0 value charge;
  • You want to store and verify a card after it is charged – for example, the customer pays and upon payment, our system returns a card token in the response;

 

Available options are:

0 - CARD_TOKEN_REQUEST_NONECreate regular payment without token request
1 - CARD_TOKEN_REQUEST_ONLY_STORE
Only token request without making payment
2 - CARD_TOKEN_REQUEST_PAY_AND_STORE
– Make payment and create a token

 

Once you have a token using IPCPurchase, you can then subsequently charge your customer with calling IPCIAPurchase method with CardToken parameter. This means that your customer won’t be redirected to a myPOS hosted checkout page the second time. You can find examples using our PHP SDK in the attached file.

 

NOTE: If the card is 3D Secure, the first time when cardholder enters card data, he/she will be redirected to issuing bank’s 3D Secure portal.

 

Store a card with payment

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');

#Create Purchase object using Config object and set required params
$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 request to this address with purchase status
$purchase->setOrderID(uniqid()); //Some unique ID
$purchase->setCurrency('EUR');
$purchase->setNote('Some note'); //Not required


#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);
$purchase->setCart($cart);


$purchase->setCardTokenRequest(\Mypos\IPC\Purchase::CARD_TOKEN_REQUEST_PAY_AND_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();"
}

 

Store card without Payment

To make only a token request without payment you must set the appropriate value to setCardTokenRequest() method.

 

NOTE: $cart object is unnecessary, so it may be skipped.

 

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'); 
$purchase->setUrlOk('http://mysite.com/ipc_ok'); 
$purchase->setUrlNotify('https://mysite.com/ipc_notify'); 
$purchase->setOrderID(uniqid());
$purchase->setCurrency('EUR');

$purchase->setCardTokenRequest(\Mypos\IPC\Purchase::CARD_TOKEN_REQUEST_ONLY_STORE);
$purchase->setPaymentParametersRequired(\Mypos\IPC\Purchase::PURCHASE_TYPE_SIMPLIFIED_PAYMENT_PAGE);

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

 

Once the process is completed on myPOS site, merchant site will receive Notify request containing confirmation data and token (if its requested)

 

As a merchant notify endpoint this code may be used to check and verify the request:

 

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);

 

NOTE: $data is an array containing confirmation data and token (if its requested).

  

2. Store a card with IPCIAPurchase, charge a stored card with IPCIAPurchase


If you want to store a card without your customer being redirected to the myPOS checkout hosted page, you have to host the checkout page at your side. As it is hosted on your side, you should also take care of the communication with the issuing bank’s ACS. The communication with issuing bank’s ACS happens through a so-called 3DS MPI (merchant plug-in). We recommend this method only for PCI-SAQ D compliant merchants, as it involves serious dedication and it might not be feasible for smaller merchants. Obtaining the PCI SAQ D compliance might be a painful process.