#karls_api

1 messages ¡ Page 1 of 1 (latest)

cyan skiffBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1328468432529920124

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

spring capeBOT
radiant void
#

Can you share a subscription id where this happened? Not sure I understand what you mean

abstract shadow
#

Hello. Sorry I stepped away. Yes. 1 sec.

#

sub_1QguXfDOnh5qjbu12jOdpXLO

radiant void
#

I only see 1 invoice for that subscription

#

Not sure I understand the problem

abstract shadow
#

Right, here is the pending invoice.

#

in_1QguXcDOnh5qjbu12sCibfAg

#

Pending, because it was never charged and was suppose to attach to the subscription invoice. I honestly thought I had this working.

radiant void
#

That's a one-off invoice you created for the same customer

#

Separately from the subscription

abstract shadow
#

Yes

radiant void
#

What's unexpected?

abstract shadow
#

I created the invoice with these line-items, but never invoked a Pay, I then created the subscription invoice and expected the draft invoice to be paid at the same time I paid it.

radiant void
#

Why would you expect that?

#

The invoice you created is entirely separate from the subscription

#

You need to explicitly pay it separately

abstract shadow
#

Isn't there a stripe methodology similar to this that you can have pending items that are attached and paid in a final invoice? Looking for my code sample.

tidal pier
#

If you add the invoice items before creating the subscription, you can have them added to the subscription's invoice I believe.

radiant void
#

^ this

#

Basically you just don't want to create the invoice separately if you want the invoice items on the subscription invoice

tidal pier
abstract shadow
#

Yes, AutoAdvance = true, when I'm creating my invoice.

tidal pier
#

Here it looks like you created the invoice just before the subscription. Basically what happens is that the invoice items exist on the customer until some invoice claims them while being created, if you hadn't created that other invoice, I think the subscription's first invoice would have picked them up

abstract shadow
#

I've done it this way before, adding invoice items to the subscription creation. I was hoping to exploit more feature from the invoice as there are some limitations to the add line item request on the subscription class.

#

So create the subscription invoice first, then create the line-items 2nd (resulting in a draft invoice) and 3rd, Pay the subscription invoice and all line items from draft will be included in this final invoice?

tidal pier
#

No I don't think that would work. The first invoice on a subscription will finalize immediately if collection_method is set to charge_automatically and you can't invoke invoice payment yourself if you use send_invoice for collection method.

#

So it sounds like you want to:

  1. Create invoice items on the Customer
  2. Create a subscription with collection_method=charge_automatically, this creates an invoice that picks up the invoice items
  3. The invoice should immediately finalize and attempt to charge the customer
abstract shadow
#

Yes, that sounds right. I think I'm doing that. Aren't I?

cyan skiffBOT
abstract shadow
#

9BA6C037-DRAFT, is assigned to same customer as the sub_1QguXfDOnh5qjbu12jOdpXLO, customer

tidal pier
abstract shadow
#

OK, your pseudo code above, step 1, Create invoice items on the Customer. I'm confused, isn't that what I did?

#

What is a "one-off" invoice, vs. creating invoice items on the customer?

#

You mean, create invoice-tems without creating an actuall invoice?

tidal pier
#

The request that I linked to is what I am talking about. You had already created invoice items, but that call told us to create an invoice that isn't linked to a subscription. That invoice picked up the existing invoice items that you had already created

#

If you remove the call to /v1/invoices but keep your calls to /v1/invioceitems you should have the behavior that you are going for

abstract shadow
#

OK, I'm going to mess with this. Leave this open please. I'll be back maybe with questions.

bright lance
#

Stepping in for my teammate. We typically leave threads open for ~20 mins. If you don't have any new questions within that time frame, I'll archive the thread. You can still return to #help should any new questions come up

abstract shadow
#

All right. I'm testing now..

#

OK, I see that I am adding promo and discount codes to the original invoice I created. I guess I can't add promo and discount codes without an invoice to attachem them to, or do I have to attach them to the invoice which is ultimately my subscription invoie?

bright lance
#

So you can still work with the pseudo code above:

#
  1. Create invoice items on the Customer
  2. Create a subscription with collection_method=charge_automatically and add any discounts. This creates an invoice that picks up the invoice items
  3. The invoice should immediately finalize and attempt to charge the customer
abstract shadow
#

OK. The logic in my code was: Create and invoice, attach line items, apply promo and discounts, leave it as a draft, pay everything in the next invoice, the subscription invoice.

#

That doesn't work??

bright lance
#

You shouldn't create an Invoice directly. Creating the Subscription will automatically create an Invoice and pull in any pending invoice items for a customer

abstract shadow
#

OK, it is just that I tested this a couple of weeks earlier and I thought it was working.. I will rework my code.

#

Question: if you are just creating Items, so now Invoice, how is this associated with a customer?

#

Nevermind, I see a customer id on the invoice item create request.

bright lance
#

You'll create items for a specific customer then create a Subscription for that same customer

abstract shadow
#

Yep, testing new code now...

#

Think I got it, although I need to improve my line item descriptions: in_1QgwE7DOnh5qjbu1pVWIs09t

bright lance
#

Yep, this looks like you're on the right track. That Invoice was created automatically after you created a Subscription for this customer

abstract shadow
#

OK, onto the subscription now. I need to add both promo code(one) and discount(1-many)

bright lance
bright lance
#

@abstract shadow do you still need help? I can close this thread if you're done testing for the day. You can always return to #help if you have any more questions.

abstract shadow
#

I do. i'm good. Sorry, was chasing other things!

#

*I don't

bright lance
#

No worries!