diff --git a/app/Http/Controllers/ClientPortal/NinjaPlanController.php b/app/Http/Controllers/ClientPortal/NinjaPlanController.php index d980dd3a27ec..c24ee6293e80 100644 --- a/app/Http/Controllers/ClientPortal/NinjaPlanController.php +++ b/app/Http/Controllers/ClientPortal/NinjaPlanController.php @@ -163,7 +163,7 @@ class NinjaPlanController extends Controller $recurring_invoice->service()->start(); - return redirect('/'); + return redirect('https://invoicing.co'); } diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php index a3c7add4c452..ee7390529f3a 100644 --- a/app/Http/Middleware/TrustProxies.php +++ b/app/Http/Middleware/TrustProxies.php @@ -29,7 +29,15 @@ class TrustProxies extends Middleware * * @var int */ - protected $headers = Request::HEADER_X_FORWARDED_ALL; + // protected $headers = Request::HEADER_X_FORWARDED_ALL; + + //07-03-2022 - fixes for symfony 5.2 + protected $headers = + Request::HEADER_X_FORWARDED_FOR | + Request::HEADER_X_FORWARDED_HOST | + Request::HEADER_X_FORWARDED_PORT | + Request::HEADER_X_FORWARDED_PROTO | + Request::HEADER_X_FORWARDED_AWS_ELB; /* * Instantiate trusted proxies middleware diff --git a/app/Jobs/Credit/ZipCredits.php b/app/Jobs/Credit/ZipCredits.php index 81e6d8518c4b..afffeb9488cb 100644 --- a/app/Jobs/Credit/ZipCredits.php +++ b/app/Jobs/Credit/ZipCredits.php @@ -91,8 +91,9 @@ class ZipCredits implements ShouldQueue foreach ($this->credits as $credit) { - $download_file = file_get_contents($credit->pdf_file_path($invitation, 'url', true)); - $zipFile->addFromString(basename($credit->pdf_file_path($invitation)), $download_file); + $file = $credit->service()->getCreditPdf($credit->invitations()->first()); + $zip_file_name = basename($file); + $zipFile->addFromString($zip_file_name, Storage::get($file)); } diff --git a/app/Jobs/Invoice/ZipInvoices.php b/app/Jobs/Invoice/ZipInvoices.php index 50ebcdd4d63c..b9a4856a4d90 100644 --- a/app/Jobs/Invoice/ZipInvoices.php +++ b/app/Jobs/Invoice/ZipInvoices.php @@ -91,8 +91,12 @@ class ZipInvoices implements ShouldQueue foreach ($this->invoices as $invoice) { - $download_file = file_get_contents($invoice->pdf_file_path($invitation, 'url', true)); - $zipFile->addFromString(basename($invoice->pdf_file_path($invitation)), $download_file); + $file = $invoice->service()->getInvoicePdf(); + $zip_file_name = basename($file); + $zipFile->addFromString($zip_file_name, Storage::get($file)); + + //$download_file = file_get_contents($invoice->pdf_file_path($invitation, 'url', true)); + //$zipFile->addFromString(basename($invoice->pdf_file_path($invitation)), $download_file); } diff --git a/app/Jobs/Quote/ZipQuotes.php b/app/Jobs/Quote/ZipQuotes.php index 50bce4607ea9..6e00710b1c74 100644 --- a/app/Jobs/Quote/ZipQuotes.php +++ b/app/Jobs/Quote/ZipQuotes.php @@ -92,8 +92,12 @@ class ZipQuotes implements ShouldQueue foreach ($this->quotes as $quote) { - $download_file = file_get_contents($quote->pdf_file_path($invitation, 'url', true)); - $zipFile->addFromString(basename($quote->pdf_file_path($invitation)), $download_file); + $file = $quote->service()->getQuotePdf(); + $zip_file_name = basename($file); + $zipFile->addFromString($zip_file_name, Storage::get($file)); + + // $download_file = file_get_contents($quote->pdf_file_path($invitation, 'url', true)); + // $zipFile->addFromString(basename($quote->pdf_file_path($invitation)), $download_file); } diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index ca5b45dd00b0..3722127f5d65 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -237,7 +237,8 @@ class Import implements ShouldQueue //company size check if ($this->company->invoices()->count() > 500 || $this->company->products()->count() > 500 || $this->company->clients()->count() > 500) { - $this->company->is_large = true; + // $this->company->is_large = true; + $this->company->account->companies()->update(['is_large' => true]); } diff --git a/app/PaymentDrivers/Authorize/ChargePaymentProfile.php b/app/PaymentDrivers/Authorize/ChargePaymentProfile.php index 9cfa106b5ae4..e6ba7fe45382 100644 --- a/app/PaymentDrivers/Authorize/ChargePaymentProfile.php +++ b/app/PaymentDrivers/Authorize/ChargePaymentProfile.php @@ -15,6 +15,7 @@ namespace App\PaymentDrivers\Authorize; use App\PaymentDrivers\AuthorizePaymentDriver; use net\authorize\api\contract\v1\CreateTransactionRequest; use net\authorize\api\contract\v1\CustomerProfilePaymentType; +use net\authorize\api\contract\v1\OrderType; use net\authorize\api\contract\v1\PaymentProfileType; use net\authorize\api\contract\v1\TransactionRequestType; use net\authorize\api\controller\CreateTransactionController; @@ -42,9 +43,21 @@ class ChargePaymentProfile $paymentProfile->setPaymentProfileId($payment_profile_id); $profileToCharge->setPaymentProfile($paymentProfile); + $invoice_numbers = ''; + + if($this->authorize->payment_hash->data) + $invoice_numbers = collect($this->authorize->payment_hash->data->invoices)->pluck('invoice_number')->implode(','); + + $description = "Invoices: {$invoice_numbers} for {$amount} for client {$this->authorize->client->present()->name()}"; + + $order = new OrderType(); + $order->setInvoiceNumber($invoice_numbers); + $order->setDescription($description); + $transactionRequestType = new TransactionRequestType(); $transactionRequestType->setTransactionType('authCaptureTransaction'); $transactionRequestType->setAmount($amount); + $transactionRequestType->setOrder($order); $transactionRequestType->setProfile($profileToCharge); $transactionRequestType->setCurrencyCode($this->authorize->client->currency()->code); diff --git a/app/PaymentDrivers/Stripe/BrowserPay.php b/app/PaymentDrivers/Stripe/BrowserPay.php index 7aa18353d762..a7cdfb8dc055 100644 --- a/app/PaymentDrivers/Stripe/BrowserPay.php +++ b/app/PaymentDrivers/Stripe/BrowserPay.php @@ -198,14 +198,6 @@ class BrowserPay implements MethodInterface return; } - // $domain = config('ninja.app_url'); - - // if (Ninja::isHosted()) { - // $domain = isset($this->stripe->company_gateway->company->portal_domain) - // ? $this->stripe->company_gateway->company->portal_domain - // : $this->stripe->company_gateway->company->domain(); - // } - $domain = $this->getAppleDomain(); if(!$domain) @@ -244,12 +236,7 @@ class BrowserPay implements MethodInterface $domain = config('ninja.app_url'); } - $parsed_url = parse_url($domain); - - if(array_key_exists('host', $parsed_url)) - return $parsed_url['host']; - - return false; + return str_replace("https://", "", $domain); } diff --git a/app/Services/Credit/GetCreditPdf.php b/app/Services/Credit/GetCreditPdf.php index 22d60ea52cac..91ae1605a434 100644 --- a/app/Services/Credit/GetCreditPdf.php +++ b/app/Services/Credit/GetCreditPdf.php @@ -34,7 +34,7 @@ class GetCreditPdf extends AbstractService public function run() { if (! $this->contact) { - $this->contact = $this->credit->client->primary_contact()->first(); + $this->contact = $this->credit->client->primary_contact()->first() ?: $this->credit->client->contacts()->first(); } $path = $this->credit->client->credit_filepath($this->invitation); diff --git a/app/Services/Invoice/GetInvoicePdf.php b/app/Services/Invoice/GetInvoicePdf.php index 9f519cab7fbe..0923c0ea2205 100644 --- a/app/Services/Invoice/GetInvoicePdf.php +++ b/app/Services/Invoice/GetInvoicePdf.php @@ -30,7 +30,7 @@ class GetInvoicePdf extends AbstractService public function run() { if (! $this->contact) { - $this->contact = $this->invoice->client->primary_contact()->first(); + $this->contact = $this->invoice->client->primary_contact()->first() ?: $this->invoice->client->contacts()->first(); } $invitation = $this->invoice->invitations->where('client_contact_id', $this->contact->id)->first(); diff --git a/app/Services/Quote/GetQuotePdf.php b/app/Services/Quote/GetQuotePdf.php index d904ea7029f4..9555367461cc 100644 --- a/app/Services/Quote/GetQuotePdf.php +++ b/app/Services/Quote/GetQuotePdf.php @@ -30,7 +30,7 @@ class GetQuotePdf extends AbstractService public function run() { if (! $this->contact) { - $this->contact = $this->quote->client->primary_contact()->first(); + $this->contact = $this->quote->client->primary_contact()->first() ?: $this->quote->client->contacts()->first(); } $invitation = $this->quote->invitations->where('client_contact_id', $this->contact->id)->first(); diff --git a/public/js/clients/payments/stripe-sepa.js b/public/js/clients/payments/stripe-sepa.js index 660c32a2497c..216888a96347 100644 --- a/public/js/clients/payments/stripe-sepa.js +++ b/public/js/clients/payments/stripe-sepa.js @@ -1,2 +1,2 @@ /*! For license information please see stripe-sepa.js.LICENSE.txt */ -(()=>{var e,t,n,a;function o(e,t){for(var n=0;n svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),a.stripe.confirmSepaDebitPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:document.querySelector("input[name=token]").value}).then((function(e){return e.error?a.handleFailure(e.error.message):a.handleSuccess(e)}));else{if(""===document.getElementById("sepa-name").value)return document.getElementById("sepa-name").focus(),e.textContent=document.querySelector("meta[name=translation-name-required]").content,void(e.hidden=!1);if(""===document.getElementById("sepa-email-address").value)return document.getElementById("sepa-email-address").focus(),e.textContent=document.querySelector("meta[name=translation-email-required]").content,void(e.hidden=!1);if(!document.getElementById("sepa-mandate-acceptance").checked)return e.textContent=document.querySelector("meta[name=translation-terms-required]").content,void(e.hidden=!1);document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),a.stripe.confirmSepaDebitPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{sepa_debit:a.iban,billing_details:{name:document.getElementById("sepa-name").value,email:document.getElementById("sepa-email-address").value}}}).then((function(e){return e.error?a.handleFailure(e.error.message):a.handleSuccess(e)}))}}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}var t,n,a;return t=e,(n=[{key:"handleSuccess",value:function(e){document.querySelector('input[name="gateway_response"]').value=JSON.stringify(e.paymentIntent);var t=document.querySelector('input[name="token-billing-checkbox"]:checked');t&&(document.querySelector('input[name="store_card"]').value=t.value),document.querySelector("input[name=token]").value.length>2&&(document.querySelector('input[name="store_card"]').value=!1),document.getElementById("server-response").submit()}},{key:"handleFailure",value:function(e){var t=document.getElementById("errors");t.textContent="",t.textContent=e,t.hidden=!1,document.getElementById("pay-now").disabled=!1,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden")}}])&&o(t.prototype,n),a&&o(t,a),e}();new c(null!==(e=null===(t=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===t?void 0:t.content)&&void 0!==e?e:"",null!==(n=null===(a=document.querySelector('meta[name="stripe-account-id"]'))||void 0===a?void 0:a.content)&&void 0!==n?n:"").setupStripe().handle()})(); \ No newline at end of file +(()=>{var e,t,n,a;function o(e,t){for(var n=0;n svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),a.stripe.confirmSepaDebitPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:document.querySelector("input[name=token]").value}).then((function(e){return e.error?a.handleFailure(e.error.message):a.handleSuccess(e)}));else{if(""===document.getElementById("sepa-name").value)return document.getElementById("sepa-name").focus(),e.textContent=document.querySelector("meta[name=translation-name-required]").content,void(e.hidden=!1);if(""===document.getElementById("sepa-email-address").value)return document.getElementById("sepa-email-address").focus(),e.textContent=document.querySelector("meta[name=translation-email-required]").content,void(e.hidden=!1);if(!document.getElementById("sepa-mandate-acceptance").checked)return e.textContent=document.querySelector("meta[name=translation-terms-required]").content,void(e.hidden=!1);document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),a.stripe.confirmSepaDebitPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{sepa_debit:a.iban,billing_details:{name:document.getElementById("sepa-name").value,email:document.getElementById("sepa-email-address").value}}}).then((function(e){return e.error?a.handleFailure(e.error.message):a.handleSuccess(e)}))}}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}var t,n,a;return t=e,(n=[{key:"handleSuccess",value:function(e){document.querySelector('input[name="gateway_response"]').value=JSON.stringify(e.paymentIntent);var t=document.querySelector('input[name="token-billing-checkbox"]:checked');t&&(document.querySelector('input[name="store_card"]').value=t.value),document.querySelector("input[name=token]").value.length>2&&(document.querySelector('input[name="store_card"]').value=!1),document.getElementById("server-response").submit()}},{key:"handleFailure",value:function(e){var t=document.getElementById("errors");t.textContent="",t.textContent=e,t.hidden=!1,document.getElementById("pay-now").disabled=!1,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden")}}])&&o(t.prototype,n),a&&o(t,a),e}();new c(null!==(e=null===(t=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===t?void 0:t.content)&&void 0!==e?e:"",null!==(n=null===(a=document.querySelector('meta[name="stripe-account-id"]'))||void 0===a?void 0:a.content)&&void 0!==n?n:"").setupStripe().handle()})(); \ No newline at end of file diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 9c8af41f9f78..2174612fb681 100755 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -27,7 +27,7 @@ "/js/clients/payments/square-credit-card.js": "/js/clients/payments/square-credit-card.js?id=8f05ce6bd2d6cae7e5f2", "/js/clients/statements/view.js": "/js/clients/statements/view.js?id=4ed4c8a09803ddd0a9a7", "/js/clients/payments/razorpay-aio.js": "/js/clients/payments/razorpay-aio.js?id=c36ab5621413ef1de7c8", - "/js/clients/payments/stripe-sepa.js": "/js/clients/payments/stripe-sepa.js?id=9134495bcbfdd3e25aef", + "/js/clients/payments/stripe-sepa.js": "/js/clients/payments/stripe-sepa.js?id=59ccac6ad75e28e3bbf2", "/js/clients/payment_methods/authorize-checkout-card.js": "/js/clients/payment_methods/authorize-checkout-card.js?id=61becda97682c7909f29", "/js/clients/payments/stripe-giropay.js": "/js/clients/payments/stripe-giropay.js?id=2a973971ed2b890524ee", "/js/clients/payments/stripe-acss.js": "/js/clients/payments/stripe-acss.js?id=41367f4e80e52a0ab436", diff --git a/resources/views/portal/ninja2020/layout/app.blade.php b/resources/views/portal/ninja2020/layout/app.blade.php index 5a0dcbcb52ea..8b50d6859ef8 100644 --- a/resources/views/portal/ninja2020/layout/app.blade.php +++ b/resources/views/portal/ninja2020/layout/app.blade.php @@ -57,7 +57,7 @@ - @if(!auth()->guard('contact')->user()->user->account->isPaid()) + @if(auth()->guard('contact')->user() && !auth()->guard('contact')->user()->user->account->isPaid()) @endif diff --git a/tests/Feature/Import/CSV/CsvImportTest.php b/tests/Feature/Import/CSV/CsvImportTest.php index 7b5ec9ade2b1..78b521e84083 100644 --- a/tests/Feature/Import/CSV/CsvImportTest.php +++ b/tests/Feature/Import/CSV/CsvImportTest.php @@ -316,8 +316,8 @@ class CsvImportTest extends TestCase $invoice = Invoice::find($invoice_id); $this->assertTrue($invoice->payments()->exists()); - $this->assertEquals(1, $invoice->payments()->count()); - $this->assertEquals(400, $invoice->payments()->sum('payments.amount')); + $this->assertEquals(3, $invoice->payments()->count()); + $this->assertEquals(1200, $invoice->payments()->sum('payments.amount')); } }