Android
1.After the payment is completed, redirect to the webpage for 3D Secure authentication
After confirming the returned data after the payment contains the nextAction object and the web redirection addressredirectToUrl is not empty, the web page will be redirected to 3D Secure authentication.
moneyCollect.confirmPayment(requestConfirmPayment, payment.clientSecret,
object : ApiResultCallback<Payment> {
override fun onSuccess(payment: Payment) {
//if nextAction object is not null and redirectToUrl address is not null, further 3d verification
if (payment.nextAction != null) {
if (!TextUtils.isEmpty(payment.nextAction?.redirectToUrl)) {
val intent = Intent(activity, ValidationWebActivity::class.java)
//pass redirectToUrl
intent.putExtra(Constant.VALIDATION_PARAM_URL,payment.nextAction?.redirectToUrl)
//pass payment id
intent.putExtra(Constant.VALIDATION_PAYMENT_ID, payment.id)
//pass payment clientSecret
intent.putExtra(Constant.VALIDATION_PAYMENT_CLIENTSECRET,payment.clientSecret)
startActivityLauncher.launch(intent)
} else {
moneyCollectResultBackInterface?.paymentConfirmResultBack(false,
Constant.PAYMENT_PENDING_MESSAGE)
}
} else {
//Need to deal with the state has succeeded, uncaptured, pending, failed, canceled
when (payment.status) {
Constant.PAYMENT_SUCCEEDED -> {
var intent = Intent()
intent.putExtra(Constant.PAYMENT_RESULT_PAYMENT, payment)
activity?.setResult(Constant.PAYMENT_RESULT_CODE,intent)
moneyCollectResultBackInterface?.paymentConfirmResultBack(true,"")
}
Constant.PAYMENT_FAILED -> {
moneyCollectResultBackInterface?.paymentConfirmResultBack(false,payment.errorMessage)
}
Constant.PAYMENT_UN_CAPTURED -> {
moneyCollectResultBackInterface?.paymentConfirmResultBack(false,
Constant.PAYMENT_UN_CAPTURED_MESSAGE)
}
Constant.PAYMENT_PENDING -> {
moneyCollectResultBackInterface?.paymentConfirmResultBack(false,
Constant.PAYMENT_PENDING_MESSAGE)
}
Constant.PAYMENT_CANCELED -> {
moneyCollectResultBackInterface?.paymentConfirmResultBack(false,
Constant.PAYMENT_CANCELED_MESSAGE)
}
else -> {
moneyCollectResultBackInterface?.paymentConfirmResultBack(false,
Constant.PAYMENT_PENDING_MESSAGE)
}
}
}
}
override fun onError(e: Exception) {
moneyCollectResultBackInterface?.failExceptionBack(e.message)
}
})2.3D Secure authentication on web
Check the current url address firstly after directing to the webpage. If the authenticated rules are met, retrievePayment interface will be called and the payment result will be returned to the customer.
If you click Returnbutton during the verification process, an Exit prompt box will be displayed. Clicking to exit will call the retrievePayment interface, and then return the payment result to the customer. For details, please refer to the ValidationWebActivity class under the MoneyCollectSDK demo.
3.Get the payment result
Last updated