Describe the bug
When confirming BLIK operation with passing a 6-digit code Android returns error "The payment has been canceled" but I see that payment appears in Stripe dashboard as "Succeeded".
iOS with the same implementation return "Payment successfully completed" and I also see that payment appears in Stripe dashboard as "Succeeded".
Create a payment intent and confirm it using this sdk.
Expected behavior
PAyment should be successful on android like on iOS.
Additional context
I found that isNextActionSuccessState(result.nextActionType) in retrievePaymentIntent function in PaymentLauncherFragment.kt in reactnativestripesdk package returns false and thats why it returns error with the message "The payment has been canceled"
private fun retrievePaymentIntent(clientSecret: String, stripeAccountId: String?) {
stripe.retrievePaymentIntent(clientSecret, stripeAccountId, expand = listOf("payment_method"), object : ApiResultCallback<PaymentIntent> {
override fun onError(e: Exception) {
promise.resolve(createError(ConfirmPaymentErrorType.Failed.toString(), e))
removeFragment(context)
}
override fun onSuccess(result: PaymentIntent) {
when (result.status) {
StripeIntent.Status.Succeeded,
StripeIntent.Status.Processing,
StripeIntent.Status.RequiresConfirmation,
StripeIntent.Status.RequiresCapture -> {
promise.resolve(createResult("paymentIntent", mapFromPaymentIntentResult(result)))
}
StripeIntent.Status.RequiresAction -> {
// nextActionType is BlikAuthorize and this method will return false
if (isNextActionSuccessState(result.nextActionType)) {
promise.resolve(createResult("paymentIntent", mapFromPaymentIntentResult(result)))
} else {
(result.lastPaymentError)?.let {
promise.resolve(createError(ConfirmPaymentErrorType.Canceled.toString(), it))
} ?: run {
// Android will go here
promise.resolve(createError(ConfirmPaymentErrorType.Canceled.toString(), "The payment has been canceled"))
}
}
}
StripeIntent.Status.RequiresPaymentMethod -> {
promise.resolve(createError(ConfirmPaymentErrorType.Failed.toString(), result.lastPaymentError))
}
StripeIntent.Status.Canceled -> {
promise.resolve(createError(ConfirmPaymentErrorType.Canceled.toString(), result.lastPaymentError))
}
else -> {
promise.resolve(createError(ConfirmPaymentErrorType.Unknown.toString(), "unhandled error: ${result.status}"))
}
}
removeFragment(context)
}
})
}
On iOS StripeSdk.swift has different implementation for this confirmPayment
func onCompleteConfirmPayment(status: STPPaymentHandlerActionStatus, paymentIntent: STPPaymentIntent?, error: NSError?) {
self.confirmPaymentClientSecret = nil
switch (status) {
case .failed:
confirmPaymentResolver?(Errors.createError(ErrorType.Failed, error))
break
case .canceled:
let statusCode: String
if (paymentIntent?.status == STPPaymentIntentStatus.requiresPaymentMethod) {
statusCode = ErrorType.Failed
} else {
statusCode = ErrorType.Canceled
}
if let lastPaymentError = paymentIntent?.lastPaymentError {
confirmPaymentResolver?(Errors.createError(statusCode, lastPaymentError))
} else {
confirmPaymentResolver?(Errors.createError(statusCode, "The payment has been canceled"))
}
break
case .succeeded:
// iOS will go here
if let paymentIntent = paymentIntent {
let intent = Mappers.mapFromPaymentIntent(paymentIntent: paymentIntent)
confirmPaymentResolver?(Mappers.createResult("paymentIntent", intent))
}
break
@unknown default:
confirmPaymentResolver?(Errors.createError(ErrorType.Unknown, "Cannot complete the payment"))
break
}
}
Describe the bug When confirming BLIK operation with passing a 6-digit code Android returns error "The payment has been canceled" but I see that payment appears in Stripe dashboard as "Succeeded". iOS with the same implementation return "Payment successfully completed" and I also see that payment appears in Stripe dashboard as "Succeeded".
For more context: https://github.com/flutter-stripe/flutter_stripe/issues/1497
To Reproduce Servercode:
Create a payment intent and confirm it using this sdk.
Expected behavior PAyment should be successful on android like on iOS.
Additional context I found that isNextActionSuccessState(result.nextActionType) in retrievePaymentIntent function in PaymentLauncherFragment.kt in reactnativestripesdk package returns false and thats why it returns error with the message "The payment has been canceled"
On iOS StripeSdk.swift has different implementation for this confirmPayment