#mikeD-PHP
1 messages · Page 1 of 1 (latest)
static calls being \Stripe\Stripe::setApiKey('key')
\Stripe\Customer::retrieve('custid')
static call is the legacy approach and what you did in the first place is the correct newer approach. I guess it's a different problem 🤔
Are you sure your code looks like this? https://github.com/stripe/stripe-php/wiki/Migration-to-StripeClient-and-services-in-7.33.0#client-and-services
looks good. How is your code?
$stripeItem = '';
$stripeItemFound = false;
$stripe = new \Stripe\StripeClient(env('STRIPE_SECRET'));
if($te->stripe_id) {
try {
$stripe->invoiceItems->retrieve($te->stripe_id, []);
} catch (\Exception $ee) {
}
}
$cstripeid = \App\Models\Project::findOrFail($te->project_id)->customer->stripe_id;
$stripeCustomer = $stripe->customers->retrieve($cstripeid);
// check if invoiceitem exists
\Stripe\InvoiceItem::create(array(
"customer" => $stripeCustomer->id,
"amount" => 2500,
"currency" => "usd",
"description" => "One-time fee")
);
return 'created item';
Ahhh it's prob erroring on \Stripe\InvoiceItem::create
grrrr.. Checking one sec. Sorryu
^^YUP. I am dumb. Sorry it's late. forgive me.
@grizzled bloom Thanks again. feel free to close thread.
No worry and happy to help 🙂
Actually @grizzled bloom you got another sec?
Sure
What if I wanted to update an invoice item?
I am using them as like time entries
So lets say some one puts in a time entry. Item: Consulting Services: At Rate: of 100.00 /hr
Then they change that time entry to
Client Phone Call: At Rate: $75 /hr
I wan to basically be able to update 3 things
line entry description on invoice (TimeEntry.Description).
line entry Units (TimeEntry.Hours)
lineEntry Rate (TimeEntry.BillRate)
looks like I lined most of them up. InvoiceItem.Description => TimeEntry.Description / InvoiceItem.unit_amount => TimeEntry.BillRate / InvoiceItem.quantity => TimeEntry.Hours
Using something like this
$sitem = $stripe->invoiceItems->create(array(
"customer" => $stripeCustomer->id,
"quantity" => 1,
"unit_amount" => 10000,
"currency" => "usd",
"description" => "Consulting Services")
);
to generate item
To update is it as simple as
$sitem = $stripe->invoiceItems->update($stripeItem->id, array(
"quantity" => 1,
"unit_amount" => 7500,
"currency" => "usd",
"description" => "Client Phone Call")
);
Also an Issue I see is it quantity. What if someone does 1.5 hours not just 1 hour?
Sorry I am a bit stretched out, will go back asap
Also, by tax laws. I have to be able to indicate whether an item was an expense or not.
As for pass through expenses I do not pay any tax on the money collected. For example
Hotel Room costs me ($150 including taxes). If I charge my customers $500. which was $150 + $350 for services. I don't get charged tax on the $150 as well just the $350