Support iDEAL
This commit is contained in:
parent
33c8bbd0ce
commit
c6b4e2b71d
|
@ -190,10 +190,10 @@ public class SubscriptionController {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// This logic to exclude some iOS client versions from receiving SEPA_DEBIT
|
// This logic to exclude some iOS client versions from receiving SEPA_DEBIT or IDEAL
|
||||||
// as a supported payment method can be removed after 01-23-24.
|
// as a supported payment method can be removed after 01-23-24.
|
||||||
private boolean excludePaymentMethod(@Nullable final UserAgent userAgent, final PaymentMethod paymentMethod) {
|
private boolean excludePaymentMethod(@Nullable final UserAgent userAgent, final PaymentMethod paymentMethod) {
|
||||||
return paymentMethod == PaymentMethod.SEPA_DEBIT
|
return (paymentMethod == PaymentMethod.SEPA_DEBIT || paymentMethod == PaymentMethod.IDEAL)
|
||||||
&& userAgent != null
|
&& userAgent != null
|
||||||
&& userAgent.getPlatform() == ClientPlatform.IOS
|
&& userAgent.getPlatform() == ClientPlatform.IOS
|
||||||
&& userAgent.getVersion().isLowerThanOrEqualTo(LAST_PROBLEMATIC_IOS_VERSION);
|
&& userAgent.getVersion().isLowerThanOrEqualTo(LAST_PROBLEMATIC_IOS_VERSION);
|
||||||
|
@ -392,7 +392,7 @@ public class SubscriptionController {
|
||||||
|
|
||||||
private SubscriptionProcessorManager getManagerForPaymentMethod(PaymentMethod paymentMethod) {
|
private SubscriptionProcessorManager getManagerForPaymentMethod(PaymentMethod paymentMethod) {
|
||||||
return switch (paymentMethod) {
|
return switch (paymentMethod) {
|
||||||
case CARD, SEPA_DEBIT -> stripeManager;
|
case CARD, SEPA_DEBIT, IDEAL -> stripeManager;
|
||||||
case PAYPAL -> braintreeManager;
|
case PAYPAL -> braintreeManager;
|
||||||
case UNKNOWN -> throw new BadRequestException("Invalid payment method");
|
case UNKNOWN -> throw new BadRequestException("Invalid payment method");
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,4 +19,8 @@ public enum PaymentMethod {
|
||||||
* A SEPA debit account
|
* A SEPA debit account
|
||||||
*/
|
*/
|
||||||
SEPA_DEBIT,
|
SEPA_DEBIT,
|
||||||
|
/**
|
||||||
|
* An iDEAL account
|
||||||
|
*/
|
||||||
|
IDEAL,
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,9 @@ public class StripeManager implements SubscriptionProcessorManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsPaymentMethod(PaymentMethod paymentMethod) {
|
public boolean supportsPaymentMethod(PaymentMethod paymentMethod) {
|
||||||
return paymentMethod == PaymentMethod.CARD || paymentMethod == PaymentMethod.SEPA_DEBIT;
|
return paymentMethod == PaymentMethod.CARD
|
||||||
|
|| paymentMethod == PaymentMethod.SEPA_DEBIT
|
||||||
|
|| paymentMethod == PaymentMethod.IDEAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
private RequestOptions commonOptions() {
|
private RequestOptions commonOptions() {
|
||||||
|
|
|
@ -132,6 +132,8 @@ class SubscriptionControllerTest {
|
||||||
.thenReturn(Set.of("usd", "jpy", "bif", "eur"));
|
.thenReturn(Set.of("usd", "jpy", "bif", "eur"));
|
||||||
when(STRIPE_MANAGER.getSupportedCurrenciesForPaymentMethod(PaymentMethod.SEPA_DEBIT))
|
when(STRIPE_MANAGER.getSupportedCurrenciesForPaymentMethod(PaymentMethod.SEPA_DEBIT))
|
||||||
.thenReturn(Set.of("eur"));
|
.thenReturn(Set.of("eur"));
|
||||||
|
when(STRIPE_MANAGER.getSupportedCurrenciesForPaymentMethod(PaymentMethod.IDEAL))
|
||||||
|
.thenReturn(Set.of("eur"));
|
||||||
when(BRAINTREE_MANAGER.getSupportedCurrenciesForPaymentMethod(PaymentMethod.PAYPAL))
|
when(BRAINTREE_MANAGER.getSupportedCurrenciesForPaymentMethod(PaymentMethod.PAYPAL))
|
||||||
.thenReturn(Set.of("usd", "jpy"));
|
.thenReturn(Set.of("usd", "jpy"));
|
||||||
}
|
}
|
||||||
|
@ -733,7 +735,7 @@ class SubscriptionControllerTest {
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource
|
@MethodSource
|
||||||
void getSubscriptionConfiguration(final String userAgent, final boolean expectSepa) {
|
void getSubscriptionConfiguration(final String userAgent, final boolean expectNonCardPaymentMethods) {
|
||||||
when(BADGE_TRANSLATOR.translate(any(), eq("B1"))).thenReturn(new Badge("B1", "cat1", "name1", "desc1",
|
when(BADGE_TRANSLATOR.translate(any(), eq("B1"))).thenReturn(new Badge("B1", "cat1", "name1", "desc1",
|
||||||
List.of("l", "m", "h", "x", "xx", "xxx"), "SVG",
|
List.of("l", "m", "h", "x", "xx", "xxx"), "SVG",
|
||||||
List.of(new BadgeSvg("sl", "sd"), new BadgeSvg("ml", "md"), new BadgeSvg("ll", "ld"))));
|
List.of(new BadgeSvg("sl", "sd"), new BadgeSvg("ml", "md"), new BadgeSvg("ll", "ld"))));
|
||||||
|
@ -811,7 +813,7 @@ class SubscriptionControllerTest {
|
||||||
List.of(BigDecimal.valueOf(5))));
|
List.of(BigDecimal.valueOf(5))));
|
||||||
assertThat(currency.subscription()).isEqualTo(
|
assertThat(currency.subscription()).isEqualTo(
|
||||||
Map.of("5", BigDecimal.valueOf(5), "15", BigDecimal.valueOf(15),"35", BigDecimal.valueOf(35)));
|
Map.of("5", BigDecimal.valueOf(5), "15", BigDecimal.valueOf(15),"35", BigDecimal.valueOf(35)));
|
||||||
final List<String> expectedPaymentMethods = expectSepa ? List.of("CARD", "SEPA_DEBIT") : List.of("CARD");
|
final List<String> expectedPaymentMethods = expectNonCardPaymentMethods ? List.of("CARD", "SEPA_DEBIT", "IDEAL") : List.of("CARD");
|
||||||
assertThat(currency.supportedPaymentMethods()).isEqualTo(expectedPaymentMethods);
|
assertThat(currency.supportedPaymentMethods()).isEqualTo(expectedPaymentMethods);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue