Skip to content

Commit 8e073d9

Browse files
committed
fire and forget checkout process request when selecting offline payment method
1 parent f416ff1 commit 8e073d9

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

core/src/main/java/io/snabble/sdk/Checkout.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,6 @@ private void pay(final PaymentMethod paymentMethod, boolean force) {
381381

382382
if(paymentMethod.isOfflineMethod()){
383383
notifyStateChanged(State.WAIT_FOR_APPROVAL);
384-
return;
385384
}
386385

387386
CheckoutProcessRequest checkoutProcessRequest = new CheckoutProcessRequest();
@@ -403,6 +402,10 @@ private void pay(final PaymentMethod paymentMethod, boolean force) {
403402
call.enqueue(new Callback() {
404403
@Override
405404
public void onResponse(Call call, Response response) throws IOException {
405+
if(paymentMethod.isOfflineMethod()){
406+
return;
407+
}
408+
406409
if (response.isSuccessful()) {
407410
ResponseBody body = response.body();
408411
if (body == null) {
@@ -435,14 +438,20 @@ public void onResponse(Call call, Response response) throws IOException {
435438

436439
@Override
437440
public void onFailure(Call call, IOException e) {
441+
if(paymentMethod.isOfflineMethod()){
442+
return;
443+
}
444+
438445
if (!call.isCanceled()) {
439446
Logger.e("Connection error while creating checkout process");
440447
notifyStateChanged(State.CONNECTION_ERROR);
441448
}
442449
}
443450
});
444451

445-
notifyStateChanged(State.VERIFYING_PAYMENT_METHOD);
452+
if(!paymentMethod.isOfflineMethod()) {
453+
notifyStateChanged(State.VERIFYING_PAYMENT_METHOD);
454+
}
446455
}
447456
}
448457
}

0 commit comments

Comments
 (0)