Set boost description from configuration
This commit is contained in:
parent
71b38356b1
commit
7ea43a728d
|
@ -423,7 +423,7 @@ public class WhisperServerService extends Application<WhisperServerConfiguration
|
||||||
build();
|
build();
|
||||||
|
|
||||||
StripeManager stripeManager = new StripeManager(config.getStripe().getApiKey(), stripeExecutor,
|
StripeManager stripeManager = new StripeManager(config.getStripe().getApiKey(), stripeExecutor,
|
||||||
config.getStripe().getIdempotencyKeyGenerator());
|
config.getStripe().getIdempotencyKeyGenerator(), config.getStripe().getBoostDescription());
|
||||||
|
|
||||||
ExternalServiceCredentialGenerator directoryCredentialsGenerator = new ExternalServiceCredentialGenerator(
|
ExternalServiceCredentialGenerator directoryCredentialsGenerator = new ExternalServiceCredentialGenerator(
|
||||||
config.getDirectoryConfiguration().getDirectoryClientConfiguration().getUserAuthenticationTokenSharedSecret(),
|
config.getDirectoryConfiguration().getDirectoryClientConfiguration().getUserAuthenticationTokenSharedSecret(),
|
||||||
|
|
|
@ -13,13 +13,16 @@ public class StripeConfiguration {
|
||||||
|
|
||||||
private final String apiKey;
|
private final String apiKey;
|
||||||
private final byte[] idempotencyKeyGenerator;
|
private final byte[] idempotencyKeyGenerator;
|
||||||
|
private final String boostDescription;
|
||||||
|
|
||||||
@JsonCreator
|
@JsonCreator
|
||||||
public StripeConfiguration(
|
public StripeConfiguration(
|
||||||
@JsonProperty("apiKey") final String apiKey,
|
@JsonProperty("apiKey") final String apiKey,
|
||||||
@JsonProperty("idempotencyKeyGenerator") final byte[] idempotencyKeyGenerator) {
|
@JsonProperty("idempotencyKeyGenerator") final byte[] idempotencyKeyGenerator,
|
||||||
|
@JsonProperty("boostDescription") final String boostDescription) {
|
||||||
this.apiKey = apiKey;
|
this.apiKey = apiKey;
|
||||||
this.idempotencyKeyGenerator = idempotencyKeyGenerator;
|
this.idempotencyKeyGenerator = idempotencyKeyGenerator;
|
||||||
|
this.boostDescription = boostDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
|
@ -31,4 +34,9 @@ public class StripeConfiguration {
|
||||||
public byte[] getIdempotencyKeyGenerator() {
|
public byte[] getIdempotencyKeyGenerator() {
|
||||||
return idempotencyKeyGenerator;
|
return idempotencyKeyGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotEmpty
|
||||||
|
public String getBoostDescription() {
|
||||||
|
return boostDescription;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,11 +62,13 @@ public class StripeManager {
|
||||||
private final String apiKey;
|
private final String apiKey;
|
||||||
private final Executor executor;
|
private final Executor executor;
|
||||||
private final byte[] idempotencyKeyGenerator;
|
private final byte[] idempotencyKeyGenerator;
|
||||||
|
private final String boostDescription;
|
||||||
|
|
||||||
public StripeManager(
|
public StripeManager(
|
||||||
@Nonnull String apiKey,
|
@Nonnull String apiKey,
|
||||||
@Nonnull Executor executor,
|
@Nonnull Executor executor,
|
||||||
@Nonnull byte[] idempotencyKeyGenerator) {
|
@Nonnull byte[] idempotencyKeyGenerator,
|
||||||
|
@Nonnull String boostDescription) {
|
||||||
this.apiKey = Objects.requireNonNull(apiKey);
|
this.apiKey = Objects.requireNonNull(apiKey);
|
||||||
if (Strings.isNullOrEmpty(apiKey)) {
|
if (Strings.isNullOrEmpty(apiKey)) {
|
||||||
throw new IllegalArgumentException("apiKey cannot be empty");
|
throw new IllegalArgumentException("apiKey cannot be empty");
|
||||||
|
@ -76,6 +78,7 @@ public class StripeManager {
|
||||||
if (idempotencyKeyGenerator.length == 0) {
|
if (idempotencyKeyGenerator.length == 0) {
|
||||||
throw new IllegalArgumentException("idempotencyKeyGenerator cannot be empty");
|
throw new IllegalArgumentException("idempotencyKeyGenerator cannot be empty");
|
||||||
}
|
}
|
||||||
|
this.boostDescription = Objects.requireNonNull(boostDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
private RequestOptions commonOptions() {
|
private RequestOptions commonOptions() {
|
||||||
|
@ -148,6 +151,7 @@ public class StripeManager {
|
||||||
PaymentIntentCreateParams params = PaymentIntentCreateParams.builder()
|
PaymentIntentCreateParams params = PaymentIntentCreateParams.builder()
|
||||||
.setAmount(amount)
|
.setAmount(amount)
|
||||||
.setCurrency(currency.toLowerCase(Locale.ROOT))
|
.setCurrency(currency.toLowerCase(Locale.ROOT))
|
||||||
|
.setDescription(boostDescription)
|
||||||
.build();
|
.build();
|
||||||
try {
|
try {
|
||||||
return PaymentIntent.create(params, commonOptions());
|
return PaymentIntent.create(params, commonOptions());
|
||||||
|
|
|
@ -85,7 +85,7 @@ class DonationControllerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
static StripeConfiguration getStripeConfiguration() {
|
static StripeConfiguration getStripeConfiguration() {
|
||||||
return new StripeConfiguration("test-api-key", new byte[16]);
|
return new StripeConfiguration("test-api-key", new byte[16], "Boost Description String");
|
||||||
}
|
}
|
||||||
|
|
||||||
static BadgesConfiguration getBadgesConfiguration() {
|
static BadgesConfiguration getBadgesConfiguration() {
|
||||||
|
|
Loading…
Reference in New Issue