Propagate another subscription processor error to clients
This commit is contained in:
parent
3548c3df15
commit
bb347999ce
|
@ -285,14 +285,8 @@ public class StripeManager implements SubscriptionProcessorManager {
|
|||
} catch (StripeException e) {
|
||||
|
||||
if (e instanceof CardException ce) {
|
||||
throw new CompletionException(new SubscriptionProcessorException(getProcessor(),
|
||||
new ChargeFailure(
|
||||
StringUtils.defaultIfBlank(ce.getDeclineCode(), ce.getCode()),
|
||||
e.getStripeError().getMessage(),
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)));
|
||||
throw new CompletionException(
|
||||
new SubscriptionProcessorException(getProcessor(), createChargeFailureFromCardException(e, ce)));
|
||||
}
|
||||
|
||||
throw new CompletionException(e);
|
||||
|
@ -337,8 +331,14 @@ public class StripeManager implements SubscriptionProcessorManager {
|
|||
commonOptions(
|
||||
generateIdempotencyKeyForSubscriptionUpdate(subscription.getCustomer(), idempotencyKey)));
|
||||
} catch (StripeException e) {
|
||||
|
||||
if (e instanceof CardException ce) {
|
||||
throw new CompletionException(
|
||||
new SubscriptionProcessorException(getProcessor(), createChargeFailureFromCardException(e, ce)));
|
||||
}
|
||||
throw new CompletionException(e);
|
||||
}
|
||||
|
||||
}, executor)
|
||||
.thenApply(subscription1 -> new SubscriptionId(subscription1.getId()));
|
||||
}
|
||||
|
@ -504,6 +504,16 @@ public class StripeManager implements SubscriptionProcessorManager {
|
|||
outcome != null ? outcome.getType() : null);
|
||||
}
|
||||
|
||||
private static ChargeFailure createChargeFailureFromCardException(StripeException e, CardException ce) {
|
||||
return new ChargeFailure(
|
||||
StringUtils.defaultIfBlank(ce.getDeclineCode(), ce.getCode()),
|
||||
e.getStripeError().getMessage(),
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<SubscriptionInformation> getSubscriptionInformation(Object subscriptionObj) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue