Skip to content

Commit

Permalink
fix: fix issue with MP checkout rebooting rn app
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatansalas committed May 29, 2020
1 parent 6c65a6b commit 56c1c38
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ open class ReactNativeMercadoPagoPxEventListener: ActivityEventListener {
}

if (resultCode == MercadoPagoCheckout.PAYMENT_RESULT_CODE) {
val payment = PaymentResult.getPayment(data);

mModulePromise?.resolve(payment);
if (data == null) {
throw Error("Something went wrong with payment");
} else if (data.extras != null && data.extras.containsKey(MercadoPagoCheckout.EXTRA_ERROR)) {
val error = PaymentResult.getError(data);
throw Error(error.message);
} else {
val payment = PaymentResult.getPayment(data);
mModulePromise?.resolve(payment);
}
}
}
} catch (err: Error) {
Expand Down

0 comments on commit 56c1c38

Please sign in to comment.