Skip to content

Commit 97084e4

Browse files
authored
Remove customer card as payment method (#165)
Removed `LEINWEBER_CUSTOMER_ID` as payment method, since it is obsolete. Change `Paymentcredentials.Type` to be nullable, so that outdated payment methods can be cleaned up properly.
1 parent a5b3547 commit 97084e4

File tree

12 files changed

+25
-98
lines changed

12 files changed

+25
-98
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ All notable changes to this project will be documented in this file.
1919
* PaydirektAuthorizationData changed to GiropayAuthorizationData and is now a data class
2020
* PaydirektData changed to GiropayData and is now a data class
2121
* The UI event for paydirekt changed from SHOW_PAYDIREKT_INPUT to SHOW_GIROPAY_INPUT
22-
* ### Fixed
22+
* core: Paymentcredentials type is now nullable
23+
### Fixed
2324
* ui: Fixed crash caused by missing project id when calling the PaydirektInputFragment via the PaymentInputViewHelper
2425
* ui: Fixed crash caused by npe in the PaymentStatusView
26+
### Removed
27+
* core/ui: Removed LEINWEBER_CUSTOMER_ID as payment methods
2528

2629
## [0.71.8]
2730
### Changed

core/src/main/java/io/snabble/sdk/PaymentMethod.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,6 @@ enum class PaymentMethod(
9696
needsAbortConfirmation = true
9797
),
9898

99-
@SerializedName("externalBilling")
100-
LEINWEBER_CUSTOMER_ID(
101-
id = "externalBilling",
102-
isOfflineMethod = false,
103-
isRequiringCredentials = true,
104-
isShowOnlyIfCredentialsArePresent = true,
105-
needsAbortConfirmation = true
106-
),
107-
10899
@SerializedName("customerCardPOS")
109100
CUSTOMERCARD_POS(
110101
id = "customerCardPOS",
@@ -204,7 +195,6 @@ enum class PaymentMethod(
204195
if (pm.id == id && pm.id == TEGUT_EMPLOYEE_CARD.id) {
205196
when (origin[0]) {
206197
"tegutEmployeeID" -> return TEGUT_EMPLOYEE_CARD
207-
"leinweberCustomerID" -> return LEINWEBER_CUSTOMER_ID
208198
"contactPersonCredentials" -> return EXTERNAL_BILLING
209199
}
210200
} else if (pm.id == id && pm.id == PAYONE_SEPA.id) {

core/src/main/java/io/snabble/sdk/checkout/DefaultCheckoutApi.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,22 +215,22 @@ class DefaultCheckoutApi(private val project: Project,
215215
paymentInformation = when (paymentCredentials?.type) {
216216
PaymentCredentials.Type.EXTERNAL_BILLING -> {
217217
PaymentInformation(
218-
originType = paymentCredentials.type.originType,
218+
originType = paymentCredentials.type?.originType,
219219
encryptedOrigin = paymentCredentials.encryptedData,
220220
subject = paymentCredentials.additionalData["subject"]
221221
)
222222
}
223223
PaymentCredentials.Type.CREDIT_CARD_PSD2 -> {
224224
PaymentInformation(
225-
originType = paymentCredentials.type.originType,
225+
originType = paymentCredentials.type?.originType,
226226
encryptedOrigin = paymentCredentials.encryptedData,
227227
validUntil = SimpleDateFormat("yyyy/MM/dd").format(Date(paymentCredentials.validTo)),
228228
cardNumber = paymentCredentials.obfuscatedId,
229229
)
230230
}
231231
PaymentCredentials.Type.GIROPAY -> {
232232
PaymentInformation(
233-
originType = paymentCredentials.type.originType,
233+
originType = paymentCredentials.type?.originType,
234234
encryptedOrigin = paymentCredentials.encryptedData,
235235
deviceID = paymentCredentials.additionalData["deviceID"],
236236
deviceName = paymentCredentials.additionalData["deviceName"],
@@ -241,7 +241,7 @@ class DefaultCheckoutApi(private val project: Project,
241241
null -> null
242242
else -> {
243243
PaymentInformation(
244-
originType = paymentCredentials.type.originType,
244+
originType = paymentCredentials.type?.originType,
245245
encryptedOrigin = paymentCredentials.encryptedData
246246
)
247247
}

core/src/main/java/io/snabble/sdk/payment/PaymentCredentials.java

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ public enum Type {
6161
CREDIT_CARD_PSD2(null, true, Arrays.asList(PaymentMethod.VISA, PaymentMethod.MASTERCARD, PaymentMethod.AMEX)),
6262
GIROPAY(null, false, Collections.singletonList(PaymentMethod.GIROPAY)),
6363
TEGUT_EMPLOYEE_CARD("tegutEmployeeID", false, Collections.singletonList(PaymentMethod.TEGUT_EMPLOYEE_CARD)),
64-
LEINWEBER_CUSTOMER_ID("leinweberCustomerID", false, Collections.singletonList(PaymentMethod.LEINWEBER_CUSTOMER_ID)),
6564
DATATRANS("datatransAlias", true, Arrays.asList(PaymentMethod.TWINT, PaymentMethod.POST_FINANCE_CARD)),
6665
DATATRANS_CREDITCARD("datatransCreditCardAlias", true, Arrays.asList(PaymentMethod.VISA, PaymentMethod.MASTERCARD, PaymentMethod.AMEX)),
6766
PAYONE_CREDITCARD(null, true, Arrays.asList(PaymentMethod.VISA, PaymentMethod.MASTERCARD, PaymentMethod.AMEX)),
@@ -170,10 +169,6 @@ private static class TegutEmployeeCard {
170169
private String cardNumber;
171170
}
172171

173-
private static class LeinweberCustomerId {
174-
private String cardNumber;
175-
}
176-
177172
private String obfuscatedId;
178173
// comes from previously saved data on deserialization - was used in encrypt() from old code
179174
private boolean isKeyStoreEncrypted;
@@ -559,52 +554,11 @@ public static PaymentCredentials fromTegutEmployeeCard(String obfuscatedId, Stri
559554
return pc;
560555
}
561556

562-
/**
563-
* Encrypts and stores a leinweber customer id.
564-
*/
565-
public static PaymentCredentials fromLeinweberCustomerId(String obfuscatedId, String cardNumber, String projectId) {
566-
if (cardNumber == null || cardNumber.length() != 6) {
567-
return null;
568-
}
569-
570-
PaymentCredentials pc = new PaymentCredentials();
571-
pc.generateId();
572-
pc.type = Type.LEINWEBER_CUSTOMER_ID;
573-
574-
List<X509Certificate> certificates = Snabble.getInstance().getPaymentCertificates();
575-
if (certificates.size() == 0) {
576-
return null;
577-
}
578-
579-
pc.obfuscatedId = obfuscatedId;
580-
581-
X509Certificate certificate = certificates.get(0);
582-
583-
LeinweberCustomerId data = new LeinweberCustomerId();
584-
data.cardNumber = cardNumber;
585-
String json = GsonHolder.get().toJson(data, LeinweberCustomerId.class);
586-
587-
pc.rsaEncryptedData = pc.rsaEncrypt(certificate, json.getBytes());
588-
pc.signature = pc.sha256Signature(certificate);
589-
pc.brand = Brand.UNKNOWN;
590-
pc.appId = Snabble.getInstance().getConfig().appId;
591-
pc.projectId = projectId;
592-
593-
if (pc.rsaEncryptedData == null) {
594-
return null;
595-
}
596-
597-
return pc;
598-
}
599-
600557
/**
601558
* Returns the type of the payment credentials
602559
*/
560+
@Nullable
603561
public Type getType() {
604-
if (type == null) { // backwards compatibility
605-
return Type.SEPA;
606-
}
607-
608562
return type;
609563
}
610564

@@ -892,8 +846,6 @@ public PaymentMethod getPaymentMethod() {
892846
return PaymentMethod.PAYONE_SEPA;
893847
} else if (type == Type.TEGUT_EMPLOYEE_CARD) {
894848
return PaymentMethod.TEGUT_EMPLOYEE_CARD;
895-
} else if (type == Type.LEINWEBER_CUSTOMER_ID) {
896-
return PaymentMethod.LEINWEBER_CUSTOMER_ID;
897849
} else if (type == Type.GIROPAY) {
898850
return PaymentMethod.GIROPAY;
899851
} else if (type == Type.EXTERNAL_BILLING) {

core/src/main/java/io/snabble/sdk/payment/PaymentCredentialsStore.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.util.HashSet;
1616
import java.util.List;
1717
import java.util.concurrent.CopyOnWriteArrayList;
18+
import java.util.stream.Collectors;
1819

1920
import io.snabble.sdk.Environment;
2021
import io.snabble.sdk.PaymentMethod;
@@ -260,6 +261,11 @@ private synchronized void load() {
260261
if (json != null) {
261262
try {
262263
data = gson.fromJson(json, Data.class);
264+
// Filter only known types
265+
data.credentialsList = data.credentialsList.stream()
266+
.filter(paymentCredentials -> paymentCredentials.getType() != null)
267+
.collect(Collectors.toList());
268+
save();
263269
} catch (Exception e) {
264270
Logger.errorEvent("Could not read payment credentials: %s", e.getMessage());
265271
}
@@ -418,4 +424,4 @@ public void addCallback(Callback cb) {
418424
public void removeCallback(Callback cb) {
419425
callbacks.remove(cb);
420426
}
421-
}
427+
}

ui/src/main/java/io/snabble/sdk/ui/payment/PaymentMethodIcons.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ val PaymentMethodDescriptor.icon: Int
2121
PaymentMethod.GOOGLE_PAY.id -> R.drawable.snabble_ic_payment_select_gpay
2222
"externalBilling" -> when (acceptedOriginTypes?.first()) {
2323
"tegutEmployeeID" -> R.drawable.snabble_ic_payment_select_tegut
24-
"leinweberCustomerID" -> R.drawable.snabble_ic_payment_select_leinweber
2524
"contactPersonCredentials" -> R.drawable.ic_snabble_external_billing
2625
else -> 0
2726
}

ui/src/main/java/io/snabble/sdk/ui/payment/PaymentMethodMetaData.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ import io.snabble.sdk.PaymentMethod.CUSTOMERCARD_POS
88
import io.snabble.sdk.PaymentMethod.DE_DIRECT_DEBIT
99
import io.snabble.sdk.PaymentMethod.EXTERNAL_BILLING
1010
import io.snabble.sdk.PaymentMethod.GATEKEEPER_TERMINAL
11+
import io.snabble.sdk.PaymentMethod.GIROPAY
1112
import io.snabble.sdk.PaymentMethod.GOOGLE_PAY
12-
import io.snabble.sdk.PaymentMethod.LEINWEBER_CUSTOMER_ID
1313
import io.snabble.sdk.PaymentMethod.MASTERCARD
14-
import io.snabble.sdk.PaymentMethod.GIROPAY
1514
import io.snabble.sdk.PaymentMethod.PAYONE_SEPA
1615
import io.snabble.sdk.PaymentMethod.POST_FINANCE_CARD
1716
import io.snabble.sdk.PaymentMethod.QRCODE_OFFLINE
@@ -23,7 +22,6 @@ import io.snabble.sdk.ui.R.drawable.ic_snabble_external_billing
2322
import io.snabble.sdk.ui.R.drawable.snabble_ic_payment_giropay
2423
import io.snabble.sdk.ui.R.drawable.snabble_ic_payment_select_amex
2524
import io.snabble.sdk.ui.R.drawable.snabble_ic_payment_select_gpay
26-
import io.snabble.sdk.ui.R.drawable.snabble_ic_payment_select_leinweber
2725
import io.snabble.sdk.ui.R.drawable.snabble_ic_payment_select_mastercard
2826
import io.snabble.sdk.ui.R.drawable.snabble_ic_payment_select_pos
2927
import io.snabble.sdk.ui.R.drawable.snabble_ic_payment_select_postfinance
@@ -54,7 +52,6 @@ class PaymentMethodMetaDataHelper(
5452
GATEKEEPER_TERMINAL withMeta (Snabble_Payment_payAtSCO.resolved to snabble_ic_payment_select_sco),
5553
EXTERNAL_BILLING withMeta (Snabble_Payment_ExternalBilling_title.resolved to ic_snabble_external_billing),
5654
TEGUT_EMPLOYEE_CARD withMeta ("Tegut... Mitarbeiterkarte" to snabble_ic_payment_select_tegut),
57-
LEINWEBER_CUSTOMER_ID withMeta ("Leinweber Rechnungskauf" to snabble_ic_payment_select_leinweber),
5855
CUSTOMERCARD_POS withMeta (Snabble_Payment_payAtCashDesk.resolved to snabble_ic_payment_select_pos),
5956
QRCODE_POS withMeta (Snabble_Payment_payAtCashDesk.resolved to snabble_ic_payment_select_pos),
6057
QRCODE_OFFLINE withMeta (Snabble_Payment_payAtCashDesk.resolved to snabble_ic_payment_select_pos),

ui/src/main/java/io/snabble/sdk/ui/payment/PayoneInputView.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ class PayoneInputView @JvmOverloads constructor(context: Context, attrs: Attribu
299299
.show()
300300
} else {
301301
Snabble.paymentCredentialsStore.add(pc)
302-
Telemetry.event(Telemetry.Event.PaymentMethodAdded, pc.type.name)
302+
Telemetry.event(Telemetry.Event.PaymentMethodAdded, pc.type?.name)
303303
}
304304
finish()
305305
}

ui/src/main/java/io/snabble/sdk/ui/payment/externalbilling/viewmodel/ExternalBillingViewModel.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ class ExternalBillingViewModel : ViewModel() {
4040
"$idDescriptor: $username",
4141
)
4242
val success = repo.addPaymentCredentials(paymentCredentials)
43-
if (success && paymentCredentials != null) {
44-
trackCredentialType(paymentCredentials.type.name)
43+
val type = paymentCredentials?.type
44+
if (success && type != null) {
45+
trackCredentialType(type.name)
4546
}
4647
}
4748
_uiState.tryEmit(Success)

ui/src/main/java/io/snabble/sdk/ui/payment/payone/sepa/form/domain/PayoneSepaFormRepository.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ class PayoneSepaFormRepositoryImpl(
2121
val paymentCredentials = PaymentCredentials.fromPayoneSepa(data) ?: return false
2222

2323
snabble.paymentCredentialsStore.add(paymentCredentials)
24-
trackCredentialType(paymentCredentials.type.name)
24+
val type = paymentCredentials.type
25+
if (type != null) {
26+
trackCredentialType(type.name)
27+
}
2528
return true
2629
}
2730

0 commit comments

Comments
 (0)