Skip to content

Commit

Permalink
fix: Android StripeTerminal assign paymentIntentInstance for confirmP…
Browse files Browse the repository at this point in the history
…aymentIntent
  • Loading branch information
yllaw committed Mar 18, 2024
1 parent 1f5f5c0 commit cb8762f
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public class StripeTerminal extends Executor {
private final JSObject emptyObject = new JSObject();
private Boolean isTest;
private TerminalConnectTypes terminalConnectType;

private PaymentIntent paymentIntent;
private PaymentIntent paymentIntentInstance;

public StripeTerminal(
Supplier<Context> contextSupplier,
Expand Down Expand Up @@ -339,6 +338,7 @@ public void onFailure(@NonNull TerminalException ex) {
@Override
public void onSuccess(PaymentIntent paymentIntent) {
collectCancelable = null;
paymentIntentInstance = paymentIntent;
notifyListeners(TerminalEnumEvent.CollectedPaymentIntent.getWebEventName(), emptyObject);

PaymentMethod pm = paymentIntent.getPaymentMethod();
Expand Down Expand Up @@ -374,19 +374,20 @@ public void onFailure(@NonNull TerminalException ex) {
};

public void confirmPaymentIntent(final PluginCall call) {
if (this.paymentIntent == null) {
if (this.paymentIntentInstance == null) {
call.reject("PaymentIntent not found for confirmPaymentIntent. Use collect method first and try again.");
return;
}

this.confirmPaymentIntentCall = call;
Terminal.getInstance().confirmPaymentIntent(this.paymentIntent, confirmPaymentMethodCallback);
Terminal.getInstance().confirmPaymentIntent(this.paymentIntentInstance, confirmPaymentMethodCallback);
}

private final PaymentIntentCallback confirmPaymentMethodCallback = new PaymentIntentCallback() {
@Override
public void onSuccess(PaymentIntent paymentIntent) {
notifyListeners(TerminalEnumEvent.ConfirmedPaymentIntent.getWebEventName(), emptyObject);
paymentIntentInstance = null;
confirmPaymentIntentCall.resolve();
}

Expand Down

0 comments on commit cb8762f

Please sign in to comment.