Request card token without payment

Create a Config object and set API configuration parameters

Note that ipcApiUrl is different for sandbox and production environment

You can set RSA keys for request signatures by setting key content using loadPrivateKeyFromString and loadPublicKeyFromString or by setting file path using loadPrivateKeyFromFile and loadPublicKeyFromFile

import java.net.MalformedURLException; 
import java.net.URL; 

import com.mypos.myposcheckout.ipc.Config; 
import com.mypos.myposcheckout.ipc.IPCException; 

// ... 

Config cnf = new Config(); 

URL ipcApiUrl = null; 
try { 
    ipcApiUrl = new URL("https://mypos.com/vmp/checkout-test/"); 
} catch (MalformedURLException ex) { 
    // Handle the malformed URL exception 
} 

cnf.setIpcUrl(ipcApiUrl); 
cnf.setLang("en"); 
cnf.loadPrivateKeyFromFile("path_to_directory/storePrivateKey.pem"); // Replace `path_to_directory` with the actual file path 
cnf.loadPublicKeyFromFile("path_to_directory/apiPublicKey.pem"); // Replace `path_to_directory` with the actual file path 
cnf.setKeyIndex(1); 
cnf.setSid("000000000000010"); 
cnf.setVersion("1.4"); 
cnf.setWalletNumber("61938166610");


Create a Purchase object using the Config object and set the required parameters

import java.net.MalformedURLException; 
import java.net.URL; 

import com.mypos.myposcheckout.ipc.enumerable.Currency; 
import com.mypos.myposcheckout.ipc.request.Purchase; 

// ... 

Purchase purchase = new Purchase(cnf); 
try { 
    purchase.setCancelUrl(new URL("https://mysite.com/ipc_cancel")); // User comes here after purchase cancelation 
    purchase.setSuccessUrl(new URL("https://mysite.com/ipc_ok")); // User comes here after purchase success 
    purchase.setNotifyUrl(new URL("https://mysite.com/ipc_notify")); // IPC sends POST reuquest to this address with purchase status 
} catch (MalformedURLException ex) { 
    // Handle the malformed URL exception 
} 
purchase.setOrderId("123456"); // Some unique ID 
purchase.setCurrency(Currency.EUR); 
purchase.setNote("Some note"); // Not required 
purchase.setCardTokenRequest(CardTokenRequest.CARD_TOKEN_REQUEST_ONLY_STORE); 
purchase.setParametersRequired(PaymentParametersRequired.PURCHASE_TYPE_SIMPLIFIED_PAYMENT_PAGE);


Process payment

import com.mypos.myposcheckout.ipc.IPCException; 

// ... 

try { 
    purchase.process(); 
} catch (IPCException ex) { 
    // Invalid parameters. To see details use `ex.getMessage();`. 
}