mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 21:18:08 +01:00
Support SEPA
This commit is contained in:
@@ -55,13 +55,13 @@ public class BraintreeManager implements SubscriptionProcessorManager {
|
||||
private final BraintreeGateway braintreeGateway;
|
||||
private final BraintreeGraphqlClient braintreeGraphqlClient;
|
||||
private final Executor executor;
|
||||
private final Set<String> supportedCurrencies;
|
||||
private final Map<PaymentMethod, Set<String>> supportedCurrenciesByPaymentMethod;
|
||||
private final Map<String, String> currenciesToMerchantAccounts;
|
||||
|
||||
public BraintreeManager(final String braintreeMerchantId, final String braintreePublicKey,
|
||||
final String braintreePrivateKey,
|
||||
final String braintreeEnvironment,
|
||||
final Set<String> supportedCurrencies,
|
||||
final Map<PaymentMethod, Set<String>> supportedCurrenciesByPaymentMethod,
|
||||
final Map<String, String> currenciesToMerchantAccounts,
|
||||
final String graphqlUri,
|
||||
final CircuitBreakerConfiguration circuitBreakerConfiguration,
|
||||
@@ -70,7 +70,7 @@ public class BraintreeManager implements SubscriptionProcessorManager {
|
||||
|
||||
this(new BraintreeGateway(braintreeEnvironment, braintreeMerchantId, braintreePublicKey,
|
||||
braintreePrivateKey),
|
||||
supportedCurrencies,
|
||||
supportedCurrenciesByPaymentMethod,
|
||||
currenciesToMerchantAccounts,
|
||||
new BraintreeGraphqlClient(FaultTolerantHttpClient.newBuilder()
|
||||
.withName("braintree-graphql")
|
||||
@@ -86,19 +86,20 @@ public class BraintreeManager implements SubscriptionProcessorManager {
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
BraintreeManager(final BraintreeGateway braintreeGateway, final Set<String> supportedCurrencies,
|
||||
BraintreeManager(final BraintreeGateway braintreeGateway,
|
||||
final Map<PaymentMethod, Set<String>> supportedCurrenciesByPaymentMethod,
|
||||
final Map<String, String> currenciesToMerchantAccounts, final BraintreeGraphqlClient braintreeGraphqlClient,
|
||||
final Executor executor) {
|
||||
this.braintreeGateway = braintreeGateway;
|
||||
this.supportedCurrencies = supportedCurrencies;
|
||||
this.supportedCurrenciesByPaymentMethod = supportedCurrenciesByPaymentMethod;
|
||||
this.currenciesToMerchantAccounts = currenciesToMerchantAccounts;
|
||||
this.braintreeGraphqlClient = braintreeGraphqlClient;
|
||||
this.executor = executor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getSupportedCurrencies() {
|
||||
return supportedCurrencies;
|
||||
public Set<String> getSupportedCurrenciesForPaymentMethod(final PaymentMethod paymentMethod) {
|
||||
return supportedCurrenciesByPaymentMethod.getOrDefault(paymentMethod, Collections.emptySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,11 +112,6 @@ public class BraintreeManager implements SubscriptionProcessorManager {
|
||||
return paymentMethod == PaymentMethod.PAYPAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsCurrency(final String currency) {
|
||||
return supportedCurrencies.contains(currency.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<PaymentDetails> getPaymentDetails(final String paymentId) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
|
||||
@@ -14,4 +14,8 @@ public enum PaymentMethod {
|
||||
* A PayPal account
|
||||
*/
|
||||
PAYPAL,
|
||||
/**
|
||||
* A SEPA debit account
|
||||
*/
|
||||
SEPA_DEBIT,
|
||||
}
|
||||
|
||||
@@ -77,14 +77,14 @@ public class StripeManager implements SubscriptionProcessorManager {
|
||||
private final Executor executor;
|
||||
private final byte[] idempotencyKeyGenerator;
|
||||
private final String boostDescription;
|
||||
private final Set<String> supportedCurrencies;
|
||||
private final Map<PaymentMethod, Set<String>> supportedCurrenciesByPaymentMethod;
|
||||
|
||||
public StripeManager(
|
||||
@Nonnull String apiKey,
|
||||
@Nonnull Executor executor,
|
||||
@Nonnull byte[] idempotencyKeyGenerator,
|
||||
@Nonnull String boostDescription,
|
||||
@Nonnull Set<String> supportedCurrencies) {
|
||||
@Nonnull Map<PaymentMethod, Set<String>> supportedCurrenciesByPaymentMethod) {
|
||||
if (Strings.isNullOrEmpty(apiKey)) {
|
||||
throw new IllegalArgumentException("apiKey cannot be empty");
|
||||
}
|
||||
@@ -95,7 +95,7 @@ public class StripeManager implements SubscriptionProcessorManager {
|
||||
throw new IllegalArgumentException("idempotencyKeyGenerator cannot be empty");
|
||||
}
|
||||
this.boostDescription = Objects.requireNonNull(boostDescription);
|
||||
this.supportedCurrencies = supportedCurrencies;
|
||||
this.supportedCurrenciesByPaymentMethod = supportedCurrenciesByPaymentMethod;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,12 +105,7 @@ public class StripeManager implements SubscriptionProcessorManager {
|
||||
|
||||
@Override
|
||||
public boolean supportsPaymentMethod(PaymentMethod paymentMethod) {
|
||||
return paymentMethod == PaymentMethod.CARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsCurrency(final String currency) {
|
||||
return supportedCurrencies.contains(currency);
|
||||
return paymentMethod == PaymentMethod.CARD || paymentMethod == PaymentMethod.SEPA_DEBIT;
|
||||
}
|
||||
|
||||
private RequestOptions commonOptions() {
|
||||
@@ -184,8 +179,8 @@ public class StripeManager implements SubscriptionProcessorManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getSupportedCurrencies() {
|
||||
return supportedCurrencies;
|
||||
public Set<String> getSupportedCurrenciesForPaymentMethod(final PaymentMethod paymentMethod) {
|
||||
return supportedCurrenciesByPaymentMethod.getOrDefault(paymentMethod, Collections.emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,9 +19,7 @@ public interface SubscriptionProcessorManager {
|
||||
|
||||
boolean supportsPaymentMethod(PaymentMethod paymentMethod);
|
||||
|
||||
boolean supportsCurrency(String currency);
|
||||
|
||||
Set<String> getSupportedCurrencies();
|
||||
Set<String> getSupportedCurrenciesForPaymentMethod(PaymentMethod paymentMethod);
|
||||
|
||||
CompletableFuture<PaymentDetails> getPaymentDetails(String paymentId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user