#dbjpanda-invoice-paymentlink
1 messages · Page 1 of 1 (latest)
dbjpanda-invoice-paymentlink
@thick kindle our PaymentLinks product is a "completely separate" product. It's documented here: https://stripe.com/docs/payments/payment-links if you want to read more about it.
But I assume what you meant is a bit different. You kinda want to create a one-off Invoice to invoice the customer's $5 you created as an InvoiceItem? In that case, I recommend reading https://stripe.com/docs/invoicing/integration
But mostly you would do
1/ Create an Invoice https://stripe.com/docs/api/invoices/create
2/ Finalize the Invoice https://stripe.com/docs/api/invoices/finalize
After that you can see the https://stripe.com/docs/api/invoices/object#invoice_object-hosted_invoice_url that you can give to your customer to come and pay
So I need to call two apis to get a payment link to charge one-off payment?
I simply want to charge an amount to an existing subscriber. Is there any better way?
Yes, I have customer ID.
Is there a PaymentMethod attached to that Customer?
Or you just have a Customer object?
yes
Okay then you can just create/confirm a PaymentIntent using that PaymentMethod
No need for an Invoice unless you want to provide them with an Invoice
You would basically do what we show here: https://stripe.com/docs/payments/save-during-payment?platform=web#charge-saved-payment-method
Subscriber is paying monthly fee. For some reason, I want to charge some extra amount.
And you want to charge it separately from the next monthly invoice or add it on to the next invoice?
Actually if you read my previous thread you can understand the full scenario. Can you reopen that ? So that I can continue my question there
No I can't re-open threads. You can summarize the issue though and I am happy to help
can you have a look here https://discord.com/channels/841573134531821608/1092799080582881320
This was my scenario.
On the 1st of May, the user begins his subscription at 25€/month. On the 15th of May, he switches to an upgraded subscription at 50€/month. He is immediately invoiced 12.5€ (25€ difference - 12.5€ unused time) I believe.
I would like the user to pay the full 25€ difference while keeping the billing period the same.
How could I remove the "Unused time" from the equation? Is there a simple way?
Additionally, if the user downgrades, it would be optimal if the user receives no credit to his account.
And since the Stripe Proration can not exclude time by default, so your staff suggested that I need to charge off one off-invoice while upgrading a subscription.
You want that 25 EUR payment immediately on May 15th?
Or added and billed on June 1st?
Immediately.
Okay then yeah you want to set proration_behavior: none when you make the Subscription update and then you create/confirm a PaymentIntent as I noted above to charge for the 25 EUR as a one-off.
Please keep this thread open for some time. I am trying it out.
👍
But how can I attach the payment to an existing subscription id.
You could set metadata on the PaymentIntent with the Subscription ID if you just need to track this on your end.
Otherwise you create an Invoice with an Invoice Item like you were doing originally and koopajah was explaining
So, when a user pay through PaymentIntent, and later I update subsacription, will the balance adjusted towards that subscription?
This is the only concern why I wanted to attch a subscription id.
I don't understand what you mean, sorry. What balance are you referring to here?
As I shared the thread earlier, I want to charge a customer while upgrading or downgrading their subscription. And I want to exclude the time from proration. Since I can't exclude the time from proration, I need to charge that amount separately using PyamentIntent or Create Invoice forst then, update the subscription using update subscription API.
So my question is when the customer pays through paymentIntent API, and then update the subscription, he/she shoudn't be charged any amount.
Yes that's correct. As long as you pass proration_behavior: none and the update includes a Price that is on the same interval (ie you upgrade or downgrade without changing from monthly --> annual) then there will be no charge on the Subscription update.
I have one more query.
While creating a checkoutsession for first time, can we take a permission from the user that we can charge later without a payment flow or user interaction? So that we don't need to send a payment link or confirmation link again while updating. We will just charge the extra amount and update the subscription.
You are using mode: subscription here with all of your Checkout Sessions, correct?
This is how you are starting your Subscriptions I assume
Yes, right
return await stripe.checkout.sessions.create({
line_items: [{
price: price_id,
quantity: 1
}],
mode: 'subscription',
success_url: 'https://example.com/success',
client_reference_id: uid,
...(stripeCustomerId ?
{customer: stripeCustomerId} :
{customer_email: context.auth.token.email}),
subscription_data:{
metadata:{
uid:uid
}
}
});
Then yes that will automatically set up these PaymentMethods to be charged in the future. You should just make it clear on your site before redirecting them to Checkout or you could use a ToS consent collection in Checkout via: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-consent_collection-terms_of_service
So which method would be best to charge an amount PaymentIntent or CreateInvoice?
There is no best - it is all what you prefer.
Either way works equally well. Just depends on whether you actually want an Invoice associated with the PaymentIntent or not.
Also one more issue, for Indian customers, there is E mandate or 3D secure system, so when using this payment method, I need to take care of the Authentication URL that I need to send to the user.
Yeah if you are going to have Indian customers then you are going to want to handle this a bit differently.
In that case you may want to actually use Invoices and send the Invoice's Hosted Payment Page to the Indian customer to complete 3DS for the one-off payment.
const session = await stripe.checkout.sessions.create({
customer: userData.stripe_customer_id,
subscription: userData.current_plan.subscription_id,
line_items: [
{
price: userData.current_plan.price_id,
quantity: 1,
},
{
price_data: {
currency: 'usd',
unit_amount: 500,
product_data: {
name: 'One-time Charge',
},
},
quantity: 1,
},
],
success_url: 'https://example.com/success',
cancel_url: 'https://example.com/cancel',
});
console.log(session);
Can I also use create Check out session to charge an amount like this?
Yep that would work too. You would use mode: payment
You can't pass a Subscription ID like you are trying to do here
Let me try it once. Please don't close the thread.
Can we ommit the line items here?
Nope line_items are required unless in mode: setup (see: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items).
As I understand, price is a new price id which needs to be check out. Isn't it?
You can either use a Price Id from a Price you have previously created or you can use price_data to create the Price inline when you create the Checkout Session
Well. And can I directly deduct the amount via createCheckoutSession if there is no requirement of 3D secure pin from the user?
No you only use a Checkout Session if you are collecting a new payment method (or need to handle 3DS in the case of an India payment). Otherwise you just use a PaymentIntent and charge the saved PaymentMethod so the customer doesn't have to input their payment method details again.
Can you share a doc where I can go through all the type of payments available in stripe through which I can collect an amount?