Skip to content

Commit aa62abf

Browse files
committed
fixed credential screen lock from cart
1 parent 9593c6a commit aa62abf

File tree

4 files changed

+44
-26
lines changed

4 files changed

+44
-26
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [0.33.3]
5+
6+
### Fixed
7+
- Require screen lock for payment methods that require credentials when calling from the shopping cart
48
## [0.33.2]
59

610
### Fixed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ allprojects {
2929
}
3030

3131
project.ext {
32-
sdkVersion='0.33.2'
32+
sdkVersion='0.33.3'
3333
versionCode=1
3434

3535
compileSdkVersion=30

ui/src/main/java/io/snabble/sdk/ui/cart/ShoppingCartView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ private void pay() {
311311
PaymentSelectionHelper.Entry entry = paymentSelectionHelper.getSelectedEntry().getValue();
312312
if (entry != null) {
313313
if (entry.paymentMethod.isRequiringCredentials() && entry.paymentCredentials == null) {
314-
PaymentInputViewHelper.openPaymentInputView(entry.paymentMethod, project);
314+
PaymentInputViewHelper.openPaymentInputView(getContext(), entry.paymentMethod, project);
315315
} else {
316316
Telemetry.event(Telemetry.Event.ClickCheckout);
317317
SEPALegalInfoHelper.showSEPALegalInfoIfNeeded(getContext(),
Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,53 @@
11
package io.snabble.sdk.ui.payment;
22

3+
import android.content.Context;
34
import android.os.Bundle;
45

6+
import androidx.appcompat.app.AlertDialog;
7+
58
import io.snabble.sdk.PaymentMethod;
69
import io.snabble.sdk.Project;
10+
import io.snabble.sdk.ui.R;
711
import io.snabble.sdk.ui.SnabbleUI;
12+
import io.snabble.sdk.ui.utils.KeyguardUtils;
813

914
public class PaymentInputViewHelper {
10-
public static void openPaymentInputView(PaymentMethod paymentMethod, Project project) {
15+
public static void openPaymentInputView(Context context, PaymentMethod paymentMethod, Project project) {
1116
SnabbleUI.Callback callback = SnabbleUI.getUiCallback();
1217
if (callback != null) {
13-
Bundle args = new Bundle();
14-
switch (paymentMethod) {
15-
case VISA:
16-
args.putString(CreditCardInputView.ARG_PROJECT_ID, project.getId());
17-
args.putSerializable(CreditCardInputView.ARG_PAYMENT_TYPE, PaymentMethod.VISA);
18-
callback.execute(SnabbleUI.Action.SHOW_CREDIT_CARD_INPUT, args);
19-
break;
20-
case AMEX:
21-
args.putString(CreditCardInputView.ARG_PROJECT_ID, project.getId());
22-
args.putSerializable(CreditCardInputView.ARG_PAYMENT_TYPE, PaymentMethod.AMEX);
23-
callback.execute(SnabbleUI.Action.SHOW_CREDIT_CARD_INPUT, args);
24-
break;
25-
case MASTERCARD:
26-
args.putString(CreditCardInputView.ARG_PROJECT_ID, project.getId());
27-
args.putSerializable(CreditCardInputView.ARG_PAYMENT_TYPE, PaymentMethod.MASTERCARD);
28-
callback.execute(SnabbleUI.Action.SHOW_CREDIT_CARD_INPUT, args);
29-
break;
30-
case PAYDIREKT:
31-
callback.execute(SnabbleUI.Action.SHOW_PAYDIREKT_INPUT, null);
32-
break;
33-
case DE_DIRECT_DEBIT:
34-
callback.execute(SnabbleUI.Action.SHOW_SEPA_CARD_INPUT, null);
35-
break;
18+
if (KeyguardUtils.isDeviceSecure()) {
19+
Bundle args = new Bundle();
20+
switch (paymentMethod) {
21+
case VISA:
22+
args.putString(CreditCardInputView.ARG_PROJECT_ID, project.getId());
23+
args.putSerializable(CreditCardInputView.ARG_PAYMENT_TYPE, PaymentMethod.VISA);
24+
callback.execute(SnabbleUI.Action.SHOW_CREDIT_CARD_INPUT, args);
25+
break;
26+
case AMEX:
27+
args.putString(CreditCardInputView.ARG_PROJECT_ID, project.getId());
28+
args.putSerializable(CreditCardInputView.ARG_PAYMENT_TYPE, PaymentMethod.AMEX);
29+
callback.execute(SnabbleUI.Action.SHOW_CREDIT_CARD_INPUT, args);
30+
break;
31+
case MASTERCARD:
32+
args.putString(CreditCardInputView.ARG_PROJECT_ID, project.getId());
33+
args.putSerializable(CreditCardInputView.ARG_PAYMENT_TYPE, PaymentMethod.MASTERCARD);
34+
callback.execute(SnabbleUI.Action.SHOW_CREDIT_CARD_INPUT, args);
35+
break;
36+
case PAYDIREKT:
37+
callback.execute(SnabbleUI.Action.SHOW_PAYDIREKT_INPUT, null);
38+
break;
39+
case DE_DIRECT_DEBIT:
40+
callback.execute(SnabbleUI.Action.SHOW_SEPA_CARD_INPUT, null);
41+
break;
42+
}
43+
} else {
44+
new AlertDialog.Builder(context)
45+
.setMessage(R.string.Snabble_Keyguard_requireScreenLock)
46+
.setPositiveButton(R.string.Snabble_OK, null)
47+
.setCancelable(false)
48+
.show();
3649
}
50+
3751
}
3852
}
3953
}

0 commit comments

Comments
 (0)