#Nukesforbreakfast
1 messages ยท Page 1 of 1 (latest)
Generally yes for the latest payment products (not for legacy products or API). What is your use case?
Well
I currently use stripe checkout to process payments
I'm looking to transition to invoices.
In the transition there will likely be some mix of both
It would be ideal to have one event type to listen to in order to keep the out of stripe balances in sync
I see! I'd recommend using the corresponding event type to determine the successful payment instead of using one single event since not all information such as metadata will be populated to payment intent.
You may listen to checkout.session.completed event for Checkout Session and invoice.paid event for Invoice.
Oh, so metadata doesn't propagate to the other sub-types?
Yep! Metadata won't be populated to other underlying objects
Interesting. I could have swore the charge or payment intent objects from the current checkout implementation were getting copies of the metadata added when creating the session...
They must be because I rely on the metadata to reconcile the successful payment to a specific account.
Interesting! If you have a PaymentIntent ID (pi_xxx) to share, I'll be happy to take a look
I might think of a case where it can be populated
If you set metadata in payment_intent_data field, it will then be populated to the Payment Intent: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-metadata
If metadata is set directly on Checkout Session alone, then metadata won't be populated: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-metadata
payment_intent_data.metadata is to set metadata on the underlying Payment Intent object
ok, looking...
However, there's no similar field in Invoice, i.e. set the metadata in PaymentIntent object with Invoice API
yes, so I am setting payment_intent_data.metadata
and it looks like I'm actually currently handling charge.succeeded
and the charge object has that metadata.
evt_3MMJs5B7kbjcJ8Qq0vm9yoGx
is an example of an event that shows this
With payment_intent_data.metadata will have metadata set in Payment Intent as the parameter is specifically for Payment Intent object.
However, invoice doesn't have similar field, so you won't get metadata set on the invoice in Payment Intent or Charges
ok
and I'm guessing the payment intent itself doesn't have any reference to what created it?
I guess it does have the invoice ID that created it as an attribute, so I could use that in a pinch if I wanted to.
Yep! If the payment intent is created from an invoice, the invoice ID will be present under invoice field in Payment Intent object: https://stripe.com/docs/api/payment_intents/object#payment_intent_object-invoice
ok, switching gears a bit to a related topic: Right now in checkout I create the cart on demand based on the outstanding fees/fines for the user in question they need to pay. In invoicing land how do I do something similar at the end of the billing period? It looks like creating an invoice doesn't allow you to create line items? And the update API doesn't seem to either, so I'm not seeing how to add one off items to an invoice.
I've checked in other chats and with support and our fee/fine schedule doesn't quite fit into the stripe product/billing/subscription model.
context from this thread: https://discord.com/channels/841573134531821608/1055557742837903483
It looks like creating an invoice doesn't allow you to create line items?
Invoice works different. You'd create an empty invoice first, then add line items to the invoice. It's possible to create line items on the invoice. You may refer to the doc here: https://stripe.com/docs/invoicing/integration/quickstart
oh!
wait, am I understanding this right? I can create invoice items for a customer that are not associated to an invoice, and then the next invoice I create will automatically pick up those items?
Sorry, I'm a bit confused. Are you talking about one-time payment using invoice or invoices on a subscription?
not using stripe subscriptions. It doesn't quite work for our use case.
Looking at this doc: https://stripe.com/docs/api/invoiceitems/create
If no invoice is specified, the item will be on the next invoice created for the customer specified.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
so if I understand this right: throughout the month as they accrue fines, I can create invoice items as that happens. Then, at the end of the month, when I call
invoice = stripe.Invoice.create(
customer=customer_id,
collection_method='send_invoice',
days_until_due=30,
)
That created invoice will pick up all those unassociated invoice items?
By default, invoice should be created first, then adding the invoice items as described in the guide: https://stripe.com/docs/invoicing/integration/quickstart
However, it's possible to add invoice items first then create an invoice. You will need to set pending_invoice_items_behavior to include during invoice creation, so that those pending items on the customers will be included in the invoice: https://stripe.com/docs/api/invoices/create#create_invoice-pending_invoice_items_behavior
No problem! Happy to help ๐
@pale horizon do products/prices work with connect?
Hi, yes it should?
Sorry if I haven't grasped the context, but generally yes. You just need to make sure Products/Prices belongs to the correct Account (Platform or Connected)
ok, so in a destination charge scenario with an express account, am I able to use a product/price to create an invoice?
each connected account may have a different array of prices/products
destination charge means you are using data on your Platform account, just "redirect" some fund to your connected account, so the products/prices should belong to your Platform account
got it, so I can have the products/prices live on the main platform account