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) {
|
} catch (StripeException e) {
|
||||||
|
|
||||||
if (e instanceof CardException ce) {
|
if (e instanceof CardException ce) {
|
||||||
throw new CompletionException(new SubscriptionProcessorException(getProcessor(),
|
throw new CompletionException(
|
||||||
new ChargeFailure(
|
new SubscriptionProcessorException(getProcessor(), createChargeFailureFromCardException(e, ce)));
|
||||||
StringUtils.defaultIfBlank(ce.getDeclineCode(), ce.getCode()),
|
|
||||||
e.getStripeError().getMessage(),
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null
|
|
||||||
)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new CompletionException(e);
|
throw new CompletionException(e);
|
||||||
|
@ -337,8 +331,14 @@ public class StripeManager implements SubscriptionProcessorManager {
|
||||||
commonOptions(
|
commonOptions(
|
||||||
generateIdempotencyKeyForSubscriptionUpdate(subscription.getCustomer(), idempotencyKey)));
|
generateIdempotencyKeyForSubscriptionUpdate(subscription.getCustomer(), idempotencyKey)));
|
||||||
} catch (StripeException e) {
|
} catch (StripeException e) {
|
||||||
|
|
||||||
|
if (e instanceof CardException ce) {
|
||||||
|
throw new CompletionException(
|
||||||
|
new SubscriptionProcessorException(getProcessor(), createChargeFailureFromCardException(e, ce)));
|
||||||
|
}
|
||||||
throw new CompletionException(e);
|
throw new CompletionException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, executor)
|
}, executor)
|
||||||
.thenApply(subscription1 -> new SubscriptionId(subscription1.getId()));
|
.thenApply(subscription1 -> new SubscriptionId(subscription1.getId()));
|
||||||
}
|
}
|
||||||
|
@ -504,6 +504,16 @@ public class StripeManager implements SubscriptionProcessorManager {
|
||||||
outcome != null ? outcome.getType() : null);
|
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
|
@Override
|
||||||
public CompletableFuture<SubscriptionInformation> getSubscriptionInformation(Object subscriptionObj) {
|
public CompletableFuture<SubscriptionInformation> getSubscriptionInformation(Object subscriptionObj) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue