#johnykes-metered-billing
1 messages ยท Page 1 of 1 (latest)
Hi ynnoj ๐
Hey! Have you seen the guide that outlines a billing integration? https://stripe.com/docs/billing/subscriptions/build-subscription?ui=elements
Generally you'd create the Subscription and then collect payment info from your customer to handle any auth/3DS and confirm the initial payment
I tried to use the low code version of this integration
using vue-stripe npm package
but I get an error because of missing quantity of the subscription items
With Checkout?
Can you share the request ID? https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
I can't find it because the request did not arrive to stripe, because I used vue-stripe https://vuestripe.com/stripe-checkout/recurring-payment/
I think I'll create an issue to vue-stripe on github...
I don't want to implement using hardcoded price IDs
Share your code, I'll see if anything stands out
I assume this is creating the Checkout Session?
yesm it should
Share the code
that's my user profile page. he will see/create/cancel his PAYG subscrption from this page.
I want to use a no-code option in order to keep the things simple and save his card details automatically on the stripe page
Yeah the issue is here I think:
lineItems: [
{
price: "price_1JxVxhKXC3SV2dGeR14xixpR"
},
{
price: "price_1JxXQYKXC3SV2dGet6Q8jzRX"
}
],
You need to pass the quantity parameter: https://stripe.com/docs/js/checkout/redirect_to_checkout#stripe_checkout_redirect_to_checkout-options-lineItems-quantity
Complete reference documentation for the Stripe JavaScript SDK.
from metered billing docs - https://stripe.com/docs/billing/subscriptions/metered-billing#reporting-usage
Yeah but you're creating a Checkout Session
That Session handles the creation of the Subscription
because it's a metered subscription... 0$ / month if no usage
There still need to be an initial quantity to subscribe to
The usage reporting is separate
If I set quantity, they will be charged every month even if they don't use my service. I don't want that... I want to be Pay As You Go
There won't be. The quantity here is the total amount of subscriptions to each price to create
The amount they're billed is dependent on your usage reporting within the billing cycle
I don't get it... anyway, tried with quantitiy: 1 for both items, but it seems Client-onlycheckout does not support metered billing
v3:1 Uncaught (in promise) IntegrationError: Client-only Checkout does not support prices with `usage_type=metered` in `items[0]`.
payment links for creating a metered subscription, or what?
or just for paying every month/day/etc?
I don't think I can use this with metered billing... I tried right now to create a paymnet link, but I can't choose the metered products...
Yeah it's pretty new (as a replacement for client-only Checkout) but is getting more and more features added
In that case you'd need a sever to create the Checkout Session
what would be the workflow?
I mean, I need this: customer will click "activate subscription", somehow collect and VALIDATE payment details and just then create metered billing subscription... then he will be peridically automatically charged...
Checkout can do all that, yes
But to be clear there will be some code required for the metered usage reporting
yes, the usage report is not a problem.
will the invoice be created automatically at the end of the period (e.g. month) and sent to customer?
Yep at the timestamp of the billing_cycle_anchor on the Subscription: https://stripe.com/docs/api/subscriptions/object#subscription_object-billing_cycle_anchor
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
But you need to report usage for that billing period before then
At the end of a subscription period, Stripe automatically totals and invoices for all usage during the billing period. Metered billing invoices respect trials. Note that once the invoice is submitted, it cannot be changed. The usage reporting endpoint is rate-limited, so you might need to exercise caution and avoid making too many separate usage records.
Sure!
this card element generates a token... can this token be passed to the SubscriptionCreateOptions.DefaultPaymentMethod string?
is this its purpose?
Is your intention not to use Checkout?
do you mean this tutorial https://stripe.com/docs/billing/subscriptions/metered#create-subscription ?
Token objects are mostly legacy (and deprecated). Instead you'd want a Payment Method object. I'm not sure what that library supports as it's third-party and not maintained by Stripe
Previously you wanted to use Checkout which will handle the creation of your subscription as well as collecting payment methods. Now you're linking to Element components for a custom flow
Unsure as to which way you're building!
I would like to use checkout... but it's html + js....
I want to use vuejs
and not hardcode variables like my publishable key or price IDs...
If you're using Checkout then you don't need the Card Element
but I'll need this for example
let stripe = Stripe('xxxx');
let elements = stripe.elements();
Instead, look a this: https://site-admin.stripe.com/docs/checkout/quickstart
Will help you get an understanding of Checkout and how to create a Session
Not with Checkout, no
I can't use Checkout for metered billing products, right?
No, but you could use it to collect the payment details, for example
using virtual product with price 0$, or how?
Using mode=setup: https://stripe.com/docs/payments/save-and-reuse?platform=checkout#create-checkout-session
This allows you to collect payment details for future payments with no payment taken at the time
ok ๐ I'll try to implement that and add the payment method to my create subscription backend function. Thank you for now for all your patience ๐
Sounds good, and happy to help!