#Manu-Java-Sub
1 messages · Page 1 of 1 (latest)
Hi there! Give me a moment to take a look
Have you tried breaking this up?
Like are you able to retrieve just the invoice?
What Java version and Stripe API version are you using?
Can you provide me the Subscription ID for the above?
Thanks, looking!
Ah okay
Interesting
Sorry, still verifying.
You are using licensed usage
And there is no initial invoice
I believe this is expected
But I haven't played with licensed usage in quite a while
So looking to verify
Thank you! We took a look at the documentation, which sets the subscriptions payment behaviour as DEFAULT_INCOMPLETE.
But we only have ALLOW_INCOMPLETE, ERROR_IF_INCOMPLETE and PENDING_IF_INCOMPLETE available.
Yes but with licensed usage there will be no initial charge, as the amount is determined during the billing cycle.
So the Subscription will always become active immediately.
I see. How would I be able to get to the invoice? Because I can't activate the subscription before it's been paid.
What is your model? Are you sure you want to be using a licensed type of pricing?
Do you want to charge the customer immediately when they activate the Subscription?
We sell software licenses, a per-seat subscription model.
And do you know that per-seat amount upon the start of the Sub?
We describe a per-seat model in our docs here: https://stripe.com/docs/products-prices/pricing-models#per-seat
You may want to take a peak at that if you haven't seen it.
We get the priceId and amount from the Front-end before creating the Sub.
Okay so you do know how many seats your customer wants up front.
In that case you don't want to use licensed usage.
You would just use a "Standard pricing" model here where you then charge a quantity equal to the amount of seats you want to provide.
This will then generate an initial invoice when you create the Subscription
And default_incomplete will come into play here
All you need to really change is the price ID that you are using
So create a new product/price via either the Dashboard or the API
That uses "Standard pricing"
https://dashboard.stripe.com/test/products/prod_LA0U2elrRViesV
We already created two products with 2 prices each that use standard pricing
which is the price we are passing to stripe at the moment
Okay I looked again and I missed that you were setting billing_cycle_anchor to the future
My bad!
The business logic dictates that the billing_cycle be at the 5th of every month
Yes but you are setting proration_behavior: none this means that no invoice is generated. We describe this behavior in the docs here: https://stripe.com/docs/billing/subscriptions/billing-cycle#new-subscriptions
That is why no invoice is created.
So there are a couple ways to work around this.
You don't want to charge the customer for the amount of time from when the Sub is created until the 5th of the month, correct?
That would be the easiest way... but can lead to some small prorated invoices
I need to charge the difference up to the next months fifth. If a customer buys a subscription on the 20th I need to be able to charge the difference between the 20th and the 5th of next month, and then charge him the price for the entire billing cycle from 5th to 5th the following month.
Oh that is easy then... just remove your proration_behavior parameter!
As the default will be to create prorations here, which will generate an invoice for the prorated amount until the 5th of next month
Will that invoice be generated at the same time as the subscription? Or on the 5th of next month?
At the time of creation
Well now that just might solve everything.
Let me try and get back to you ASAP, thank you so much!
Reopened!
After removing the proration behavior I get the following error:
com.stripe.exception.InvalidRequestException: This customer has no attached payment source or default payment method.; code: resource_missing; request-id: req_BN7aDCLUPRbxnQ
Thanks!
Don't I need the clientSecret to pass to my payment-element on the FE and save the default payment method after the first payment has been made?
Ah! So here, at the subscrion create, you'd want to set payment_behavior to allow_incomplete: https://stripe.com/docs/api/subscriptions/create#create_subscription-payment_behavior. This way even if the customer does not have a default payment method, you'd see the first invoice even if ir cannot be paid.
Sorry, default_incomplete instead.
Let me test this out on my end real quick. In the meantine, can you share the request id for this error?
Thank you, please give me some time
Absolutely, appreciate it!
I was able to test this on my test account and payment_behavior: "default_incomplete" seems to be working as expected without returning 'This customer has no attached payment source or default payment method.'.
It also appears that you're using Javalibrary 20.35.0 and the default_incomplete behavior was not introduced until 20.48.0.
https://github.com/stripe/stripe-java/blob/master/CHANGELOG.md#20480---2021-05-05
The recommendation here is to upgrade this on your end.
I will upgrade the library right away. Thank you.
Upgrading the library did the job. Thank you very much for your time. I'm receiving the client_secret i was looking for. and now I'm going to work on the payment-element in the FE. Thanks again!