diff --git a/app/Filters/InvoiceFilters.php b/app/Filters/InvoiceFilters.php index 81f3e6db68dd..cafeee6ab5e7 100644 --- a/app/Filters/InvoiceFilters.php +++ b/app/Filters/InvoiceFilters.php @@ -69,7 +69,6 @@ class InvoiceFilters extends QueryFilters if (in_array('overdue', $status_parameters)) { $query->orWhereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]) ->where('due_date', '<', Carbon::now()) - ->orWhere('due_date', null) ->orWhere('partial_due_date', '<', Carbon::now()); } }); diff --git a/app/Http/Livewire/BillingPortalPurchasev2.php b/app/Http/Livewire/BillingPortalPurchasev2.php index 612dfd5b8209..f3f0a3b132a7 100644 --- a/app/Http/Livewire/BillingPortalPurchasev2.php +++ b/app/Http/Livewire/BillingPortalPurchasev2.php @@ -311,7 +311,7 @@ class BillingPortalPurchasev2 extends Component 'description' => $p->notes, 'product_key' => $p->product_key, 'unit_cost' => $p->price, - 'product' => nl2br(substr($p->notes, 0, 50)), + 'product' => substr(strip_tags($p->markdownNotes()), 0, 50), 'price' => Number::formatMoney($total, $this->subscription->company).' / '. RecurringInvoice::frequencyForKey($this->subscription->frequency_id), 'total' => $total, 'qty' => $qty, @@ -329,7 +329,7 @@ class BillingPortalPurchasev2 extends Component 'description' => $p->notes, 'product_key' => $p->product_key, 'unit_cost' => $p->price, - 'product' => nl2br(substr($p->notes, 0, 50)), + 'product' => substr(strip_tags($p->markdownNotes()), 0, 50), 'price' => Number::formatMoney($total, $this->subscription->company), 'total' => $total, 'qty' => $qty, @@ -352,7 +352,7 @@ class BillingPortalPurchasev2 extends Component 'description' => $p->notes, 'product_key' => $p->product_key, 'unit_cost' => $p->price, - 'product' => nl2br(substr($p->notes, 0, 50)), + 'product' => substr(strip_tags($p->markdownNotes()), 0, 50), 'price' => Number::formatMoney($total, $this->subscription->company).' / '. RecurringInvoice::frequencyForKey($this->subscription->frequency_id), 'total' => $total, 'qty' => $qty, @@ -375,7 +375,7 @@ class BillingPortalPurchasev2 extends Component 'description' => $p->notes, 'product_key' => $p->product_key, 'unit_cost' => $p->price, - 'product' => nl2br(substr($p->notes, 0, 50)), + 'product' => substr(strip_tags($p->markdownNotes()), 0, 50), 'price' => Number::formatMoney($total, $this->subscription->company), 'total' => $total, 'qty' => $qty, diff --git a/app/PaymentDrivers/CustomPaymentDriver.php b/app/PaymentDrivers/CustomPaymentDriver.php index 6cc437e53494..a99bdd4123fe 100644 --- a/app/PaymentDrivers/CustomPaymentDriver.php +++ b/app/PaymentDrivers/CustomPaymentDriver.php @@ -12,12 +12,16 @@ namespace App\PaymentDrivers; -use App\Models\ClientGatewayToken; -use App\Models\GatewayType; use App\Models\Invoice; use App\Models\Payment; +use App\Models\SystemLog; use App\Utils\HtmlEngine; +use App\Models\GatewayType; +use App\Models\PaymentHash; +use App\Models\PaymentType; +use App\Jobs\Util\SystemLogger; use App\Utils\Traits\MakesHash; +use App\Models\ClientGatewayToken; /** * Class CustomPaymentDriver. @@ -81,6 +85,7 @@ class CustomPaymentDriver extends BaseDriver $this->payment_hash->save(); $data['gateway'] = $this; + $data['payment_hash'] = $this->payment_hash->hash; return render('gateways.custom.payment', $data); } @@ -92,6 +97,56 @@ class CustomPaymentDriver extends BaseDriver */ public function processPaymentResponse($request) { + + if ($request->has('gateway_response')) { + + $this->client = auth()->guard('contact')->user()->client; + + $state = [ + 'server_response' => json_decode($request->gateway_response), + 'payment_hash' => $request->payment_hash, + ]; + + $payment_hash = PaymentHash::where('hash', $request->payment_hash)->first(); + + if($payment_hash) + { + $this->payment_hash = $payment_hash; + + $payment_hash->data = array_merge((array) $payment_hash->data, $state); + $payment_hash->save(); + } + + $gateway_response = json_decode($request->gateway_response); + + if ($gateway_response->status == 'COMPLETED') { + $this->logSuccessfulGatewayResponse(['response' => json_decode($request->gateway_response), 'data' => $payment_hash], SystemLog::TYPE_CUSTOM); + + $data = [ + 'payment_method' => '', + 'payment_type' => PaymentType::CREDIT_CARD_OTHER, + 'amount' => $payment_hash->amount_with_fee(), + 'transaction_reference' => $gateway_response?->purchase_units[0]?->payments?->captures[0]?->id, + 'gateway_type_id' => GatewayType::PAYPAL, + ]; + + $payment = $this->createPayment($data, Payment::STATUS_COMPLETED); + + SystemLogger::dispatch( + ['response' => $payment_hash->data->server_response, 'data' => $data], + SystemLog::CATEGORY_GATEWAY_RESPONSE, + SystemLog::EVENT_GATEWAY_SUCCESS, + SystemLog::TYPE_STRIPE, + $this->client, + $this->client->company, + ); + + return redirect()->route('client.payments.show', ['payment' => $this->encodePrimaryKey($payment->id)]); + + } + } + + return redirect()->route('client.invoices'); } diff --git a/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php b/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php index d3417dded2f0..82dc46a03241 100644 --- a/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php @@ -107,7 +107,9 @@

