Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function updatePrices($newCost)
- {
- $this->subtotal += $newCost;
- $this->tax = round($this->subtotal * $this->tax_rate , 2);
- $this->total = $this->subtotal + $this->tax;
- $secret_key = config('services.stripe.sk');
- $stripe = new StripeClient(
- $secret_key
- );
- $stripe->paymentIntents->update(
- $this->paymentIntentId,
- [
- 'amount' => $this->total * 100,
- ]
- );
- $items = CartItem::where([
- ['user_id', $this->user_id],
- ['user_type', $this->user_type],
- ['use_case_id', $this->useCaseId],
- ['organization_id', $this->organization_id],
- ])->get();
- $info = [];
- foreach($items as $index => $item)
- {
- $info[$index] = [];
- $info[$index][0] = $item->item->name;
- $info[$index][1] = $item->qty;
- $price = 0;
- $options = CartItem::where('cart_item_id', $item->id)->get();
- foreach($options as $option)
- {
- $price += $option->item->price;
- }
- $info[$index][2] = $price + $item->item->price;
- }
- $this->dispatchBrowserEvent('prices-updated', ['info' => $info]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement