Internet Banking
The 2C2P PGW SDK allows merchants to accept direct debit payments from a customer's preferred bank. This allows for seamless payments in merchants' mobile applications.
API Method
References
1. Prepare Payment Token Request
To prepare a payment token request, refer to the required parameters below.
Payment Token API
Refer to: Payment Token API
{
"merchantID": "JT04",
"invoiceNo": "1595219400",
"description": "2 days 1 night hotel room",
"amount": 10.0,
"currencyCode": "THB",
"nonceStr": "a8092512-b144-41b0-8284-568bb5e9264c",
"paymentChannel": ["IMBANK"]
}
2. Receive Payment Token Response
To receive a payment token response, refer to the sample payment token response below.
String paymentToken = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
NSString *paymentToken = @"roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
let paymentToken: String = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL"
3. Prepare Payment Request
To prepare a payment request, refer to the sample code below.
Payment Request Parameters
Payment Channels & Agents
To see the available payment channels and agents for supported banks, refer to: Payment Channel Matrix
PaymentCode paymentCode = new PaymentCode("123", "UOB", "IBANKING");
PaymentRequest paymentRequest = new InternetBankingBuilder(paymentCode)
.setName("DavidBilly")
.setEmail("[email protected]")
.setMobileNo("08888888")
.build();
PaymentCode *paymentCode = [[PaymentCode alloc] initWithChannelCode: @"123" agentCode: @"UOB" agentChannelCode: @"IBANKING"];
PaymentRequest *paymentRequest = [[[[[[InternetBankingBuilder alloc] initWithPaymentCode: paymentCode]
name: @"DavidBilly"]
email: @"[email protected]"]
mobileNo: @"08888888"]
build];
let paymentCode: PaymentCode = PaymentCode(channelCode: "123", "UOB", "IBANKING")
let paymentRequest: PaymentRequest = InternetBankingBuilder(paymentCode: paymentCode)
.name("DavidBilly")
.email("[email protected]")
.mobileNo("08888888")
.build()
4. Prepare Transaction Request
To prepare a transaction request, refer to the parameters below.
Transaction Request API Parameters
Refer to: Do Payment Request API Parameter
TransactionResultRequest transactionResultRequest = new TransactionResultRequestBuilder(paymentToken)
.with(paymentRequest)
.build();
TransactionResultRequest *transactionResultRequest = [[[[TransactionResultRequestBuilder alloc] initWithPaymentToken: paymentToken]
withPaymentRequest: paymentRequest]
build];
let transactionResultRequest: TransactionResultRequest = TransactionResultRequestBuilder(paymentToken: paymentToken)
.with(paymentRequest)
.build()
5. Receive Transaction Request Response
To receive a transaction request response, refer to the parameters below.
Transaction Response API Parameters
Refer to: Do Payment Response API Parameters
References
Response Code
To view payment process flows based on response code, refer to: Payment Flow Response Codes
PGWSDK.getInstance().proceedTransaction(transactionResultRequest, new APIResponseCallback<TransactionResultResponse>() {
@Override
public void onResponse(TransactionResultResponse response) {
if(response.getResponseCode().equals(APIResponseCode.TransactionPaymentSlip)) {
String paymentSlipUrl = response.getData(); //Open payment slip on WebView
} else {
//Get error response and display error.
}
}
@Override
public void onFailure(Throwable error) {
//Get error response and display error.
}
});
[[PGWSDK shared] proceedTransactionWithTransactionResultRequest: transactionResultRequest response: ^(TransactionResultResponse * _Nonnull response) {
if([response.responseCode isEqualToString: APIResponseCode.TransactionPaymentSlip]) {
NSString *paymentSlipUrl = response.data; //Open payment slip on WebView
} else {
//Get error response and display error.
}
} failure: ^(NSError * _Nonnull error) {
//Get error response and display error.
}];
PGWSDK.shared.proceedTransaction(transactionResultRequest: transactionResultRequest, { (response:TransactionResultResponse) in
if response.responseCode == APIResponseCode.TransactionPaymentSlip {
guard let paymentSlipUrl: String = response.data else { return } //Open payment slip on WebView
} else {
//Get error response and display error.
}
}) { (error: NSError) in
//Get error response and display error.
}
Callback for PGW Payment Authentication
Refer to: Handle PGW Payment Authentication
Full Sample Code
The following sample code demonstrates requests and parameters for each step of the process.
//Step 1 : Generate payment token
String paymentToken = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
//Step 2: Construct Internet Banking request.
PaymentCode paymentCode = new PaymentCode("123", "UOB", "IBANKING");
PaymentRequest paymentRequest = new InternetBankingBuilder(paymentCode)
.setName("DavidBilly")
.setEmail("[email protected]")
.setMobileNo("08888888")
.build();
//Step 3: Construct transaction request.
TransactionResultRequest transactionResultRequest = new TransactionResultRequestBuilder(paymentToken)
.with(paymentRequest)
.build();
//Step 4: Execute payment request.
PGWSDK.getInstance().proceedTransaction(transactionResultRequest, new APIResponseCallback<TransactionResultResponse>() {
@Override
public void onResponse(TransactionResultResponse response) {
if(response.getResponseCode().equals(APIResponseCode.TransactionPaymentSlip)) {
String paymentSlipUrl = response.getData(); //Open payment slip on WebView
} else {
//Get error response and display error.
}
}
@Override
public void onFailure(Throwable error) {
//Get error response and display error.
}
});
//Step 1 : Generate payment token
NSString *paymentToken = @"roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
//Step 2: Construct Internet Banking request.
PaymentCode *paymentCode = [[PaymentCode alloc] initWithChannelCode: @"123" agentCode: @"UOB" agentChannelCode: @"IBANKING"];
PaymentRequest *paymentRequest = [[[[[[InternetBankingBuilder alloc] initWithPaymentCode: paymentCode]
name: @"DavidBilly"]
email: @"[email protected]"]
mobileNo: @"08888888"]
build];
//Step 3: Construct transaction request.
TransactionResultRequest *transactionResultRequest = [[[[TransactionResultRequestBuilder alloc] initWithPaymentToken: paymentToken]
withPaymentRequest: paymentRequest]
build];
//Step 4: Execute payment request.
[[PGWSDK shared] proceedTransactionWithTransactionResultRequest: transactionResultRequest response: ^(TransactionResultResponse * _Nonnull response) {
if([response.responseCode isEqualToString: APIResponseCode.TransactionPaymentSlip]) {
NSString *paymentSlipUrl = response.data; //Open payment slip on WebView
} else {
//Get error response and display error.
}
} failure: ^(NSError * _Nonnull error) {
//Get error response and display error.
}];
//Step 1 : Generate payment token
let paymentToken: String = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL"
//Step 2: Construct Internet Banking request.
let paymentCode: PaymentCode = PaymentCode(channelCode: "123", "UOB", "IBANKING")
let paymentRequest: PaymentRequest = InternetBankingBuilder(paymentCode: paymentCode)
.name("DavidBilly")
.email("[email protected]")
.mobileNo("08888888")
.build()
//Step 3: Construct transaction request.
let transactionResultRequest: TransactionResultRequest = TransactionResultRequestBuilder(paymentToken: paymentToken)
.with(paymentRequest)
.build()
//Step 4: Execute payment request.
PGWSDK.shared.proceedTransaction(transactionResultRequest: transactionResultRequest, { (response:TransactionResultResponse) in
if response.responseCode == APIResponseCode.TransactionPaymentSlip {
guard let paymentSlipUrl: String = response.data else { return } //Open payment slip on WebView
} else {
//Get error response and display error.
}
}) { (error: NSError) in
//Get error response and display error.
}
Updated almost 3 years ago