From b249077420e2a81c6044709ad8fd16e1da35aa11 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 24 Nov 2021 04:27:45 +1100 Subject: [PATCH] fixes for Stripe ACH description --- app/PaymentDrivers/Stripe/ACH.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/PaymentDrivers/Stripe/ACH.php b/app/PaymentDrivers/Stripe/ACH.php index a0568cb8f6ec..cac64514a20c 100644 --- a/app/PaymentDrivers/Stripe/ACH.php +++ b/app/PaymentDrivers/Stripe/ACH.php @@ -231,12 +231,24 @@ class ACH $this->stripe->payment_hash->data = array_merge((array)$this->stripe->payment_hash->data, $state); $this->stripe->payment_hash->save(); + $amount = array_sum(array_column($this->stripe->payment_hash->invoices(), 'amount')) + $this->stripe->payment_hash->fee_total; + $invoice = Invoice::whereIn('id', $this->transformKeys(array_column($this->stripe->payment_hash->invoices(), 'invoice_id'))) + ->withTrashed() + ->first(); + + if ($invoice) { + $description = "Invoice {$invoice->number} for {$amount} for client {$this->stripe->client->present()->name()}"; + } else { + $description = "Payment with no invoice for amount {$amount} for client {$this->stripe->client->present()->name()}"; + } + try { $state['charge'] = \Stripe\Charge::create([ 'amount' => $state['amount'], 'currency' => $state['currency'], 'customer' => $state['customer'], 'source' => $state['source'], + 'description' => $description, ], $this->stripe->stripe_connect_auth); $state = array_merge($state, $request->all());