#dru - invoice
1 messages ยท Page 1 of 1 (latest)
Hello! Just starting a thread for you -- I'll review and respond as soon as I can ๐
hey there, what label do you mean, exactly? Can you show me an example screenshot + invoice id?
The 'Description' that appears here
I'm wanting to include some description of the invoice contents at a quick glance
also appears here.. (this is all test data obvs)
Oops, forgot the invoice ID, example from the screenshots is: in_1KwRtnJy1BVuvdY9OW62pAwl - I appreciated your input what with the docs being down and all..
did I lose you?
Oh, no sorry i was struggling with the docs like looking at examples here
That's the description on the payment automatically created within the invoice
the description you set would be shown on the invoice itself
Is there any way to change the label for the Payment instead of the invoice?
Ok just confirm yep
You can update the payment intent description directly:
https://stripe.com/docs/api/payment_intents/update#update_payment_intent-description
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
using the invoice.payment_intent eg
thanks, must be something wrong with my syntax here though:?
$invoice = $stripe->invoices->create(['customer' => $customer->id]);
$update = $stripe->paymentIntents->update('invoice.payment_intent', ['description' => $invoice_contents]);
Have also tried:
$update = $stripe->paymentIntents->update('latest_invoice.payment_intent', ['description' => $invoice_contents]);
$update = $stripe->paymentIntents->update('pi_1234', ['description' => $invoice_contents]);
You need to get the actual id from the invoice
perhaps eg: $update = $stripe->paymentIntents->update($invoice->payment_intent, ['description' => $invoice_contents]);
Think I might need to finalize the invoice first..
Yes, the payment intent isnt created until an invoice is finalized
Bingo, got working with:
$invoice = $stripe->invoices->create(['customer' => $customer->id]);
$finalize = $stripe->invoices->finalizeInvoice($invoice->id,[]);
$update = $stripe->paymentIntents->update($finalize->payment_intent, ['description' => $invoice_contents]);
Thanks!
Quite welcome! Thanks for your patience ๐
I don't suppose you're still around? I'm now trying to do the same but with Subscriptions, so the label doesn't say 'Subscription Creation' but there is no payment intent when creating a subscription..?
Hi ๐ @blissful karma has stepped away but I'm here
Hi, thanks ๐
When you create a Subscription it will create an Invoice which creates a Payment Intent
It's just one more layer
currently i'm doing this:
$stripe_subscription = $stripe->subscriptions->create($sub_fields);
and that's it for the subscriptions
Should I be running this after I create the subscription?
$invoice = $stripe->invoices->create(['customer' => $customer->id]);
$finalize = $stripe->invoices->finalizeInvoice($invoice->id,[]);
$update = $stripe->paymentIntents->update($finalize->payment_intent, ['description' => $invoice_contents]);
Checking some stuff right now
When you create the subscription it should have an invoice already in the latest_invoice property
You use that one and do the updates
ah yes, I had used that elsewhere earlier, will give that a shot now..
OK, so I'm getting close, but I don't think it works on subscriptions that have 'trial_period_days' set
you should create an invoice for $0 representing the trial
that still seems to return a payment_intent without an id.. I currently I have:
$sub_fields = array(
'customer' => $customer->id,
'items' => [['plan' => $basket->membership_price_id]],
'trial_period_days' => 7,
'expand' => ['latest_invoice.payment_intent']);
$stripe_subscription = $stripe->subscriptions->create($sub_fields);
$invoice_item = $stripe->invoiceItems->create(['customer' => $customer->id,'amount' => 0, 'currency'=> 'USD' ]);
$invoice = $stripe->invoices->create(['customer' => $customer->id]);
$finalize = $stripe->invoices->finalizeInvoice($invoice->id,[]);
$update = $stripe->paymentIntents->update($finalize->payment_intent->, ['Subscription created for '.$basket->membership_name]);
But there is no ID for the payment_intent returned in $finalize ..
I'm assuming because the amount is zero
๐ stepping in here. What do you see when you log out $finalize?
sorry, there may be something else afoot, I'm just trying to rule that out before I waste any more of your time... one sec...