handleAction
Function that can be called in the event that you get a 3-D Secure additional action required response to a payment request. Use the json.action
received from v1/payments
endpoint when actionRequired
: true
, this will be converted into a nonce
you can use to complete the payment with a ProviderThreeDSecureNonce Payment Instrument.
Errors Thrown
Brdge3DSecureError
Caution
List of supported PSPs is available here.
Data Example
{
"type": "3D_SECURE",
"paymentId": "paymentId",
"data": {
"verifyCardPayload": "Verify String",
"clientToken": "Token",
"psp": "BR"
}
}
Content copied to clipboard
Code Example
This example shows a function that uses an already initialized Brdge3DSecure and passes the json.action
as string to the 3-D Secure action handler.
Then it demonstrates how to catch errors that might be thrown by this function.
suspend fun getTokenFrom3DSecureAction(json: JSONObject): String? {
try {
val handleActionResponse = this.handleAction(jsonString = json.toString())
return handleActionResponse.token
} catch (e: Brdge3DSecureError.NonceNotReturned) {
errorMessage = "Something went wrong. Please try again."
} catch (e: Brdge3DSecureError.PspNotHandled) {
errorMessage = "Wrong PSP used: ${e.psp}"
} catch (e: Brdge3DSecureError.UserCancelled) {
errorMessage = "User cancelled. Please try again."
} catch (e: Brdge3DSecureError) {
errorMessage = e.message
} catch (e: Exception) {
errorMessage = "Something went wrong. Please try again."
}
return null
}
Content copied to clipboard
Return
Response with a new token, also known as nonce
.
Parameters
jsonString
Action as JSON String received from Brdge REST API v1/payments
.