I'm having some issues for adding an amount fee on a subscription on Stripe. Looking at this documentation I should be able to add a connected account when creating the subscription so i can set an application fee on the subscription without having to do any modification on it afterwards.
I'm trying to use a RequestOptions on the subscription creation to add the connected stripe account but it seems that if i use it it's redirecting to the live account and it's not finding the customer i'm using making the request to fail.
Here is the code of the whole process:
attachPayMethodToCustomer(bookingDetails.getPaymentMethod(), user.getCustomerId());
Price price = getPriceForItem(item, bookingDetails.isExclusive());
SubscriptionCreateParams.Item item = SubscriptionCreateParams.Item.builder()
.setQuantity(1L)
.setPrice(price.getId())
.build();
BigDecimal bd = new BigDecimal(calculateSubscriptionFee(price.getUnitAmount() / 100, bookingDetails.isRecorded()), new MathContext(2, RoundingMode.HALF_UP));
SubscriptionCreateParams.Builder params = SubscriptionCreateParams.builder()
.setCustomer(user.getCustomerId())
.setApplicationFeePercent(bd)
.addItem(item);
if (bookingDetails.hasExtras()) {
Price recordPrice = getExtrasPrice(seller().getCurrency());
SubscriptionCreateParams.Item extraItem = SubscriptionCreateParams.Item.builder()
.setQuantity(1L)
.setPrice(extraPrice.getId())
.build();
params.addItem(extraItem);
}
RequestOptions ro = new RequestOptions.RequestOptionsBuilder()
.setStripeAccount(seller.getStripeAccountId())
.build();
Subscription subscription = Subscription.create(params.build(), ro);
I'm receiving this exception when it tries to create the subscription:
com.stripe.exception.InvalidRequestException: No such customer: 'cus_IaFZjrBAlBsXXX'; code: resource_missing; request-id: req_C67JN4tgneXXXX but i can see the customer on the dashboard. I tried also to override the stripe api key to use the test one, but i have the same issue.
Thanks a lot, Adrián