You can perform Debit (Purchase) payments using our server-to-server REST API.
Debit (DB)
A DB is created by sending a POST request over HTTPS to the /transaction/request-payment-url resource. The request should include all required information such as your authentication credentials, the type of transaction, the amount and the payment information such as card details. A DB request effectively combines a PA and capture request, automatically requesting that the funds are cleared if the authorization was successful.
Synchronous Workflow
Each paymentBrand follows one of two workflows: asynchronous or synchronous. In a synchronous workflow the payment data is sent directly in the server-to-server initial payment request and the payment is processed straight away.
How it works:
Prepare the Checkout
First, perform a server-to-server POST request to prepare the checkout with the required data, including the order type, amount and currency. The response to a successful request is a JSON string with an id, which is required in the second step to create the payment form.
private String request() throws IOException {
URL url = new URL(“https: //staging.logibiztech.com:8777/transaction/request-payment-url");
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Authorization",
"Bearer OGE4Mjk0MTc0YjdlY2IyODAxNGI5Njk5MjIwMDE1Y2N8c3k2S0pzVDg=");
conn.setDoInput(true);
conn.setDoOutput(true);
String data = "{"actionCode":"1","amount":"130",
"browserColorDepth": "24",
"browserJavaEnabled": "true",
"browserJavaScriptEnabled": "true",
"browserLanguage": "en-PK",
"browserScreenHeight": "714",
"browserScreenWidth": "1536",
"browserTimeZone": "-300",
"currency": "840",
"errorUrl": "https://www.logibiztech.com/details",
"javaScriptEnabled": true,
"langId": "EN",
"password": "******",
"successUrl": "https://www.logibiztech.com/details",
"trackId": "00008",
"tranPortalId": "t2",
"udf": [
""
]
}";
DataOutputStream wr = new DataOutputStream(conn.getOutputStream());
wr.writeBytes(data);
wr.flush();
wr.close();
int responseCode = conn.getResponseCode();
InputStream is;
if (responseCode >= 400) is = conn.getErrorStream();
else is = conn.getInputStream();
return IOUtils.toString(is);
}
Response
Success Scenario
{
"status": "1",
"PaymentId": "823201000100006",
"PaymentPageUrl": "https://staging.logibiztech.com:8777/transaction/mvc/payment"
}
Failure Scenario
{
"errorCode": "LOG7",
"errorDesc": "DuplicateMerchantReferenceID",
"message": "DUPLICATE_MERCHANT_REF_ID"
}
Re-direct to Payment Page
Paybiz Payment gateway internally validates the request and gives payment ID and payment page URL in the response in case of successful validation, if failure then error code and description will be provided.
private String request() throws IOException {
URL url = new URL("https://staging.logibiztech.com:8777/transaction/mvc/payment/t2/Jy1dTheUgNtdwOPg_skJSw ==");
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Authorization",
"Bearer OGE4Mjk0MTc0YjdlY2IyODAxNGI5Njk5MjIwMDE1Y2N8c3k2S0pzVDg=");
int responseCode = conn.getResponseCode();
InputStream is;
if (responseCode >= 400) is = conn.getErrorStream();
else is = conn.getInputStream();
return IOUtils.toString(is);
}
Response
Success Scenario
{
"responseMessage": "PaymentSuccessful",
"status": "SUCCESS",
"merchantRefId": "6566666666",
"token": "0b4d4878-c5ae-4cb7-a99aa45d9121984d",
"paymentId": "823203499820001",
"txnTime": "2023-07-2201:53:02PM",
"amount": "200.0",
"authCode": "000000",
"responseCode": "00",
"rrn": "139022961549"
}
Failure Scenario
{
"responseMessage": "RISK-001:Cardnumber is in Declined Card list",
"status": "RISK_FAILED",
"merchantRefId": "000083423",
"paymentId": "823202511610001",
"trxnTime": "2023-07-21 02:12:41 PM",
"amount": "130.0"
}