#dbjpanda-invoice-paymentlink

1 messages · Page 1 of 1 (latest)

bold parcelBOT
upbeat horizon
#

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

thick kindle
#

So I need to call two apis to get a payment link to charge one-off payment?

upbeat horizon
#

yes

#

well 3 really since you are creating an InvoiceItem first

thick kindle
#

I simply want to charge an amount to an existing subscriber. Is there any better way?

civic pasture
#

👋 stepping in

#

They already exist and you already have a PaymentMethod collected?

thick kindle
#

Yes, I have customer ID.

civic pasture
#

Is there a PaymentMethod attached to that Customer?

#

Or you just have a Customer object?

thick kindle
#

yes

civic pasture
#

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

thick kindle
#

Subscriber is paying monthly fee. For some reason, I want to charge some extra amount.

civic pasture
#

And you want to charge it separately from the next monthly invoice or add it on to the next invoice?

thick kindle
#

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

civic pasture
#

No I can't re-open threads. You can summarize the issue though and I am happy to help

thick kindle
#

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.

civic pasture
#

You want that 25 EUR payment immediately on May 15th?

#

Or added and billed on June 1st?

thick kindle
#

Immediately.

civic pasture
#

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.

thick kindle
#

Yes

#

Do I need to create a paymentIntent?

civic pasture
#

And you pass confirm: true to immediately attempt payment

thick kindle
#

Please keep this thread open for some time. I am trying it out.

civic pasture
#

👍

thick kindle
#

But how can I attach the payment to an existing subscription id.

civic pasture
#

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

thick kindle
#

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.

civic pasture
#

I don't understand what you mean, sorry. What balance are you referring to here?

thick kindle
#

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.

civic pasture
#

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.

thick kindle
#

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.

civic pasture
#

You are using mode: subscription here with all of your Checkout Sessions, correct?

#

This is how you are starting your Subscriptions I assume

thick kindle
#

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
                }
            }
        });
civic pasture
thick kindle
#

So which method would be best to charge an amount PaymentIntent or CreateInvoice?

civic pasture
#

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.

thick kindle
#

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.

civic pasture
#

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.

thick kindle
#
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?

civic pasture
#

Yep that would work too. You would use mode: payment

#

You can't pass a Subscription ID like you are trying to do here

thick kindle
#

Let me try it once. Please don't close the thread.

#

Can we ommit the line items here?

civic pasture
thick kindle
#

As I understand, price is a new price id which needs to be check out. Isn't it?

civic pasture
#

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

thick kindle
#

Well. And can I directly deduct the amount via createCheckoutSession if there is no requirement of 3D secure pin from the user?

civic pasture
#

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.

thick kindle
#

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?