-
Notifications
You must be signed in to change notification settings - Fork 54
Bank Transfer Payment Usage
There are four banks supported at this SDK.
- BCA
- Permata
- BNI
- Other Banks (Using Permata)
We provide interface for transaction callback. You just need to implement TransactionCallback when make a transaction to get transaction response.
It contains three implemented methods onSuccess
, onFailure
and onError
.
public interface TransactionCallback {
//transaction response when success
public void onSuccess(TransactionResponse response);
//response when transaction failed
public void onFailure(TransactionResponse response, String reason);
//general error
public void onError(Throwable error);
}
for transaction using bank transfer, You can use methods API of midtrans SDK below
//bank transfer BCA
midtransSDK.paymentUsingBankTransferBCA(
AUTHENTICATION_TOKEN, EMAIL_USER, transactionCallback);
//bank tranfer Permata
midtransSDK.paymentUsingBankTransferPermata(
AUTHENTICATION_TOKEN, EMAIL_USER, transactionCallback);
//bank tranfer BNI
midtransSDK.paymentUsingBankTransferBni(
AUTHENTICATION_TOKEN, EMAIL_USER, transactionCallback);
//bank tranfer all
midtransSDK.paymentUsingBankTransferAllBank(
AUTHENTICATION_TOKEN, EMAIL_USER, transactionCallback);
You need the checkout token and customer email before starting the payment.
Execute Transaction using following method to get response back. below sample transaction using bank tranfer permata
midtransSDK.paymentUsingBankTransferPermata(
AUTHENTICATION_TOKEN,
EMAIL_USER, new TransactionCallback() {
@Override
public void onSuccess(TransactionResponse response) {
//actionTransactionSuccess(response);
}
@Override
public void onFailure(TransactionResponse response, String reason) {
//actionTransactionFailure(response, reason);
}
@Override
public void onError(Throwable error) {
//actionTransactionError(error);
}
}
);
User need to get the virtual account number. It is provided in TransactionResponse
.
BCA and Permata has different data structure so we must handle it in different way.
BCA can provide more than one virtual account, so we get a list of BCAVANumber
object.
List<BCAVANumber> virtualAccounts = response.getAccountNumbers();
String virtualAccount = response.getPermataVANumber();