Android
1.After the payment is completed, redirect to the webpage for 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
3.Get the payment result
Last updated