Upon HTTP request, the party should respond with header HTTP 200 OK with the following body content: “OK”. Every other response will be treated as communication error, call error, server error or system malfunctions.
Do not use IPCPurchaseOK to authorize a payment because it is not a server-to-server connection and it is not always guaranteed to receive a response. In this case, you should use IPCPurchaseNotify.
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
For more information please refer to myPOS Checkout API Documentation
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.eu/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.3");
cnf.setWalletNumber("61938166610");
Create a Response object with the incoming POST data.
This will validate the income data and the request signature.
import com.mypos.myposcheckout.ipc.IPCException;
import com.mypos.myposcheckout.ipc.enumerable.CommunicationFormat;
import com.mypos.myposcheckout.ipc.response.BasicResponse;
// ...
try {
// `postPayload` should contain the POST request body
BasicResponse notification = new BasicResponse(cnf, postPayload, CommunicationFormat.POST);
notification.processApiResponse();
} catch (IPCException ex) {
// Error
}
Get the posted data as a Map<String, String>
the response data contains elements with keys: IPCmethod, SID, Amount, Currency, OrderID, IPC_Trnref, RequestSTAN, RequestDateTime.
getDataNormalized() returns the response data with lowercase keys.
Merchant site must have next logics:
1. Search in DB for order with this OrderID
2. Verify that Amount and Currency match to amount from the original transaction
3. Change order status to "Paid"
4. echo "OK"
import java.util.Map;
import com.mypos.myposcheckout.ipc.Constants;
// ...
Map<String, String> notificationData = notification.getDataNormalized();
if (/* ... check and update order */) {
// Output `Constants.SUCCESSFUL_RESPONSE` ("OK")
} else {
// Output anything different from `Constants.SUCCESSFUL_RESPONSE` ("OK")
}