- {!! nl2br($product->markdownNotes()) !!} +
+ {!! $product->markdownNotes() !!} +

{{ \App\Utils\Number::formatMoney($product->price, $subscription->company) }}

@@ -145,7 +147,11 @@
-

{!! nl2br($product->markdownNotes()) !!}

+

+
+ {!! $product->markdownNotes() !!} +
+

{{ \App\Utils\Number::formatMoney($product->price, $subscription->company) }} / {{ App\Models\RecurringInvoice::frequencyForKey($subscription->frequency_id) }}

@@ -186,7 +192,11 @@
-

{!! nl2br($product->markdownNotes()) !!}

+

+
+ {!! $product->markdownNotes() !!} +
+

{{ \App\Utils\Number::formatMoney($product->price, $subscription->company) }}

@@ -234,7 +244,7 @@ @foreach($bundle->toArray() as $item)
- {{ $item['qty'] }} x {{ substr(str_replace(["\r","\n","
","
","
","
"]," ", $item['product']), 0, 30) . "..." }}
+ {{ $item['qty'] }} x {{ $item['product'] }} {{ $item['price'] }}
@endforeach diff --git a/resources/views/portal/ninja2020/gateways/custom/payment.blade.php b/resources/views/portal/ninja2020/gateways/custom/payment.blade.php index d337c71897d9..42373e59628f 100644 --- a/resources/views/portal/ninja2020/gateways/custom/payment.blade.php +++ b/resources/views/portal/ninja2020/gateways/custom/payment.blade.php @@ -1,7 +1,15 @@ @extends('portal.ninja2020.layout.payments', ['gateway_title' => $title, 'card_title' => $title]) @section('gateway_content') - @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) +
+ @csrf + + + + + +
+@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) {{ $title }} @endcomponent @@ -11,3 +19,18 @@ {!! nl2br($instructions) !!} @endcomponent @endsection + \ No newline at end of file