#dru - invoice

1 messages ยท Page 1 of 1 (latest)

blissful karma
#

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?

fluid sundial
#

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..

fluid sundial
#

did I lose you?

blissful karma
#

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

fluid sundial
#

Is there any way to change the label for the Payment instead of the invoice?

blissful karma
#

Ok just confirm yep

#

using the invoice.payment_intent eg

fluid sundial
#

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]);

blissful karma
#

$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]);

fluid sundial
#

Think I might need to finalize the invoice first..

blissful karma
#

Yes, the payment intent isnt created until an invoice is finalized

fluid sundial
#

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!

blissful karma
#

Quite welcome! Thanks for your patience ๐Ÿ™‚

fluid sundial
#

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..?

amber kernel
#

Hi ๐Ÿ‘‹ @blissful karma has stepped away but I'm here

fluid sundial
#

Hi, thanks ๐Ÿ™‚

amber kernel
#

When you create a Subscription it will create an Invoice which creates a Payment Intent

#

It's just one more layer

fluid sundial
#

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]);

amber kernel
#

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

fluid sundial
#

ah yes, I had used that elsewhere earlier, will give that a shot now..

fluid sundial
#

OK, so I'm getting close, but I don't think it works on subscriptions that have 'trial_period_days' set

amber kernel
#

you should create an invoice for $0 representing the trial

fluid sundial
#

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

small zodiac
#

๐Ÿ‘‹ stepping in here. What do you see when you log out $finalize?

fluid sundial
#

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...

small zodiac
#

No problem. We are here to help so you aren't wasting our time!

#

But yeah, would recommend doublechecking as there should be a PI there ๐Ÿ™‚