PayTo
Follow this guide to add PayTo to your checkout.
- PAYTO - PayTo
Payment method availability:
- PayTo since mSDK version 7.7.0
iOS
Ready-to-Use UI
When you use our ready-to-use UI, everything works out-of-box. Just set PAYTO payment brand and shopper result url in the Checkout Settings class and you are done. Proceed with the presenting checkout as for standard transaction.
let checkoutSettings = OPPCheckoutSettings()
// Set PayTo payment method
checkoutSettings.paymentBrands = ["PAYTO"]
checkoutSettings.shopperResultURL = "com.companyname.appname.payments://result"
OPPCheckoutSettings *checkoutSettings = [[OPPCheckoutSettings alloc] init];
// Set PayTo payment methods
checkoutSettings.paymentBrands = @[@"PAYTO"];
checkoutSettings.shopperResultURL = @"com.companyname.appname.payments://result";
To customize the order of PayID options on the PayTo payment screen, set the payToPaymentOptions property within checkoutSettings. The first option in the list will appear as the default selection. If any invalid value is provided, the system will fall back to the default sequence: "Mobile", "Email", "Account No".
checkoutSettings.payToPaymentOptions = [.mobileNo, .email, .accountNo]
checkoutSettings.payToPaymentOptionsObjc = @[@"Mobile", @"Email", @"Account no"];
SDK & Your Own UI
In this guide we assume that you have already implemented all steps for performing standard mSDK transaction.
There are several steps that you have to perform to integrate PAYTO, which are as follows:
1. Create PayTo payment param
Use checkoutId and pay Id to create PayTo payment params. You may use mobile number, email address or account number as pay id.
var params: OPPPayToPaymentParams
do {
params = try OPPPayToPaymentParams(checkoutID: checkoutID, mobileNumber: mobileNumber)
params.shopperResultURL = shopperResultURL
} catch let error as NSError {
// Handle the error
}
NSError *error;
OPPPayToPaymentParams *paymentParams = [[[OPPPayToPaymentParams alloc] initWithCheckoutId:checkoutId mobileNumber:mobileNumber error:&error];
paymentParams.shopperResultURL = @"com.companyname.appname.payments://result";
var params: OPPPayToPaymentParams
do {
params = try OPPPayToPaymentParams(checkoutID: checkoutID, email: email)
params.shopperResultURL = shopperResultURL
} catch let error as NSError {
// Handle the error
}
NSError *error;
OPPPayToPaymentParams *paymentParams = [[[OPPPayToPaymentParams alloc] initWithCheckoutId:checkoutId email:email error:&error];
paymentParams.shopperResultURL = @"com.companyname.appname.payments://result";
var params: OPPPayToPaymentParams
do {
params = try OPPPayToPaymentParams(checkoutId: checkoutID, bsb: bsb, accountNumber: accountNumber)
params.shopperResultURL = shopperResultURL
} catch let error as NSError {
// Handle the error
}
NSError *error;
OPPPayToPaymentParams *paymentParams = [[OPPPayToPaymentParams alloc] initWithCheckoutId:checkoutId bsb:bsb accountNumber:accountNumber error:&error];
paymentParams.shopperResultURL = @"com.companyname.appname.payments://result";
2. Submit transaction
Create a payment provider object and call submit transaction.
let provider = OPPPaymentProvider(mode: providerMode)
self.provider.submitTransaction(transaction, completionHandler: {(transaction, error) in
// Process transaction here using PayTo processor
})
OPPPaymentProvider *provider = [OPPPaymentProvider paymentProviderWithMode:providerMode];
[provider submitTransaction:transaction completionHandler:^(OPPTransaction * _Nonnull transaction, NSError * _Nullable error) {
// Process transaction here using PayTo processor
}];
3. Create PayTo processor object to process transaction
To complete PayTo transaction you have to create PayToProcessor object and you have to call 'process' method on it to process the transaction.
let payToProcessor = OPPPayToProcessor(transaction: transaction, provider: provider)
payToProcessor.process { transaction, error in
if let error = error {
// Handle error
} else {
// Get the payment status
}
}
OPPPayToProcessor *payToProcessor = [[OPPPayToProcessor alloc] initWithTransaction:transaction provider:provider];
[payToProcessor process:^(OPPTransaction * _Nonnull transaction, NSError * _Nullable error) {
if (error) {
// Handle error
} else {
// Get the payment status
}
}];
4. Get the payment status
Finally your app should request the payment status from your server.
For more details you can refer to this document.
Ready-to-Use UI
When you use our ready-to-use UI, everything works out-of-box. Just set PAYTO payment brand and shopper result url in the Checkout Settings class and you are done. Proceed with the presenting checkout as for standard transaction.
Set<String> paymentBrands = new LinkedHashSet<String>();
paymentBrands.add("PAYTO");
CheckoutSettings checkoutSettings = new CheckoutSettings(checkoutId, paymentBrands, Connect.ProviderMode.TEST);
val paymentBrands = hashSetOf("PAYTO")
val checkoutSettings = CheckoutSettings(checkoutId, paymentBrands, Connect.ProviderMode.TEST)
To customize the order of PayID options on the PayTo payment screen, set the payToPaymentOptions property within checkoutSettings. The first option in the list will appear as the default selection. If any invalid value is provided, the system will fall back to the default sequence: "Mobile", "Email", "Account No".
checkoutSettings.setPayToPayIdTypes(Arrays.asList(PayToPayIdType.MOBILE, PayToPayIdType.EMAIL, PayToPayIdType.ACCOUNT_NUMBER));
checkoutSettings.setPayToPayIdTypes(listOf(PayToPayIdType.MOBILE, PayToPayIdType.EMAIL, PayToPayIdType.ACCOUNT_NUMBER))
SDK & Your Own UI
In this guide we assume that you have already implemented all steps for performing standard mSDK transaction.
There are several steps that you have to perform to integrate PAYTO, which are as follows:
1. Create PayTo payment param
Use checkoutId and pay Id to create PayTo payment params. You may pass any one payId mobile number, email address or account number.
//initializing using checkoutId and mobileNumber, rest parameters can be null.
PayToPaymentParams paymentParams = new PayToPaymentParams(checkoutId, mobileNumber, null, null, null);
paymentParams.setShopperResultUrl("com.companyname.appname.payments://result");
val paymentParams = PayToPaymentParams(checkoutId, phone, null, null, null)
paymentParams.shopperResultUrl = "com.companyname.appname.payments://result"
//initializing using checkoutId and email, rest parameters can be null.
PayToPaymentParams paymentParams = new PayToPaymentParams(checkoutId, null, email, null, null);
paymentParams.setShopperResultUrl("com.companyname.appname.payments://result");
val paymentParams = PayToPaymentParams(checkoutId, null, email, null, null)
paymentParams.shopperResultUrl = "com.companyname.appname.payments://result"
//initializing using checkoutId, account number & bsb, rest parameters can be null.
PayToPaymentParams paymentParams = new PayToPaymentParams(checkoutId, null, null, accountNumber, bsb);
paymentParams.setShopperResultUrl("com.companyname.appname.payments://result");
val paymentParams = PayToPaymentParams(checkoutId, null, null, accountNumber, bsb)
paymentParams.shopperResultUrl = "com.companyname.appname.payments://result"
2. Submit transaction
Create a payment provider object and call submit transaction.
Transaction transaction = new Transaction(paymentParams);
OppPaymentProvider paymentProvider = new OppPaymentProvider(this, Connect.ProviderMode.TEST);
paymentProvider.submitTransaction(transaction, this);
val transaction = Transaction(paymentParams)
val paymentProvider = OppPaymentProvider(this, Connect.ProviderMode.TEST)
paymentProvider.submitTransaction(transaction, this)
3. Register ActivityResultLauncher object to launch PayTo Processor to process the transaction
To complete PAYTO transaction after you receive a transaction object in the callback of step 2, you have to create ActivityResultLaucher object of PayToProcessorResultContract and launch with that transaction.
4. Get the payment status
Finally your app should request the payment status from your server.
For more details you can refer to this document.