From c60045da58fc6ad043f43407d3ccad883ce04f6b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 21 Jan 2022 10:37:39 +1100 Subject: [PATCH 01/11] Fixes for client_id queries on client list --- app/Filters/ClientFilters.php | 10 ++ app/Services/Chart/ChartQueries.php | 6 + app/Services/Chart/ChartService.php | 7 -- tests/Unit/Chart/ChartCurrencyTest.php | 146 +++++++++++++++---------- 4 files changed, 105 insertions(+), 64 deletions(-) diff --git a/app/Filters/ClientFilters.php b/app/Filters/ClientFilters.php index c1b2c2f0595d..c3039605e090 100644 --- a/app/Filters/ClientFilters.php +++ b/app/Filters/ClientFilters.php @@ -70,6 +70,16 @@ class ClientFilters extends QueryFilters } + public function client_id(string $client_id = '') :Builder + { + if (strlen($client_id) == 0) { + return $this->builder; + } + + return $this->builder->where('id', $this->decodePrimaryKey($client_id)); + + } + public function id_number(string $id_number):Builder { return $this->builder->where('id_number', $id_number); diff --git a/app/Services/Chart/ChartQueries.php b/app/Services/Chart/ChartQueries.php index 5cfab1b692ea..9e96587260f6 100644 --- a/app/Services/Chart/ChartQueries.php +++ b/app/Services/Chart/ChartQueries.php @@ -19,6 +19,12 @@ use Illuminate\Support\Facades\DB; trait ChartQueries { + // $currencies = Payment::withTrashed() + // ->where('company_id', $this->company->id) + // ->where('is_deleted', 0) + // ->distinct() + // ->get(['currency_id']); + public function getRevenueQuery($start_date, $end_date) { diff --git a/app/Services/Chart/ChartService.php b/app/Services/Chart/ChartService.php index 7f9a61f3e048..59c788285f80 100644 --- a/app/Services/Chart/ChartService.php +++ b/app/Services/Chart/ChartService.php @@ -35,13 +35,6 @@ class ChartService */ public function getCurrencyCodes() :array { - - // $currencies = Payment::withTrashed() - // ->where('company_id', $this->company->id) - // ->where('is_deleted', 0) - // ->distinct() - // ->get(['currency_id']); - /* Get all the distinct client currencies */ $currencies = Client::withTrashed() ->where('company_id', $this->company->id) diff --git a/tests/Unit/Chart/ChartCurrencyTest.php b/tests/Unit/Chart/ChartCurrencyTest.php index ae55578cf6d1..65171b4b2e7e 100644 --- a/tests/Unit/Chart/ChartCurrencyTest.php +++ b/tests/Unit/Chart/ChartCurrencyTest.php @@ -10,6 +10,8 @@ */ namespace Tests\Unit\Chart; +use App\DataMapper\ClientSettings; +use App\Models\Client; use App\Services\Chart\ChartService; use App\Utils\Ninja; use Tests\MockAccountData; @@ -17,6 +19,7 @@ use Tests\TestCase; /** * @test + * @covers App\Services\Chart\ChartService */ class ChartCurrencyTest extends TestCase { @@ -29,80 +32,109 @@ class ChartCurrencyTest extends TestCase $this->makeTestData(); } - // public function testClientServiceDataSetBuild() - // { + public function testgetCurrencyCodes() + { + $settings = ClientSettings::defaults(); + $settings->currency_id = "1"; //USD - // $haystack = [ - // [ - // 'currency_id' => null, - // 'amount' => 10 - // ], - // [ - // 'currency_id' => 1, - // 'amount' => 11 - // ], - // [ - // 'currency_id' => 2, - // 'amount' => 12 - // ], - // [ - // 'currency_id' => 3, - // 'amount' => 13 - // ], - // ]; + Client::factory()->create([ + 'user_id' => $this->user->id, + 'company_id' => $this->company->id, + 'settings' => $settings, + ]); - // $cs = new ChartService($this->company); + $settings = ClientSettings::defaults(); + $settings->currency_id = "2"; //GBP - // nlog($cs->totals(now()->subYears(10), now())); + Client::factory()->create([ + 'user_id' => $this->user->id, + 'company_id' => $this->company->id, + 'settings' => $settings, + ]); - // $this->assertTrue(is_array($cs->totals(now()->subYears(10), now()))); + $cs = new ChartService($this->company); - // } + $this->assertTrue(is_array($cs->getCurrencyCodes())); - // /* coalesces the company currency with the null currencies */ - // public function testFindNullValueinArray() - // { + $this->assertTrue(in_array("GBP", $cs->getCurrencyCodes())); + $this->assertTrue(in_array("USD", $cs->getCurrencyCodes())); + $this->assertFalse(in_array("AUD", $cs->getCurrencyCodes())); + } - // $haystack = [ - // [ - // 'currency_id' => null, - // 'amount' => 10 - // ], - // [ - // 'currency_id' => 1, - // 'amount' => 11 - // ], - // [ - // 'currency_id' => 2, - // 'amount' => 12 - // ], - // [ - // 'currency_id' => 3, - // 'amount' => 13 - // ], - // ]; + public function testClientServiceDataSetBuild() + { - // $company_currency_id = 1; + $haystack = [ + [ + 'currency_id' => null, + 'amount' => 10 + ], + [ + 'currency_id' => 1, + 'amount' => 11 + ], + [ + 'currency_id' => 2, + 'amount' => 12 + ], + [ + 'currency_id' => 3, + 'amount' => 13 + ], + ]; - // $c_key = array_search($company_currency_id , array_column($haystack, 'currency_id')); + $cs = new ChartService($this->company); - // $this->assertNotEquals($c_key, 2); - // $this->assertEquals($c_key, 1); + nlog($cs->totals(now()->subYears(10), now())); - // $key = array_search(null , array_column($haystack, 'currency_id')); + $this->assertTrue(is_array($cs->totals(now()->subYears(10), now()))); - // $this->assertNotEquals($key, 39); - // $this->assertEquals($key, 0); + } - // $null_currency_amount = $haystack[$key]['amount']; + /* coalesces the company currency with the null currencies */ + public function testFindNullValueinArray() + { - // unset($haystack[$key]); + $haystack = [ + [ + 'currency_id' => null, + 'amount' => 10 + ], + [ + 'currency_id' => 1, + 'amount' => 11 + ], + [ + 'currency_id' => 2, + 'amount' => 12 + ], + [ + 'currency_id' => 3, + 'amount' => 13 + ], + ]; - // $haystack[$c_key]['amount'] += $null_currency_amount; + $company_currency_id = 1; - // $this->assertEquals($haystack[$c_key]['amount'], 21); + $c_key = array_search($company_currency_id , array_column($haystack, 'currency_id')); - // } + $this->assertNotEquals($c_key, 2); + $this->assertEquals($c_key, 1); + + $key = array_search(null , array_column($haystack, 'currency_id')); + + $this->assertNotEquals($key, 39); + $this->assertEquals($key, 0); + + $null_currency_amount = $haystack[$key]['amount']; + + unset($haystack[$key]); + + $haystack[$c_key]['amount'] += $null_currency_amount; + + $this->assertEquals($haystack[$c_key]['amount'], 21); + + } public function testCollectionMerging() From 38031ec7a39c5ba8571a8b45308b795d1628c689 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 21 Jan 2022 12:00:32 +1100 Subject: [PATCH 02/11] Fixes for chart tests --- app/Http/Controllers/ChartController.php | 10 ++-- app/Http/Requests/Chart/ShowChartRequest.php | 16 ++++++ app/Services/Chart/ChartService.php | 23 ++++---- routes/api.php | 3 ++ tests/Unit/Chart/ChartCurrencyTest.php | 56 ++++++++++++++++++++ 5 files changed, 94 insertions(+), 14 deletions(-) diff --git a/app/Http/Controllers/ChartController.php b/app/Http/Controllers/ChartController.php index bc0b254f8c27..aedb958f18a7 100644 --- a/app/Http/Controllers/ChartController.php +++ b/app/Http/Controllers/ChartController.php @@ -12,6 +12,7 @@ namespace App\Http\Controllers; use App\Http\Requests\Chart\ShowChartRequest; +use App\Services\Chart\ChartService; use Illuminate\Http\Request; use Illuminate\Http\Response; @@ -25,8 +26,8 @@ class ChartController extends BaseController /** * @OA\Post( - * path="/api/v1/charts", - * operationId="getCharts", + * path="/api/v1/charts/totals", + * operationId="getChartTotals", * tags={"charts"}, * summary="Get chart data", * description="Get chart data", @@ -67,10 +68,11 @@ class ChartController extends BaseController * @param Request $request * @return Response|mixed */ - public function index(ShowChartRequest $request) + public function totals(ShowChartRequest $request) { + $cs = new ChartService(auth()->user()->company()); - return response()->json([],200); + return response()->json($cs->totals($request->input('start_date'), $request->input('end_date')),200); } } diff --git a/app/Http/Requests/Chart/ShowChartRequest.php b/app/Http/Requests/Chart/ShowChartRequest.php index 0c510f1940ec..a817a3c035f5 100644 --- a/app/Http/Requests/Chart/ShowChartRequest.php +++ b/app/Http/Requests/Chart/ShowChartRequest.php @@ -29,6 +29,22 @@ class ShowChartRequest extends Request public function rules() { return [ + 'start_date' => 'date', + 'end_date' => 'date', ]; } + + protected function prepareForValidation() + { + $input = $this->all(); + + if(!array_key_exists('start_date', $input)) + $input['start_date'] = now()->subDays(20); + + if(!array_key_exists('end_date', $input)) + $input['end_date'] = now(); + + $this->replace($input); + + } } diff --git a/app/Services/Chart/ChartService.php b/app/Services/Chart/ChartService.php index 59c788285f80..320b766fca70 100644 --- a/app/Services/Chart/ChartService.php +++ b/app/Services/Chart/ChartService.php @@ -50,7 +50,7 @@ class ChartService ->where('company_id', $this->company->id) ->where('is_deleted', 0) ->distinct() - ->get(['currency_id']); + ->pluck('currency_id as id'); /* Merge and filter by unique */ $currencies = $currencies->merge($expense_currencies)->unique(); @@ -72,10 +72,11 @@ class ChartService - public function totals($start_date, $end_date) + public function totals($start_date, $end_date) :array { $data = []; + $data['currencies'] = $this->getCurrencyCodes(); $data['revenue'] = $this->getRevenue($start_date, $end_date); $data['outstanding'] = $this->getOutstanding($start_date, $end_date); $data['expenses'] = $this->getExpenses($start_date, $end_date); @@ -110,7 +111,7 @@ class ChartService } - private function getRevenue($start_date, $end_date) + private function getRevenue($start_date, $end_date) :array { $revenue = $this->getRevenueQuery($start_date, $end_date); $revenue = $this->parseTotals($revenue); @@ -119,7 +120,7 @@ class ChartService return $revenue; } - private function getOutstanding($start_date, $end_date) + private function getOutstanding($start_date, $end_date) :array { $outstanding = $this->getOutstandingQuery($start_date, $end_date); $outstanding = $this->parseTotals($outstanding); @@ -128,16 +129,15 @@ class ChartService return $outstanding; } - private function getExpenses($start_date, $end_date) + private function getExpenses($start_date, $end_date) :array { $expenses = $this->getExpenseQuery($start_date, $end_date); $expenses = $this->parseTotals($expenses); $expenses = $this->addCountryCodes($expenses); - return $expenses; } - private function parseTotals($data_set) + private function parseTotals($data_set) :array { /* Find the key where the company currency amount lives*/ $c_key = array_search($this->company->id , array_column($data_set, 'currency_id')); @@ -160,22 +160,25 @@ class ChartService } - private function addCountryCodes($data_set) + private function addCountryCodes($data_set) :array { $currencies = Cache::get('currencies'); foreach($data_set as $key => $value) { - $data_set[$key]['code'] = $this->getCode($currencies, $value); + $data_set[$key]->currency_id = str_replace('"', '', $value->currency_id); + $data_set[$key]->code = $this->getCode($currencies, $data_set[$key]->currency_id); } return $data_set; } - private function getCode($currencies, $currency_id) + private function getCode($currencies, $currency_id) :string { + nlog($currency_id); + $currency = $currencies->filter(function ($item) use($currency_id) { return $item->id == $currency_id; })->first(); diff --git a/routes/api.php b/routes/api.php index 796b50cc43bf..e0756307c8b7 100644 --- a/routes/api.php +++ b/routes/api.php @@ -31,6 +31,9 @@ Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'a Route::get('activities', 'ActivityController@index'); Route::get('activities/download_entity/{activity}', 'ActivityController@downloadHistoricalEntity'); + + Route::post('charts/totals', 'ChartController@totals')->name('chart.totals'); + Route::post('claim_license', 'LicenseController@index')->name('license.index'); Route::resource('clients', 'ClientController'); // name = (clients. index / create / show / update / destroy / edit diff --git a/tests/Unit/Chart/ChartCurrencyTest.php b/tests/Unit/Chart/ChartCurrencyTest.php index 65171b4b2e7e..a18b07d3d1a6 100644 --- a/tests/Unit/Chart/ChartCurrencyTest.php +++ b/tests/Unit/Chart/ChartCurrencyTest.php @@ -12,8 +12,10 @@ namespace Tests\Unit\Chart; use App\DataMapper\ClientSettings; use App\Models\Client; +use App\Models\Invoice; use App\Services\Chart\ChartService; use App\Utils\Ninja; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Tests\MockAccountData; use Tests\TestCase; @@ -24,6 +26,7 @@ use Tests\TestCase; class ChartCurrencyTest extends TestCase { use MockAccountData; + use DatabaseTransactions; public function setUp() :void { @@ -32,6 +35,42 @@ class ChartCurrencyTest extends TestCase $this->makeTestData(); } + public function testRevenueValues() + { + + Invoice::factory()->create([ + 'client_id' => $this->client->id, + 'user_id' => $this->user->id, + 'company_id' => $this->company->id, + 'paid_to_date' => 100, + 'status_id' => 4, + 'date' => now(), + 'due_date'=> now(), + 'number' => 'db_record' + ]); + + $this->assertDatabaseHas('invoices', ['number' => 'db_record']); + + $cs = new ChartService($this->company); + nlog($cs->getRevenueQuery(now()->subDays(20)->format('Y-m-d'), now()->addDays(100)->format('Y-m-d'))); + + $data = [ + 'start_date' => now()->subDays(30)->format('Y-m-d'), + 'end_date' => now()->addDay()->format('Y-m-d') + ]; + + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->post('/api/v1/charts/totals', $data); + + $response->assertStatus(200); + + nlog($response->json()); + + } + + public function testgetCurrencyCodes() { $settings = ClientSettings::defaults(); @@ -61,6 +100,23 @@ class ChartCurrencyTest extends TestCase $this->assertFalse(in_array("AUD", $cs->getCurrencyCodes())); } + public function testGetChartTotalsApi() + { + + $data = [ + 'start_date' => now()->subDays(30)->format('Y-m-d'), + 'end_date' => now()->format('Y-m-d') + ]; + + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->post('/api/v1/charts/totals', $data); + + $response->assertStatus(200); + + } + public function testClientServiceDataSetBuild() { From 4fededc59ae08cc577817f601cc35c2e855d65a9 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 21 Jan 2022 12:25:13 +1100 Subject: [PATCH 03/11] Charting --- app/Services/Chart/ChartQueries.php | 12 +++++----- app/Services/Chart/ChartService.php | 31 ++------------------------ tests/Unit/Chart/ChartCurrencyTest.php | 8 +++---- 3 files changed, 11 insertions(+), 40 deletions(-) diff --git a/app/Services/Chart/ChartQueries.php b/app/Services/Chart/ChartQueries.php index 9e96587260f6..bb438a25ab04 100644 --- a/app/Services/Chart/ChartQueries.php +++ b/app/Services/Chart/ChartQueries.php @@ -31,7 +31,7 @@ trait ChartQueries return DB::select( DB::raw(" SELECT sum(invoices.paid_to_date) as paid_to_date, - JSON_EXTRACT( settings, '$.currency_id' ) AS currency_id + IFNULL(JSON_EXTRACT( settings, '$.currency_id' ), :company_currency) AS currency_id FROM clients JOIN invoices on invoices.client_id = clients.id @@ -42,7 +42,7 @@ trait ChartQueries AND invoices.is_deleted = 0 AND (invoices.date BETWEEN :start_date AND :end_date) GROUP BY currency_id - "), ['company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date] ); + "), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date] ); } @@ -52,7 +52,7 @@ trait ChartQueries return DB::select( DB::raw(" SELECT sum(invoices.balance) as balance, - JSON_EXTRACT( settings, '$.currency_id' ) AS currency_id + IFNULL(JSON_EXTRACT( settings, '$.currency_id' ), :company_currency) AS currency_id FROM clients JOIN invoices on invoices.client_id = clients.id @@ -63,7 +63,7 @@ trait ChartQueries AND invoices.is_deleted = 0 AND (invoices.due_date BETWEEN :start_date AND :end_date) GROUP BY currency_id - "), ['company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date] ); + "), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date] ); } @@ -72,13 +72,13 @@ trait ChartQueries return DB::select( DB::raw(" SELECT sum(expenses.amount) as amount, - expenses.currency_id as currency_id + IFNULL(expenses.currency_id, :company_currency) as currency_id FROM expenses WHERE expenses.is_deleted = 0 AND expenses.company_id = :company_id AND (expenses.date BETWEEN :start_date AND :end_date) GROUP BY currency_id - "), ['company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date] ); + "), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date] ); } diff --git a/app/Services/Chart/ChartService.php b/app/Services/Chart/ChartService.php index 320b766fca70..9a65f7ad17ba 100644 --- a/app/Services/Chart/ChartService.php +++ b/app/Services/Chart/ChartService.php @@ -70,8 +70,6 @@ class ChartService } - - public function totals($start_date, $end_date) :array { $data = []; @@ -114,7 +112,6 @@ class ChartService private function getRevenue($start_date, $end_date) :array { $revenue = $this->getRevenueQuery($start_date, $end_date); - $revenue = $this->parseTotals($revenue); $revenue = $this->addCountryCodes($revenue); return $revenue; @@ -123,7 +120,6 @@ class ChartService private function getOutstanding($start_date, $end_date) :array { $outstanding = $this->getOutstandingQuery($start_date, $end_date); - $outstanding = $this->parseTotals($outstanding); $outstanding = $this->addCountryCodes($outstanding); return $outstanding; @@ -132,34 +128,11 @@ class ChartService private function getExpenses($start_date, $end_date) :array { $expenses = $this->getExpenseQuery($start_date, $end_date); - $expenses = $this->parseTotals($expenses); $expenses = $this->addCountryCodes($expenses); + return $expenses; } - private function parseTotals($data_set) :array - { - /* Find the key where the company currency amount lives*/ - $c_key = array_search($this->company->id , array_column($data_set, 'currency_id')); - - if(!$c_key) - return $data_set; - - /* Find the key where null currency_id lives */ - $key = array_search(null , array_column($data_set, 'currency_id')); - - if(!$key) - return $data_set; - - $null_currency_amount = $data_set[$key]['amount']; - unset($data_set[$key]); - - $data_set[$c_key]['amount'] += $null_currency_amount; - - return $data_set; - - } - private function addCountryCodes($data_set) :array { @@ -177,7 +150,7 @@ class ChartService private function getCode($currencies, $currency_id) :string { - nlog($currency_id); + $currency_id = str_replace('"', '', $currency_id); $currency = $currencies->filter(function ($item) use($currency_id) { return $item->id == $currency_id; diff --git a/tests/Unit/Chart/ChartCurrencyTest.php b/tests/Unit/Chart/ChartCurrencyTest.php index a18b07d3d1a6..c664839cd67e 100644 --- a/tests/Unit/Chart/ChartCurrencyTest.php +++ b/tests/Unit/Chart/ChartCurrencyTest.php @@ -52,11 +52,11 @@ class ChartCurrencyTest extends TestCase $this->assertDatabaseHas('invoices', ['number' => 'db_record']); $cs = new ChartService($this->company); - nlog($cs->getRevenueQuery(now()->subDays(20)->format('Y-m-d'), now()->addDays(100)->format('Y-m-d'))); + // nlog($cs->getRevenueQuery(now()->subDays(20)->format('Y-m-d'), now()->addDays(100)->format('Y-m-d'))); $data = [ 'start_date' => now()->subDays(30)->format('Y-m-d'), - 'end_date' => now()->addDay()->format('Y-m-d') + 'end_date' => now()->addDays(100)->format('Y-m-d') ]; $response = $this->withHeaders([ @@ -66,8 +66,6 @@ class ChartCurrencyTest extends TestCase $response->assertStatus(200); - nlog($response->json()); - } @@ -141,7 +139,7 @@ class ChartCurrencyTest extends TestCase $cs = new ChartService($this->company); - nlog($cs->totals(now()->subYears(10), now())); + // nlog($cs->totals(now()->subYears(10), now())); $this->assertTrue(is_array($cs->totals(now()->subYears(10), now()))); From 5471eb2571e67bdc81fe96ee12cd3ee3c7a1d272 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 21 Jan 2022 14:35:16 +1100 Subject: [PATCH 04/11] Fixes for Stripe FPX --- app/PaymentDrivers/Stripe/FPX.php | 2 +- app/PaymentDrivers/StripePaymentDriver.php | 1 + app/Services/Chart/ChartQueries.php | 113 +++++++++++++++++++++ app/Services/Chart/ChartService.php | 41 +++----- 4 files changed, 129 insertions(+), 28 deletions(-) diff --git a/app/PaymentDrivers/Stripe/FPX.php b/app/PaymentDrivers/Stripe/FPX.php index c1817cadd4b1..c06c6ca58ea3 100644 --- a/app/PaymentDrivers/Stripe/FPX.php +++ b/app/PaymentDrivers/Stripe/FPX.php @@ -47,7 +47,7 @@ class FPX $intent = \Stripe\PaymentIntent::create([ 'amount' => $data['stripe_amount'], - 'currency' => 'eur', + 'currency' => $this->stripe->client->getCurrencyCode(), 'payment_method_types' => ['fpx'], 'customer' => $this->stripe->findOrCreateCustomer(), 'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')), diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index a1a055821d48..39f896be0583 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -93,6 +93,7 @@ class StripePaymentDriver extends BaseDriver GatewayType::BANCONTACT => Bancontact::class, GatewayType::BECS => BECS::class, GatewayType::ACSS => ACSS::class, + GatewayType::FPX => FPX::class, ]; const SYSTEM_LOG_TYPE = SystemLog::TYPE_STRIPE; diff --git a/app/Services/Chart/ChartQueries.php b/app/Services/Chart/ChartQueries.php index bb438a25ab04..b3d3f53de10b 100644 --- a/app/Services/Chart/ChartQueries.php +++ b/app/Services/Chart/ChartQueries.php @@ -11,6 +11,9 @@ namespace App\Services\Chart; +use App\Models\Expense; +use App\Models\Invoice; +use App\Models\Payment; use Illuminate\Support\Facades\DB; /** @@ -82,5 +85,115 @@ trait ChartQueries } + public function getPaymentQuery($start_date, $end_date) + { + return DB::select( DB::raw(" + SELECT sum(expenses.amount) as amount, + IFNULL(expenses.currency_id, :company_currency) as currency_id + FROM expenses + WHERE expenses.is_deleted = 0 + AND expenses.company_id = :company_id + AND (expenses.date BETWEEN :start_date AND :end_date) + GROUP BY currency_id + "), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date] ); + } + + public function getChartData($start_date, $end_date, $group_by = 'DAYOFYEAR', $entity_type = 'invoice', $currency_id) + { + + if(!$currency_id) + $currency_id = $this->company->settings->currency_id; + + return DB::select( DB::raw(" + SELECT + sum(invoices.balance) as balance, + sum(invoices.amount) as amount, + IFNULL(JSON_EXTRACT( settings, '$.currency_id' ), :company_currency) AS currency_id + FROM clients + JOIN invoices + on invoices.client_id = clients.id + WHERE invoices.status_id IN (2,3,4) + AND invoices.company_id = :company_id + AND clients.is_deleted = 0 + AND invoices.is_deleted = 0 + AND (invoices.date BETWEEN :start_date AND :end_date) + HAVING currency_id = :currency_id + GROUP BY :group_by + "), [ + 'currency_id' => $currency_id, + 'group_by' => $group_by, + 'company_currency' => $this->company->settings->currency_id, + 'company_id' => $this->company->id, + 'start_date' => $start_date, + 'end_date' => $end_date + ]); + + + } + } + + + + +/* + public function payments($accountId, $userId, $viewAll) + { + $payments = DB::table('payments') + ->leftJoin('clients', 'clients.id', '=', 'payments.client_id') + ->leftJoin('contacts', 'contacts.client_id', '=', 'clients.id') + ->leftJoin('invoices', 'invoices.id', '=', 'payments.invoice_id') + ->where('payments.account_id', '=', $accountId) + ->where('payments.is_deleted', '=', false) + ->where('invoices.is_deleted', '=', false) + ->where('clients.is_deleted', '=', false) + ->where('contacts.deleted_at', '=', null) + ->where('contacts.is_primary', '=', true) + ->whereNotIn('payments.payment_status_id', [PAYMENT_STATUS_VOIDED, PAYMENT_STATUS_FAILED]); + + if (! $viewAll) { + $payments = $payments->where('payments.user_id', '=', $userId); + } + + return $payments->select(['payments.payment_date', DB::raw('(payments.amount - payments.refunded) as amount'), 'invoices.public_id', 'invoices.invoice_number', 'clients.name as client_name', 'contacts.email', 'contacts.first_name', 'contacts.last_name', 'clients.currency_id', 'clients.public_id as client_public_id', 'clients.user_id as client_user_id']) + ->orderBy('payments.payment_date', 'desc') + ->take(100) + ->get(); + } + + public function oustanding($start_date, $end_date) + { + + $company_currency = (int) $this->company->settings->currency_id; + + $results = \DB::select( \DB::raw(" + SELECT + sum(invoices.balance) as balance, + JSON_EXTRACT( settings, '$.currency_id' ) AS currency_id + FROM clients + JOIN invoices + on invoices.client_id = clients.id + WHERE invoices.status_id IN (2,3) + AND invoices.company_id = :company_id + AND invoices.balance > 0 + AND clients.is_deleted = 0 + AND invoices.is_deleted = 0 + AND (invoices.due_date BETWEEN :start_date AND :end_date) + GROUP BY currency_id + "), ['company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date] ); + + //return $results; + + //the output here will most likely contain a currency_id = null value - we need to merge this value with the company currency + + } + + + + + + + + + */ \ No newline at end of file diff --git a/app/Services/Chart/ChartService.php b/app/Services/Chart/ChartService.php index 9a65f7ad17ba..db932763986f 100644 --- a/app/Services/Chart/ChartService.php +++ b/app/Services/Chart/ChartService.php @@ -70,6 +70,16 @@ class ChartService } +/* Payments */ + public function payments($start_date, $end_date) + { + $payments = $this->getPaymentQuery(); + } + +/* Payments */ + +/* Totals */ + public function totals($start_date, $end_date) :array { $data = []; @@ -82,33 +92,6 @@ class ChartService return $data; } - public function oustanding($start_date, $end_date) - { - - $company_currency = (int) $this->company->settings->currency_id; - - $results = \DB::select( \DB::raw(" - SELECT - sum(invoices.balance) as balance, - JSON_EXTRACT( settings, '$.currency_id' ) AS currency_id - FROM clients - JOIN invoices - on invoices.client_id = clients.id - WHERE invoices.status_id IN (2,3) - AND invoices.company_id = :company_id - AND invoices.balance > 0 - AND clients.is_deleted = 0 - AND invoices.is_deleted = 0 - AND (invoices.due_date BETWEEN :start_date AND :end_date) - GROUP BY currency_id - "), ['company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date] ); - - //return $results; - - //the output here will most likely contain a currency_id = null value - we need to merge this value with the company currency - - } - private function getRevenue($start_date, $end_date) :array { $revenue = $this->getRevenueQuery($start_date, $end_date); @@ -133,6 +116,10 @@ class ChartService return $expenses; } +/* Totals */ + +/* Helpers */ + private function addCountryCodes($data_set) :array { From 6b9f2118120ffabfbb0e3086a4e305bd9694bfd9 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 21 Jan 2022 14:58:58 +1100 Subject: [PATCH 05/11] Update route throttling limits --- app/Http/Kernel.php | 2 +- app/Providers/RouteServiceProvider.php | 1 - routes/api.php | 20 ++++++++++---------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 096026772db8..2c281151206c 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -95,7 +95,7 @@ class Kernel extends HttpKernel ], 'api' => [ - 'throttle:300,1', + // 'throttle:300,1', 'bindings', 'query_logging', ], diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index a67146b38c8f..87f1e84c5a3c 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -34,7 +34,6 @@ class RouteServiceProvider extends ServiceProvider */ public function boot() { - // parent::boot(); } diff --git a/routes/api.php b/routes/api.php index e0756307c8b7..a3c7936229fc 100644 --- a/routes/api.php +++ b/routes/api.php @@ -13,17 +13,17 @@ use Illuminate\Support\Facades\Route; -Route::group(['middleware' => ['api_secret_check']], function () { +Route::group(['middleware' => ['throttle:10,1', 'api_secret_check']], function () { Route::post('api/v1/signup', 'AccountController@store')->name('signup.submit'); Route::post('api/v1/oauth_login', 'Auth\LoginController@oauthApiLogin'); }); -Route::group(['middleware' => ['api_secret_check','email_db']], function () { +Route::group(['middleware' => ['throttle:10,1','api_secret_check','email_db']], function () { Route::post('api/v1/login', 'Auth\LoginController@apiLogin')->name('login.submit'); Route::post('api/v1/reset_password', 'Auth\ForgotPasswordController@sendResetLinkEmail'); }); -Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'api/v1', 'as' => 'api.'], function () { +Route::group(['middleware' => ['throttle:300,1', 'api_db', 'token_auth', 'locale'], 'prefix' => 'api/v1', 'as' => 'api.'], function () { Route::post('check_subdomain', 'SubdomainController@index')->name('check_subdomain'); Route::get('ping', 'PingController@index')->name('ping'); Route::get('health_check', 'PingController@health')->name('health_check'); @@ -216,17 +216,17 @@ Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'a }); Route::match(['get', 'post'], 'payment_webhook/{company_key}/{company_gateway_id}', 'PaymentWebhookController') - ->middleware(['guest']) + ->middleware(['throttle:1000,1','guest']) ->name('payment_webhook'); Route::match(['get', 'post'], 'payment_notification_webhook/{company_key}/{company_gateway_id}/{client}', 'PaymentNotificationWebhookController') - ->middleware(['guest']) + ->middleware(['throttle:1000,1', 'guest']) ->name('payment_notification_webhook'); -Route::post('api/v1/postmark_webhook', 'PostMarkController@webhook')->middleware(['throttle:10000,1']); -Route::get('token_hash_router', 'OneTimeTokenController@router'); -Route::get('webcron', 'WebCronController@index'); -Route::post('api/v1/get_migration_account', 'HostedMigrationController@getAccount')->middleware('guest'); -Route::post('api/v1/confirm_forwarding', 'HostedMigrationController@confirmForwarding')->middleware('guest'); +Route::post('api/v1/postmark_webhook', 'PostMarkController@webhook')->middleware('throttle:1000,1'); +Route::get('token_hash_router', 'OneTimeTokenController@router')->middleware('throttle:100,1'); +Route::get('webcron', 'WebCronController@index')->middleware('throttle:100,1');; +Route::post('api/v1/get_migration_account', 'HostedMigrationController@getAccount')->middleware('guest')->middleware('throttle:100,1');; +Route::post('api/v1/confirm_forwarding', 'HostedMigrationController@confirmForwarding')->middleware('guest')->middleware('throttle:100,1');; Route::fallback('BaseController@notFound'); From b819c1018e65dbaa76029e356d18d5d5c383ec10 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 21 Jan 2022 15:00:49 +1100 Subject: [PATCH 06/11] Backport indexing on message_id for invitations --- .../migrations/2014_10_13_000000_create_users_table.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/database/migrations/2014_10_13_000000_create_users_table.php b/database/migrations/2014_10_13_000000_create_users_table.php index c14b37cde2cd..9736fc0f0b21 100644 --- a/database/migrations/2014_10_13_000000_create_users_table.php +++ b/database/migrations/2014_10_13_000000_create_users_table.php @@ -592,7 +592,7 @@ class CreateUsersTable extends Migration $t->unsignedInteger('credit_id')->index(); $t->string('key')->index(); $t->string('transaction_reference')->nullable(); - $t->string('message_id')->nullable(); + $t->string('message_id')->nullable()->index(); $t->mediumText('email_error')->nullable(); $t->text('signature_base64')->nullable(); $t->datetime('signature_date')->nullable(); @@ -829,7 +829,7 @@ class CreateUsersTable extends Migration $t->unsignedInteger('invoice_id')->index(); $t->string('key')->index(); $t->string('transaction_reference')->nullable(); - $t->string('message_id')->nullable(); + $t->string('message_id')->nullable()->index(); $t->mediumText('email_error')->nullable(); $t->text('signature_base64')->nullable(); $t->datetime('signature_date')->nullable(); @@ -858,7 +858,7 @@ class CreateUsersTable extends Migration $t->unsignedInteger('quote_id')->index(); $t->string('key')->index(); $t->string('transaction_reference')->nullable(); - $t->string('message_id')->nullable(); + $t->string('message_id')->nullable()->index(); $t->mediumText('email_error')->nullable(); $t->text('signature_base64')->nullable(); $t->datetime('signature_date')->nullable(); From 4ed115143f41815b2aa18f0196d500f79ac01fa9 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 21 Jan 2022 17:04:01 +1100 Subject: [PATCH 07/11] Charts for react dashboard --- app/Http/Controllers/ChartController.php | 9 +++- app/Services/Chart/ChartQueries.php | 68 +++++++++++++++++++----- app/Services/Chart/ChartService.php | 48 ++++++++++++----- routes/api.php | 1 + 4 files changed, 98 insertions(+), 28 deletions(-) diff --git a/app/Http/Controllers/ChartController.php b/app/Http/Controllers/ChartController.php index aedb958f18a7..2d3518ef484b 100644 --- a/app/Http/Controllers/ChartController.php +++ b/app/Http/Controllers/ChartController.php @@ -72,7 +72,14 @@ class ChartController extends BaseController { $cs = new ChartService(auth()->user()->company()); - return response()->json($cs->totals($request->input('start_date'), $request->input('end_date')),200); + return response()->json($cs->totals($request->input('start_date'), $request->input('end_date')), 200); + } + + public function chart_summary(ShowChartRequest $request) + { + $cs = new ChartService(auth()->user()->company()); + + return response()->json($cs->chart_summary($request->input('start_date'), $request->input('end_date')), 200); } } diff --git a/app/Services/Chart/ChartQueries.php b/app/Services/Chart/ChartQueries.php index b3d3f53de10b..6e874cd5c87e 100644 --- a/app/Services/Chart/ChartQueries.php +++ b/app/Services/Chart/ChartQueries.php @@ -98,37 +98,79 @@ trait ChartQueries "), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date] ); } - public function getChartData($start_date, $end_date, $group_by = 'DAYOFYEAR', $entity_type = 'invoice', $currency_id) + public function getInvoiceChartQuery($start_date, $end_date, $currency_id) { - if(!$currency_id) - $currency_id = $this->company->settings->currency_id; - - return DB::select( DB::raw(" + return DB::select( DB::raw(" SELECT - sum(invoices.balance) as balance, - sum(invoices.amount) as amount, - IFNULL(JSON_EXTRACT( settings, '$.currency_id' ), :company_currency) AS currency_id + -- sum(invoices.balance) as balance, + sum(invoices.amount) as total, + invoices.date, + IFNULL(CAST(JSON_EXTRACT( settings, '$.currency_id' ) AS SIGNED), :company_currency) AS currency_id FROM clients JOIN invoices on invoices.client_id = clients.id WHERE invoices.status_id IN (2,3,4) + AND (invoices.date BETWEEN :start_date AND :end_date) AND invoices.company_id = :company_id AND clients.is_deleted = 0 AND invoices.is_deleted = 0 - AND (invoices.date BETWEEN :start_date AND :end_date) + GROUP BY invoices.date HAVING currency_id = :currency_id - GROUP BY :group_by "), [ + 'company_currency' => $this->company->settings->currency_id, 'currency_id' => $currency_id, - 'group_by' => $group_by, - 'company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date ]); + } - + public function getPaymentChartQuery($start_date, $end_date, $currency_id) + { + + return DB::select( DB::raw(" + SELECT + sum(payments.amount - payments.refunded) as total, + payments.date, + IFNULL(payments.currency_id, :company_currency) AS currency_id + FROM payments + WHERE payments.status_id IN (4,5,6) + AND (payments.date BETWEEN :start_date AND :end_date) + AND payments.company_id = :company_id + AND payments.is_deleted = 0 + GROUP BY payments.date + HAVING currency_id = :currency_id + "), [ + 'company_currency' => $this->company->settings->currency_id, + 'currency_id' => $currency_id, + 'company_id' => $this->company->id, + 'start_date' => $start_date, + 'end_date' => $end_date + ]); + } + + public function getExpenseChartQuery($start_date, $end_date, $currency_id) + { + + return DB::select( DB::raw(" + SELECT + sum(expenses.amount) as total, + expenses.date, + IFNULL(expenses.currency_id, :company_currency) AS currency_id + FROM expenses + WHERE (expenses.date BETWEEN :start_date AND :end_date) + AND expenses.company_id = :company_id + AND expenses.is_deleted = 0 + GROUP BY expenses.date + HAVING currency_id = :currency_id + "), [ + 'company_currency' => $this->company->settings->currency_id, + 'currency_id' => $currency_id, + 'company_id' => $this->company->id, + 'start_date' => $start_date, + 'end_date' => $end_date + ]); } diff --git a/app/Services/Chart/ChartService.php b/app/Services/Chart/ChartService.php index db932763986f..65907280be9f 100644 --- a/app/Services/Chart/ChartService.php +++ b/app/Services/Chart/ChartService.php @@ -70,13 +70,24 @@ class ChartService } -/* Payments */ - public function payments($start_date, $end_date) +/* Chart Data */ + public function chart_summary($start_date, $end_date) :array { - $payments = $this->getPaymentQuery(); + $currencies = $this->getCurrencyCodes(); + + $data = []; + + foreach($currencies as $key => $value) + { + $data[$key]['invoices'] = $this->getInvoiceChartQuery($start_date, $end_date, $key); + $data[$key]['payments'] = $this->getPaymentChartQuery($start_date, $end_date, $key); + $data[$key]['expenses'] = $this->getExpenseChartQuery($start_date, $end_date, $key); + } + + return $data; } -/* Payments */ +/* Chart Data */ /* Totals */ @@ -85,33 +96,42 @@ class ChartService $data = []; $data['currencies'] = $this->getCurrencyCodes(); - $data['revenue'] = $this->getRevenue($start_date, $end_date); - $data['outstanding'] = $this->getOutstanding($start_date, $end_date); - $data['expenses'] = $this->getExpenses($start_date, $end_date); + + foreach($data['currencies'] as $key => $value) + { + $revenue = $this->getRevenue($start_date, $end_date); + $outstanding = $this->getOutstanding($start_date, $end_date); + $expenses = $this->getExpenses($start_date, $end_date); + + $data[$key]['revenue'] = count($revenue) > 0 ? $revenue[array_search($key,array_column($revenue,'currency_id'))] : new \stdClass; + $data[$key]['outstanding'] = count($outstanding) > 0 ? $outstanding[array_search($key,array_column($outstanding,'currency_id'))] : new \stdClass; + $data[$key]['expenses'] = count($expenses) > 0 ? $expenses[array_search($key,array_column($expenses,'currency_id'))] : new \stdClass; + + } return $data; } - private function getRevenue($start_date, $end_date) :array + public function getRevenue($start_date, $end_date) :array { $revenue = $this->getRevenueQuery($start_date, $end_date); - $revenue = $this->addCountryCodes($revenue); + $revenue = $this->addCurrencyCodes($revenue); return $revenue; } - private function getOutstanding($start_date, $end_date) :array + public function getOutstanding($start_date, $end_date) :array { $outstanding = $this->getOutstandingQuery($start_date, $end_date); - $outstanding = $this->addCountryCodes($outstanding); + $outstanding = $this->addCurrencyCodes($outstanding); return $outstanding; } - private function getExpenses($start_date, $end_date) :array + public function getExpenses($start_date, $end_date) :array { $expenses = $this->getExpenseQuery($start_date, $end_date); - $expenses = $this->addCountryCodes($expenses); + $expenses = $this->addCurrencyCodes($expenses); return $expenses; } @@ -120,7 +140,7 @@ class ChartService /* Helpers */ - private function addCountryCodes($data_set) :array + private function addCurrencyCodes($data_set) :array { $currencies = Cache::get('currencies'); diff --git a/routes/api.php b/routes/api.php index a3c7936229fc..e7f71619a675 100644 --- a/routes/api.php +++ b/routes/api.php @@ -33,6 +33,7 @@ Route::group(['middleware' => ['throttle:300,1', 'api_db', 'token_auth', 'locale Route::post('charts/totals', 'ChartController@totals')->name('chart.totals'); + Route::post('charts/chart_summary', 'ChartController@chart_summary')->name('chart.chart_summary'); Route::post('claim_license', 'LicenseController@index')->name('license.index'); From 9715caeff056d92eaa4e3a4d7be997d523aac37a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 21 Jan 2022 17:07:50 +1100 Subject: [PATCH 08/11] Query cleanup --- app/Services/Chart/ChartQueries.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Services/Chart/ChartQueries.php b/app/Services/Chart/ChartQueries.php index 6e874cd5c87e..83a6abe1c613 100644 --- a/app/Services/Chart/ChartQueries.php +++ b/app/Services/Chart/ChartQueries.php @@ -103,7 +103,6 @@ trait ChartQueries return DB::select( DB::raw(" SELECT - -- sum(invoices.balance) as balance, sum(invoices.amount) as total, invoices.date, IFNULL(CAST(JSON_EXTRACT( settings, '$.currency_id' ) AS SIGNED), :company_currency) AS currency_id From f4ea1d730c0d2ac5d3c5dd0391bfcdf515edf266 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 22 Jan 2022 15:11:11 +1100 Subject: [PATCH 09/11] Fixes for sofort - hosted --- app/PaymentDrivers/Stripe/SOFORT.php | 2 ++ public/js/clients/payments/stripe-sofort.js | 2 +- public/mix-manifest.json | 2 +- resources/js/clients/payments/stripe-sofort.js | 15 ++++++++++++--- .../gateways/stripe/sofort/pay.blade.php | 9 ++++++++- 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/app/PaymentDrivers/Stripe/SOFORT.php b/app/PaymentDrivers/Stripe/SOFORT.php index 618e4c196db4..d76b9ed43e98 100644 --- a/app/PaymentDrivers/Stripe/SOFORT.php +++ b/app/PaymentDrivers/Stripe/SOFORT.php @@ -37,6 +37,8 @@ class SOFORT public function paymentView(array $data) { + $this->stripe->init(); + $data['gateway'] = $this->stripe; $data['return_url'] = $this->buildReturnUrl(); $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); diff --git a/public/js/clients/payments/stripe-sofort.js b/public/js/clients/payments/stripe-sofort.js index a2f89416d875..354137cc77c6 100755 --- a/public/js/clients/payments/stripe-sofort.js +++ b/public/js/clients/payments/stripe-sofort.js @@ -1,2 +1,2 @@ /*! For license information please see stripe-sofort.js.LICENSE.txt */ -(()=>{var e,t,n,r;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=null!==(e=null===(t=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===t?void 0:t.content)&&void 0!==e?e:"",i=null!==(n=null===(r=document.querySelector('meta[name="stripe-account-id"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"";new function e(t,n){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o(this,"setupStripe",(function(){return r.stripe=Stripe(r.key),r.stripeConnect&&(r.stripe.stripeAccount=i),r})),o(this,"handle",(function(){document.getElementById("pay-now").addEventListener("click",(function(e){document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),r.stripe.confirmSofortPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{sofort:{country:document.querySelector('meta[name="country"]').content}},return_url:document.querySelector('meta[name="return-url"]').content})}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}(c,i).setupStripe().handle()})(); \ No newline at end of file +(()=>{var e,t,n,r;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}new function e(t,n){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o(this,"setupStripe",(function(){return r.stripeConnect?r.stripe=Stripe(r.key,{stripeAccount:r.stripeConnect}):r.stripe=Stripe(r.key),r})),o(this,"handle",(function(){document.getElementById("pay-now").addEventListener("click",(function(e){document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),r.stripe.confirmSofortPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{sofort:{country:document.querySelector('meta[name="country"]').content}},return_url:document.querySelector('meta[name="return-url"]').content})}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}(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===(r=document.querySelector('meta[name="stripe-account-id"]'))||void 0===r?void 0:r.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 b240eb83b68f..3343cf7e7f0f 100755 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -5,7 +5,7 @@ "/js/clients/payments/stripe-ach.js": "/js/clients/payments/stripe-ach.js?id=5e74bc0d346beeb57ee9", "/js/clients/invoices/action-selectors.js": "/js/clients/invoices/action-selectors.js?id=6b79265cbb8c963eef19", "/js/clients/invoices/payment.js": "/js/clients/invoices/payment.js?id=2cccf9e51b60a0ab17b8", - "/js/clients/payments/stripe-sofort.js": "/js/clients/payments/stripe-sofort.js?id=926c7b9d1ee48bbf786b", + "/js/clients/payments/stripe-sofort.js": "/js/clients/payments/stripe-sofort.js?id=22fc06e698dea2c3bdf3", "/js/clients/payments/stripe-alipay.js": "/js/clients/payments/stripe-alipay.js?id=1e159400d6a5ca4662c1", "/js/clients/payments/checkout-credit-card.js": "/js/clients/payments/checkout-credit-card.js?id=0b47ce36fe20191adb33", "/js/clients/quotes/action-selectors.js": "/js/clients/quotes/action-selectors.js?id=63f0688329be80ee8693", diff --git a/resources/js/clients/payments/stripe-sofort.js b/resources/js/clients/payments/stripe-sofort.js index e41398cd6a29..8fb9c2883e56 100644 --- a/resources/js/clients/payments/stripe-sofort.js +++ b/resources/js/clients/payments/stripe-sofort.js @@ -16,10 +16,19 @@ class ProcessSOFORT { } setupStripe = () => { - this.stripe = Stripe(this.key); - if(this.stripeConnect) - this.stripe.stripeAccount = stripeConnect; + + if (this.stripeConnect){ + // this.stripe.stripeAccount = this.stripeConnect; + + this.stripe = Stripe(this.key, { + stripeAccount: this.stripeConnect, + }); + + } + else { + this.stripe = Stripe(this.key); + } return this; }; diff --git a/resources/views/portal/ninja2020/gateways/stripe/sofort/pay.blade.php b/resources/views/portal/ninja2020/gateways/stripe/sofort/pay.blade.php index 85c223516e75..104bbfc3477c 100644 --- a/resources/views/portal/ninja2020/gateways/stripe/sofort/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/stripe/sofort/pay.blade.php @@ -1,7 +1,14 @@ @extends('portal.ninja2020.layout.payments', ['gateway_title' => 'SOFORT', 'card_title' => 'SOFORT']) @section('gateway_head') - + + @if($gateway->company_gateway->getConfigField('account_id')) + + + @else + + @endif + From 370d932eb1bdb5a03499d1ce1cdc5f3fcfe65cd6 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 22 Jan 2022 15:22:59 +1100 Subject: [PATCH 10/11] Fixes for stripe gateways in hosted --- app/Models/Account.php | 1 + app/PaymentDrivers/Stripe/ACSS.php | 4 ++- app/PaymentDrivers/Stripe/BECS.php | 4 ++- app/PaymentDrivers/Stripe/Bancontact.php | 4 ++- app/PaymentDrivers/Stripe/EPS.php | 4 ++- app/PaymentDrivers/Stripe/FPX.php | 4 ++- app/PaymentDrivers/Stripe/GIROPAY.php | 4 ++- app/PaymentDrivers/Stripe/PRZELEWY24.php | 4 ++- app/PaymentDrivers/Stripe/SEPA.php | 2 +- app/PaymentDrivers/Stripe/SOFORT.php | 2 +- app/PaymentDrivers/Stripe/iDeal.php | 4 ++- ..._add_platform_column_to_accounts_table.php | 29 +++++++++++++++++++ public/js/clients/payments/stripe-ach.js | 2 +- public/js/clients/payments/stripe-acss.js | 2 +- public/js/clients/payments/stripe-alipay.js | 2 +- .../js/clients/payments/stripe-bancontact.js | 2 +- public/js/clients/payments/stripe-becs.js | 2 +- public/js/clients/payments/stripe-eps.js | 2 +- public/js/clients/payments/stripe-fpx.js | 2 +- public/js/clients/payments/stripe-giropay.js | 2 +- public/js/clients/payments/stripe-ideal.js | 2 +- .../js/clients/payments/stripe-przelewy24.js | 2 +- public/js/clients/payments/stripe-sepa.js | 2 +- public/mix-manifest.json | 22 +++++++------- resources/js/clients/payments/stripe-ach.js | 15 ++++++++-- resources/js/clients/payments/stripe-acss.js | 15 ++++++++-- .../js/clients/payments/stripe-alipay.js | 15 ++++++++-- .../js/clients/payments/stripe-bancontact.js | 15 ++++++++-- resources/js/clients/payments/stripe-becs.js | 15 ++++++++-- resources/js/clients/payments/stripe-eps.js | 17 +++++++++-- resources/js/clients/payments/stripe-fpx.js | 16 ++++++++-- .../js/clients/payments/stripe-giropay.js | 15 ++++++++-- resources/js/clients/payments/stripe-ideal.js | 17 +++++++++-- .../js/clients/payments/stripe-przelewy24.js | 16 ++++++++-- resources/js/clients/payments/stripe-sepa.js | 16 ++++++++-- 35 files changed, 218 insertions(+), 64 deletions(-) create mode 100644 database/migrations/2022_01_19_085907_add_platform_column_to_accounts_table.php diff --git a/app/Models/Account.php b/app/Models/Account.php index 6dc153266f55..222e49aa49aa 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -54,6 +54,7 @@ class Account extends BaseModel 'utm_term', 'utm_content', 'user_agent', + 'platform', ]; /** diff --git a/app/PaymentDrivers/Stripe/ACSS.php b/app/PaymentDrivers/Stripe/ACSS.php index 6d5276e7e1fe..f82b4782de1f 100644 --- a/app/PaymentDrivers/Stripe/ACSS.php +++ b/app/PaymentDrivers/Stripe/ACSS.php @@ -127,6 +127,8 @@ class ACSS public function paymentView(array $data) { + $this->stripe->init(); + $data['gateway'] = $this->stripe; $data['return_url'] = $this->buildReturnUrl(); $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); @@ -151,7 +153,7 @@ class ACSS 'currency' => $this->stripe->client->currency()->code, ] ] - ]); + ], $this->stripe->stripe_connect_auth); $data['pi_client_secret'] = $intent->client_secret; diff --git a/app/PaymentDrivers/Stripe/BECS.php b/app/PaymentDrivers/Stripe/BECS.php index a0942c997202..a225dc3f214d 100644 --- a/app/PaymentDrivers/Stripe/BECS.php +++ b/app/PaymentDrivers/Stripe/BECS.php @@ -39,6 +39,8 @@ class BECS public function paymentView(array $data) { + $this->stripe->init(); + $data['gateway'] = $this->stripe; $data['payment_method_id'] = GatewayType::BECS; $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); @@ -55,7 +57,7 @@ class BECS 'customer' => $this->stripe->findOrCreateCustomer(), 'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')), - ]); + ], $this->stripe->stripe_connect_auth); $data['pi_client_secret'] = $intent->client_secret; diff --git a/app/PaymentDrivers/Stripe/Bancontact.php b/app/PaymentDrivers/Stripe/Bancontact.php index 608783de77c6..303dfa41d2e5 100644 --- a/app/PaymentDrivers/Stripe/Bancontact.php +++ b/app/PaymentDrivers/Stripe/Bancontact.php @@ -37,6 +37,8 @@ class Bancontact public function paymentView(array $data) { + $this->stripe->init(); + $data['gateway'] = $this->stripe; $data['return_url'] = $this->buildReturnUrl(); $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); @@ -51,7 +53,7 @@ class Bancontact 'customer' => $this->stripe->findOrCreateCustomer(), 'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')), - ]); + ], $this->stripe->stripe_connect_auth); $data['pi_client_secret'] = $intent->client_secret; diff --git a/app/PaymentDrivers/Stripe/EPS.php b/app/PaymentDrivers/Stripe/EPS.php index 5bd92956dca8..35abb4c69a5c 100644 --- a/app/PaymentDrivers/Stripe/EPS.php +++ b/app/PaymentDrivers/Stripe/EPS.php @@ -37,6 +37,8 @@ class EPS public function paymentView(array $data) { + $this->stripe->init(); + $data['gateway'] = $this->stripe; $data['return_url'] = $this->buildReturnUrl(); $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); @@ -51,7 +53,7 @@ class EPS 'customer' => $this->stripe->findOrCreateCustomer(), 'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')), - ]); + ], $this->stripe->stripe_connect_auth); $data['pi_client_secret'] = $intent->client_secret; diff --git a/app/PaymentDrivers/Stripe/FPX.php b/app/PaymentDrivers/Stripe/FPX.php index c06c6ca58ea3..0bf85e48512e 100644 --- a/app/PaymentDrivers/Stripe/FPX.php +++ b/app/PaymentDrivers/Stripe/FPX.php @@ -38,6 +38,8 @@ class FPX public function paymentView(array $data) { + $this->stripe->init(); + $data['gateway'] = $this->stripe; $data['return_url'] = $this->buildReturnUrl(); $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); @@ -52,7 +54,7 @@ class FPX 'customer' => $this->stripe->findOrCreateCustomer(), 'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')), - ]); + ], $this->stripe->stripe_connect_auth); $data['pi_client_secret'] = $intent->client_secret; diff --git a/app/PaymentDrivers/Stripe/GIROPAY.php b/app/PaymentDrivers/Stripe/GIROPAY.php index 102cf371cfe8..dbbdc5f79962 100644 --- a/app/PaymentDrivers/Stripe/GIROPAY.php +++ b/app/PaymentDrivers/Stripe/GIROPAY.php @@ -37,6 +37,8 @@ class GIROPAY public function paymentView(array $data) { + $this->stripe->init(); + $data['gateway'] = $this->stripe; $data['return_url'] = $this->buildReturnUrl(); $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); @@ -51,7 +53,7 @@ class GIROPAY 'customer' => $this->stripe->findOrCreateCustomer(), 'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')), - ]); + ], $this->stripe->stripe_connect_auth); $data['pi_client_secret'] = $intent->client_secret; diff --git a/app/PaymentDrivers/Stripe/PRZELEWY24.php b/app/PaymentDrivers/Stripe/PRZELEWY24.php index 5438649912e1..64988894fc84 100644 --- a/app/PaymentDrivers/Stripe/PRZELEWY24.php +++ b/app/PaymentDrivers/Stripe/PRZELEWY24.php @@ -37,6 +37,8 @@ class PRZELEWY24 public function paymentView(array $data) { + $this->stripe->init(); + $data['gateway'] = $this->stripe; $data['return_url'] = $this->buildReturnUrl(); $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); @@ -51,7 +53,7 @@ class PRZELEWY24 'customer' => $this->stripe->findOrCreateCustomer(), 'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')), - ]); + ], $this->stripe->stripe_connect_auth); $data['pi_client_secret'] = $intent->client_secret; diff --git a/app/PaymentDrivers/Stripe/SEPA.php b/app/PaymentDrivers/Stripe/SEPA.php index 251dbbb00bfa..cc4129d6a920 100644 --- a/app/PaymentDrivers/Stripe/SEPA.php +++ b/app/PaymentDrivers/Stripe/SEPA.php @@ -54,7 +54,7 @@ class SEPA 'setup_future_usage' => 'off_session', 'customer' => $this->stripe->findOrCreateCustomer(), 'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')), - ]); + ], $this->stripe->stripe_connect_auth); $data['pi_client_secret'] = $intent->client_secret; diff --git a/app/PaymentDrivers/Stripe/SOFORT.php b/app/PaymentDrivers/Stripe/SOFORT.php index d76b9ed43e98..383061ceabce 100644 --- a/app/PaymentDrivers/Stripe/SOFORT.php +++ b/app/PaymentDrivers/Stripe/SOFORT.php @@ -53,7 +53,7 @@ class SOFORT 'customer' => $this->stripe->findOrCreateCustomer(), 'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')), - ]); + ], $this->stripe->stripe_connect_auth); $data['pi_client_secret'] = $intent->client_secret; diff --git a/app/PaymentDrivers/Stripe/iDeal.php b/app/PaymentDrivers/Stripe/iDeal.php index c9a43a8e1793..1f16122ae1b8 100644 --- a/app/PaymentDrivers/Stripe/iDeal.php +++ b/app/PaymentDrivers/Stripe/iDeal.php @@ -37,6 +37,8 @@ class iDeal public function paymentView(array $data) { + $this->stripe->init(); + $data['gateway'] = $this->stripe; $data['return_url'] = $this->buildReturnUrl(); $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); @@ -51,7 +53,7 @@ class iDeal 'customer' => $this->stripe->findOrCreateCustomer(), 'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')), - ]); + ], $this->stripe->stripe_connect_auth); $data['pi_client_secret'] = $intent->client_secret; diff --git a/database/migrations/2022_01_19_085907_add_platform_column_to_accounts_table.php b/database/migrations/2022_01_19_085907_add_platform_column_to_accounts_table.php new file mode 100644 index 000000000000..77d3fe6803fe --- /dev/null +++ b/database/migrations/2022_01_19_085907_add_platform_column_to_accounts_table.php @@ -0,0 +1,29 @@ +string('platform', 128)->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + } +} diff --git a/public/js/clients/payments/stripe-ach.js b/public/js/clients/payments/stripe-ach.js index 983ff209fa7c..a0cd224a2119 100755 --- a/public/js/clients/payments/stripe-ach.js +++ b/public/js/clients/payments/stripe-ach.js @@ -1,2 +1,2 @@ /*! For license information please see stripe-ach.js.LICENSE.txt */ -(()=>{function e(e,t){for(var n=0;n svg").classList.add("hidden"),document.querySelector("#save-button > span").classList.remove("hidden"),r.errors.textContent="",r.errors.textContent=e,r.errors.hidden=!1})),t(this,"handleSuccess",(function(e){document.getElementById("gateway_response").value=JSON.stringify(e),document.getElementById("server_response").submit()})),t(this,"handleSubmit",(function(e){document.getElementById("save-button").disabled=!0,document.querySelector("#save-button > svg").classList.remove("hidden"),document.querySelector("#save-button > span").classList.add("hidden"),e.preventDefault(),r.errors.textContent="",r.errors.hidden=!0,r.stripe.createToken("bank_account",r.getFormData()).then((function(e){return e.hasOwnProperty("error")?r.handleError(e.error.message):r.handleSuccess(e)}))})),this.errors=document.getElementById("errors"),this.key=document.querySelector('meta[name="stripe-publishable-key"]').content,this.stripe_connect=null===(e=document.querySelector('meta[name="stripe-account-id"]'))||void 0===e?void 0:e.content}var r,o,u;return r=n,(o=[{key:"handle",value:function(){var e=this;document.getElementById("save-button").addEventListener("click",(function(t){return e.handleSubmit(t)}))}}])&&e(r.prototype,o),u&&e(r,u),n}())).setupStripe().handle()})(); \ No newline at end of file +(()=>{function e(e,t){for(var n=0;n svg").classList.add("hidden"),document.querySelector("#save-button > span").classList.remove("hidden"),r.errors.textContent="",r.errors.textContent=e,r.errors.hidden=!1})),t(this,"handleSuccess",(function(e){document.getElementById("gateway_response").value=JSON.stringify(e),document.getElementById("server_response").submit()})),t(this,"handleSubmit",(function(e){document.getElementById("save-button").disabled=!0,document.querySelector("#save-button > svg").classList.remove("hidden"),document.querySelector("#save-button > span").classList.add("hidden"),e.preventDefault(),r.errors.textContent="",r.errors.hidden=!0,r.stripe.createToken("bank_account",r.getFormData()).then((function(e){return e.hasOwnProperty("error")?r.handleError(e.error.message):r.handleSuccess(e)}))})),this.errors=document.getElementById("errors"),this.key=document.querySelector('meta[name="stripe-publishable-key"]').content,this.stripe_connect=null===(e=document.querySelector('meta[name="stripe-account-id"]'))||void 0===e?void 0:e.content}var r,o,u;return r=n,(o=[{key:"handle",value:function(){var e=this;document.getElementById("save-button").addEventListener("click",(function(t){return e.handleSubmit(t)}))}}])&&e(r.prototype,o),u&&e(r,u),n}())).setupStripe().handle()})(); \ No newline at end of file diff --git a/public/js/clients/payments/stripe-acss.js b/public/js/clients/payments/stripe-acss.js index 689f8d73cab1..7e367543203f 100644 --- a/public/js/clients/payments/stripe-acss.js +++ b/public/js/clients/payments/stripe-acss.js @@ -1,2 +1,2 @@ /*! For license information please see stripe-acss.js.LICENSE.txt */ -(()=>{var e,t,n,r;function o(e,t){for(var n=0;n svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),void r.stripe.confirmAcssDebitPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{billing_details:{name:document.getElementById("acss-name").value,email:document.getElementById("acss-email-address").value}}}).then((function(e){return e.error?r.handleFailure(e.error.message):r.handleSuccess(e)})))}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}var t,n,r;return t=e,(n=[{key:"handleSuccess",value:function(e){document.querySelector('input[name="gateway_response"]').value=JSON.stringify(e.paymentIntent),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),r&&o(t,r),e}(),i=null!==(e=null===(t=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===t?void 0:t.content)&&void 0!==e?e:"",c=null!==(n=null===(r=document.querySelector('meta[name="stripe-account-id"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"";new d(i,c).setupStripe().handle()})(); \ No newline at end of file +(()=>{var e,t,n,r;function o(e,t){for(var n=0;n svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),void r.stripe.confirmAcssDebitPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{billing_details:{name:document.getElementById("acss-name").value,email:document.getElementById("acss-email-address").value}}}).then((function(e){return e.error?r.handleFailure(e.error.message):r.handleSuccess(e)})))}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}var t,n,r;return t=e,(n=[{key:"handleSuccess",value:function(e){document.querySelector('input[name="gateway_response"]').value=JSON.stringify(e.paymentIntent),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),r&&o(t,r),e}();new i(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===(r=document.querySelector('meta[name="stripe-account-id"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"").setupStripe().handle()})(); \ No newline at end of file diff --git a/public/js/clients/payments/stripe-alipay.js b/public/js/clients/payments/stripe-alipay.js index c022f81c4456..6130b689fe00 100755 --- a/public/js/clients/payments/stripe-alipay.js +++ b/public/js/clients/payments/stripe-alipay.js @@ -1,2 +1,2 @@ /*! For license information please see stripe-alipay.js.LICENSE.txt */ -(()=>{var e,t,n,r;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}new function e(t,n){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o(this,"setupStripe",(function(){return r.stripe=Stripe(r.key),r.stripeConnect&&(r.stripe.stripeAccount=r.stripeConnect),r})),o(this,"handle",(function(){var e={type:"alipay",amount:document.querySelector('meta[name="amount"]').content,currency:document.querySelector('meta[name="currency"]').content,redirect:{return_url:document.querySelector('meta[name="return-url"]').content}};document.getElementById("pay-now").addEventListener("click",(function(t){document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden"),r.stripe.createSource(e).then((function(e){if(e.hasOwnProperty("source"))return window.location=e.source.redirect.url;document.getElementById("pay-now").disabled=!1,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.errors.textContent="",this.errors.textContent=e.error.message,this.errors.hidden=!1}))}))})),this.key=t,this.stripeConnect=n,this.errors=document.getElementById("errors")}(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===(r=document.querySelector('meta[name="stripe-account-id"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"").setupStripe().handle()})(); \ No newline at end of file +(()=>{var e,t,n,r;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}new function e(t,n){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o(this,"setupStripe",(function(){return r.stripeConnect?r.stripe=Stripe(r.key,{stripeAccount:r.stripeConnect}):r.stripe=Stripe(r.key),r})),o(this,"handle",(function(){var e={type:"alipay",amount:document.querySelector('meta[name="amount"]').content,currency:document.querySelector('meta[name="currency"]').content,redirect:{return_url:document.querySelector('meta[name="return-url"]').content}};document.getElementById("pay-now").addEventListener("click",(function(t){document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden"),r.stripe.createSource(e).then((function(e){if(e.hasOwnProperty("source"))return window.location=e.source.redirect.url;document.getElementById("pay-now").disabled=!1,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.errors.textContent="",this.errors.textContent=e.error.message,this.errors.hidden=!1}))}))})),this.key=t,this.stripeConnect=n,this.errors=document.getElementById("errors")}(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===(r=document.querySelector('meta[name="stripe-account-id"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"").setupStripe().handle()})(); \ No newline at end of file diff --git a/public/js/clients/payments/stripe-bancontact.js b/public/js/clients/payments/stripe-bancontact.js index a0e7f1380db5..6e9fcfdb80dd 100644 --- a/public/js/clients/payments/stripe-bancontact.js +++ b/public/js/clients/payments/stripe-bancontact.js @@ -1,2 +1,2 @@ /*! For license information please see stripe-bancontact.js.LICENSE.txt */ -(()=>{var e,t,n,o;function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=null!==(e=null===(t=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===t?void 0:t.content)&&void 0!==e?e:"",c=null!==(n=null===(o=document.querySelector('meta[name="stripe-account-id"]'))||void 0===o?void 0:o.content)&&void 0!==n?n:"";new function e(t,n){var o=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),r(this,"setupStripe",(function(){return o.stripe=Stripe(o.key),o.stripeConnect&&(o.stripe.stripeAccount=c),o})),r(this,"handle",(function(){document.getElementById("pay-now").addEventListener("click",(function(e){var t=document.getElementById("errors");if(!document.getElementById("bancontact-name").value)return t.textContent=document.querySelector("meta[name=translation-name-required]").content,t.hidden=!1,void console.log("name");document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),o.stripe.confirmBancontactPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{billing_details:{name:document.getElementById("bancontact-name").value}},return_url:document.querySelector('meta[name="return-url"]').content})}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}(a,c).setupStripe().handle()})(); \ No newline at end of file +(()=>{var e,t,n,o;function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}new function e(t,n){var o=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),r(this,"setupStripe",(function(){return o.stripeConnect?o.stripe=Stripe(o.key,{stripeAccount:o.stripeConnect}):o.stripe=Stripe(o.key),o})),r(this,"handle",(function(){document.getElementById("pay-now").addEventListener("click",(function(e){var t=document.getElementById("errors");if(!document.getElementById("bancontact-name").value)return t.textContent=document.querySelector("meta[name=translation-name-required]").content,t.hidden=!1,void console.log("name");document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),o.stripe.confirmBancontactPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{billing_details:{name:document.getElementById("bancontact-name").value}},return_url:document.querySelector('meta[name="return-url"]').content})}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}(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===(o=document.querySelector('meta[name="stripe-account-id"]'))||void 0===o?void 0:o.content)&&void 0!==n?n:"").setupStripe().handle()})(); \ No newline at end of file diff --git a/public/js/clients/payments/stripe-becs.js b/public/js/clients/payments/stripe-becs.js index b986a3ad3444..a42e1e735c6c 100644 --- a/public/js/clients/payments/stripe-becs.js +++ b/public/js/clients/payments/stripe-becs.js @@ -1,2 +1,2 @@ /*! For license information please see stripe-becs.js.LICENSE.txt */ -(()=>{var e,t,n,o;function a(e,t){for(var n=0;n svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),void o.stripe.confirmAuBecsDebitPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{au_becs_debit:o.auBankAccount,billing_details:{name:document.getElementById("becs-name").value,email:document.getElementById("becs-email-address").value}}}).then((function(e){return e.error?o.handleFailure(e.error.message):o.handleSuccess(e)}))):(document.getElementById("becs-mandate-acceptance").focus(),t.textContent=document.querySelector("meta[name=translation-terms-required]").content,t.hidden=!1,void console.log("Terms"))}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}var t,n,o;return t=e,(n=[{key:"handleSuccess",value:function(e){document.querySelector('input[name="gateway_response"]').value=JSON.stringify(e.paymentIntent),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")}}])&&a(t.prototype,n),o&&a(t,o),e}(),d=null!==(e=null===(t=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===t?void 0:t.content)&&void 0!==e?e:"",i=null!==(n=null===(o=document.querySelector('meta[name="stripe-account-id"]'))||void 0===o?void 0:o.content)&&void 0!==n?n:"";new r(d,i).setupStripe().handle()})(); \ No newline at end of file +(()=>{var e,t,n,o;function a(e,t){for(var n=0;n svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),void o.stripe.confirmAuBecsDebitPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{au_becs_debit:o.auBankAccount,billing_details:{name:document.getElementById("becs-name").value,email:document.getElementById("becs-email-address").value}}}).then((function(e){return e.error?o.handleFailure(e.error.message):o.handleSuccess(e)}))):(document.getElementById("becs-mandate-acceptance").focus(),t.textContent=document.querySelector("meta[name=translation-terms-required]").content,t.hidden=!1,void console.log("Terms"))}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}var t,n,o;return t=e,(n=[{key:"handleSuccess",value:function(e){document.querySelector('input[name="gateway_response"]').value=JSON.stringify(e.paymentIntent),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")}}])&&a(t.prototype,n),o&&a(t,o),e}();new r(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===(o=document.querySelector('meta[name="stripe-account-id"]'))||void 0===o?void 0:o.content)&&void 0!==n?n:"").setupStripe().handle()})(); \ No newline at end of file diff --git a/public/js/clients/payments/stripe-eps.js b/public/js/clients/payments/stripe-eps.js index 145a17963aa2..005914c92576 100644 --- a/public/js/clients/payments/stripe-eps.js +++ b/public/js/clients/payments/stripe-eps.js @@ -1,2 +1,2 @@ /*! For license information please see stripe-eps.js.LICENSE.txt */ -(()=>{var e,t,n,r;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=null!==(e=null===(t=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===t?void 0:t.content)&&void 0!==e?e:"",i=null!==(n=null===(r=document.querySelector('meta[name="stripe-account-id"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"";new function e(t,n){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o(this,"setupStripe",(function(){r.stripe=Stripe(r.key),r.stripeConnect&&(r.stripe.stripeAccount=i);var e=r.stripe.elements();return r.eps=e.create("epsBank",{style:{base:{padding:"10px 12px",color:"#32325d",fontSize:"16px","::placeholder":{color:"#aab7c4"}}}}),r.eps.mount("#eps-bank-element"),r})),o(this,"handle",(function(){document.getElementById("pay-now").addEventListener("click",(function(e){var t=document.getElementById("errors");if(!document.getElementById("eps-name").value)return t.textContent=document.querySelector("meta[name=translation-name-required]").content,t.hidden=!1,void console.log("name");document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),r.stripe.confirmEpsPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{eps:r.eps,billing_details:{name:document.getElementById("ideal-name").value}},return_url:document.querySelector('meta[name="return-url"]').content})}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}(a,i).setupStripe().handle()})(); \ No newline at end of file +(()=>{var e,t,n,r;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}new function e(t,n){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o(this,"setupStripe",(function(){r.stripeConnect?r.stripe=Stripe(r.key,{stripeAccount:r.stripeConnect}):r.stripe=Stripe(r.key);var e=r.stripe.elements();return r.eps=e.create("epsBank",{style:{base:{padding:"10px 12px",color:"#32325d",fontSize:"16px","::placeholder":{color:"#aab7c4"}}}}),r.eps.mount("#eps-bank-element"),r})),o(this,"handle",(function(){document.getElementById("pay-now").addEventListener("click",(function(e){var t=document.getElementById("errors");if(!document.getElementById("eps-name").value)return t.textContent=document.querySelector("meta[name=translation-name-required]").content,t.hidden=!1,void console.log("name");document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),r.stripe.confirmEpsPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{eps:r.eps,billing_details:{name:document.getElementById("ideal-name").value}},return_url:document.querySelector('meta[name="return-url"]').content})}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}(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===(r=document.querySelector('meta[name="stripe-account-id"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"").setupStripe().handle()})(); \ No newline at end of file diff --git a/public/js/clients/payments/stripe-fpx.js b/public/js/clients/payments/stripe-fpx.js index 5c14c98ed666..8ac764bf72be 100644 --- a/public/js/clients/payments/stripe-fpx.js +++ b/public/js/clients/payments/stripe-fpx.js @@ -1,2 +1,2 @@ /*! For license information please see stripe-fpx.js.LICENSE.txt */ -(()=>{var e,t,n,r;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var i=null!==(e=null===(t=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===t?void 0:t.content)&&void 0!==e?e:"",c=null!==(n=null===(r=document.querySelector('meta[name="stripe-account-id"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"";new function e(t,n){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o(this,"setupStripe",(function(){r.stripe=Stripe(r.key),r.stripeConnect&&(r.stripe.stripeAccount=c);var e=r.stripe.elements();return r.fpx=e.create("fpxBank",{style:{base:{padding:"10px 12px",color:"#32325d",fontSize:"16px"}},accountHolderType:"individual"}),r.fpx.mount("#fpx-bank-element"),r})),o(this,"handle",(function(){document.getElementById("pay-now").addEventListener("click",(function(e){document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),r.stripe.confirmFpxPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{fpx:r.fpx},return_url:document.querySelector('meta[name="return-url"]').content})}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}(i,c).setupStripe().handle()})(); \ No newline at end of file +(()=>{var e,t,n,r;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}new function e(t,n){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o(this,"setupStripe",(function(){r.stripeConnect?r.stripe=Stripe(r.key,{stripeAccount:r.stripeConnect}):r.stripe=Stripe(r.key);var e=r.stripe.elements();return r.fpx=e.create("fpxBank",{style:{base:{padding:"10px 12px",color:"#32325d",fontSize:"16px"}},accountHolderType:"individual"}),r.fpx.mount("#fpx-bank-element"),r})),o(this,"handle",(function(){document.getElementById("pay-now").addEventListener("click",(function(e){document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),r.stripe.confirmFpxPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{fpx:r.fpx},return_url:document.querySelector('meta[name="return-url"]').content})}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}(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===(r=document.querySelector('meta[name="stripe-account-id"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"").setupStripe().handle()})(); \ No newline at end of file diff --git a/public/js/clients/payments/stripe-giropay.js b/public/js/clients/payments/stripe-giropay.js index 01b653d83313..fcca6ff42593 100644 --- a/public/js/clients/payments/stripe-giropay.js +++ b/public/js/clients/payments/stripe-giropay.js @@ -1,2 +1,2 @@ /*! For license information please see stripe-giropay.js.LICENSE.txt */ -(()=>{var e,t,n,r;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var i=null!==(e=null===(t=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===t?void 0:t.content)&&void 0!==e?e:"",c=null!==(n=null===(r=document.querySelector('meta[name="stripe-account-id"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"";new function e(t,n){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o(this,"setupStripe",(function(){return r.stripe=Stripe(r.key),r.stripeConnect&&(r.stripe.stripeAccount=c),r})),o(this,"handle",(function(){document.getElementById("pay-now").addEventListener("click",(function(e){var t=document.getElementById("errors");if(!document.getElementById("giropay-mandate-acceptance").checked)return t.textContent=document.querySelector("meta[name=translation-terms-required]").content,t.hidden=!1,void console.log("Terms");document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),r.stripe.confirmGiropayPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{billing_details:{name:document.getElementById("giropay-name").value}},return_url:document.querySelector('meta[name="return-url"]').content})}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}(i,c).setupStripe().handle()})(); \ No newline at end of file +(()=>{var e,t,n,r;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}new function e(t,n){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o(this,"setupStripe",(function(){return r.stripeConnect?r.stripe=Stripe(r.key,{stripeAccount:r.stripeConnect}):r.stripe=Stripe(r.key),r})),o(this,"handle",(function(){document.getElementById("pay-now").addEventListener("click",(function(e){var t=document.getElementById("errors");if(!document.getElementById("giropay-mandate-acceptance").checked)return t.textContent=document.querySelector("meta[name=translation-terms-required]").content,t.hidden=!1,void console.log("Terms");document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),r.stripe.confirmGiropayPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{billing_details:{name:document.getElementById("giropay-name").value}},return_url:document.querySelector('meta[name="return-url"]').content})}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}(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===(r=document.querySelector('meta[name="stripe-account-id"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"").setupStripe().handle()})(); \ No newline at end of file diff --git a/public/js/clients/payments/stripe-ideal.js b/public/js/clients/payments/stripe-ideal.js index 32901bd060c0..c2073da4cf62 100644 --- a/public/js/clients/payments/stripe-ideal.js +++ b/public/js/clients/payments/stripe-ideal.js @@ -1,2 +1,2 @@ /*! For license information please see stripe-ideal.js.LICENSE.txt */ -(()=>{var e,t,n,r;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=null!==(e=null===(t=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===t?void 0:t.content)&&void 0!==e?e:"",i=null!==(n=null===(r=document.querySelector('meta[name="stripe-account-id"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"";new function e(t,n){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o(this,"setupStripe",(function(){r.stripe=Stripe(r.key),r.stripeConnect&&(r.stripe.stripeAccount=i);var e=r.stripe.elements();return r.ideal=e.create("idealBank",{style:{base:{padding:"10px 12px",color:"#32325d",fontSize:"16px","::placeholder":{color:"#aab7c4"}}}}),r.ideal.mount("#ideal-bank-element"),r})),o(this,"handle",(function(){document.getElementById("pay-now").addEventListener("click",(function(e){var t=document.getElementById("errors");if(!document.getElementById("ideal-name").value)return t.textContent=document.querySelector("meta[name=translation-name-required]").content,t.hidden=!1,void console.log("name");document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),r.stripe.confirmIdealPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{ideal:r.ideal,billing_details:{name:document.getElementById("ideal-name").value}},return_url:document.querySelector('meta[name="return-url"]').content})}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}(a,i).setupStripe().handle()})(); \ No newline at end of file +(()=>{var e,t,n,r;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}new function e(t,n){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o(this,"setupStripe",(function(){r.stripeConnect?r.stripe=Stripe(r.key,{stripeAccount:r.stripeConnect}):r.stripe=Stripe(r.key);var e=r.stripe.elements();return r.ideal=e.create("idealBank",{style:{base:{padding:"10px 12px",color:"#32325d",fontSize:"16px","::placeholder":{color:"#aab7c4"}}}}),r.ideal.mount("#ideal-bank-element"),r})),o(this,"handle",(function(){document.getElementById("pay-now").addEventListener("click",(function(e){var t=document.getElementById("errors");if(!document.getElementById("ideal-name").value)return t.textContent=document.querySelector("meta[name=translation-name-required]").content,t.hidden=!1,void console.log("name");document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),r.stripe.confirmIdealPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{ideal:r.ideal,billing_details:{name:document.getElementById("ideal-name").value}},return_url:document.querySelector('meta[name="return-url"]').content})}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}(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===(r=document.querySelector('meta[name="stripe-account-id"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"").setupStripe().handle()})(); \ No newline at end of file diff --git a/public/js/clients/payments/stripe-przelewy24.js b/public/js/clients/payments/stripe-przelewy24.js index 78fa414d5a45..9d0aeb0dae6f 100644 --- a/public/js/clients/payments/stripe-przelewy24.js +++ b/public/js/clients/payments/stripe-przelewy24.js @@ -1,2 +1,2 @@ /*! For license information please see stripe-przelewy24.js.LICENSE.txt */ -(()=>{var e,t,n,a;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var d=null!==(e=null===(t=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===t?void 0:t.content)&&void 0!==e?e:"",c=null!==(n=null===(a=document.querySelector('meta[name="stripe-account-id"]'))||void 0===a?void 0:a.content)&&void 0!==n?n:"";new function e(t,n){var a=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o(this,"setupStripe",(function(){a.stripe=Stripe(a.key),a.stripeConnect&&(a.stripe.stripeAccount=c);var e=a.stripe.elements();return a.p24bank=e.create("p24Bank",{style:{base:{padding:"10px 12px",color:"#32325d",fontSize:"16px","::placeholder":{color:"#aab7c4"}}}}),a.p24bank.mount("#p24-bank-element"),a})),o(this,"handle",(function(){document.getElementById("pay-now").addEventListener("click",(function(e){var t=document.getElementById("errors");return""===document.getElementById("p24-name").value?(document.getElementById("p24-name").focus(),t.textContent=document.querySelector("meta[name=translation-name-required]").content,void(t.hidden=!1)):""===document.getElementById("p24-email-address").value?(document.getElementById("p24-email-address").focus(),t.textContent=document.querySelector("meta[name=translation-email-required]").content,void(t.hidden=!1)):document.getElementById("p24-mandate-acceptance").checked?(document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),void a.stripe.confirmP24Payment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{p24:a.p24bank,billing_details:{name:document.getElementById("p24-name").value,email:document.getElementById("p24-email-address").value}},payment_method_options:{p24:{tos_shown_and_accepted:document.getElementById("p24-mandate-acceptance").checked}},return_url:document.querySelector('meta[name="return-url"]').content})):(document.getElementById("p24-mandate-acceptance").focus(),t.textContent=document.querySelector("meta[name=translation-terms-required]").content,void(t.hidden=!1))}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}(d,c).setupStripe().handle()})(); \ No newline at end of file +(()=>{var e,t,n,o;function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}new function e(t,n){var o=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),a(this,"setupStripe",(function(){o.stripeConnect?o.stripe=Stripe(o.key,{stripeAccount:o.stripeConnect}):o.stripe=Stripe(o.key);var e=o.stripe.elements();return o.p24bank=e.create("p24Bank",{style:{base:{padding:"10px 12px",color:"#32325d",fontSize:"16px","::placeholder":{color:"#aab7c4"}}}}),o.p24bank.mount("#p24-bank-element"),o})),a(this,"handle",(function(){document.getElementById("pay-now").addEventListener("click",(function(e){var t=document.getElementById("errors");return""===document.getElementById("p24-name").value?(document.getElementById("p24-name").focus(),t.textContent=document.querySelector("meta[name=translation-name-required]").content,void(t.hidden=!1)):""===document.getElementById("p24-email-address").value?(document.getElementById("p24-email-address").focus(),t.textContent=document.querySelector("meta[name=translation-email-required]").content,void(t.hidden=!1)):document.getElementById("p24-mandate-acceptance").checked?(document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),void o.stripe.confirmP24Payment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{p24:o.p24bank,billing_details:{name:document.getElementById("p24-name").value,email:document.getElementById("p24-email-address").value}},payment_method_options:{p24:{tos_shown_and_accepted:document.getElementById("p24-mandate-acceptance").checked}},return_url:document.querySelector('meta[name="return-url"]').content})):(document.getElementById("p24-mandate-acceptance").focus(),t.textContent=document.querySelector("meta[name=translation-terms-required]").content,void(t.hidden=!1))}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}(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===(o=document.querySelector('meta[name="stripe-account-id"]'))||void 0===o?void 0:o.content)&&void 0!==n?n:"").setupStripe().handle()})(); \ No newline at end of file diff --git a/public/js/clients/payments/stripe-sepa.js b/public/js/clients/payments/stripe-sepa.js index 3c14f5c21e28..5769f96f3c3b 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,o;function a(e,t){for(var n=0;n svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),void o.stripe.confirmSepaDebitSetup(document.querySelector("meta[name=si-client-secret").content,{payment_method:document.querySelector("input[name=token]").value}).then((function(e){if(!e.error)return document.querySelector('input[name="gateway_response"]').value=JSON.stringify(e.setupIntent),document.querySelector("#server-response").submit();console.error(error)})).catch((function(t){e.textContent=t,e.hidden=!1}))):""===document.getElementById("sepa-name").value?(document.getElementById("sepa-name").focus(),e.textContent=document.querySelector("meta[name=translation-name-required]").content,void(e.hidden=!1)):""===document.getElementById("sepa-email-address").value?(document.getElementById("sepa-email-address").focus(),e.textContent=document.querySelector("meta[name=translation-email-required]").content,void(e.hidden=!1)):document.getElementById("sepa-mandate-acceptance").checked?(document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),void o.stripe.confirmSepaDebitPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{sepa_debit:o.iban,billing_details:{name:document.getElementById("sepa-name").value,email:document.getElementById("sepa-email-address").value}}}).then((function(e){return e.error?o.handleFailure(e.error.message):o.handleSuccess(e)}))):(e.textContent=document.querySelector("meta[name=translation-terms-required]").content,e.hidden=!1,void console.log("Terms"))}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}var t,n,o;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.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")}}])&&a(t.prototype,n),o&&a(t,o),e}(),i=null!==(e=null===(t=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===t?void 0:t.content)&&void 0!==e?e:"",d=null!==(n=null===(o=document.querySelector('meta[name="stripe-account-id"]'))||void 0===o?void 0:o.content)&&void 0!==n?n:"";new c(i,d).setupStripe().handle()})(); \ No newline at end of file +(()=>{var e,t,n,o;function a(e,t){for(var n=0;n svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),void o.stripe.confirmSepaDebitSetup(document.querySelector("meta[name=si-client-secret").content,{payment_method:document.querySelector("input[name=token]").value}).then((function(e){if(!e.error)return document.querySelector('input[name="gateway_response"]').value=JSON.stringify(e.setupIntent),document.querySelector("#server-response").submit();console.error(error)})).catch((function(t){e.textContent=t,e.hidden=!1}))):""===document.getElementById("sepa-name").value?(document.getElementById("sepa-name").focus(),e.textContent=document.querySelector("meta[name=translation-name-required]").content,void(e.hidden=!1)):""===document.getElementById("sepa-email-address").value?(document.getElementById("sepa-email-address").focus(),e.textContent=document.querySelector("meta[name=translation-email-required]").content,void(e.hidden=!1)):document.getElementById("sepa-mandate-acceptance").checked?(document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),void o.stripe.confirmSepaDebitPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{sepa_debit:o.iban,billing_details:{name:document.getElementById("sepa-name").value,email:document.getElementById("sepa-email-address").value}}}).then((function(e){return e.error?o.handleFailure(e.error.message):o.handleSuccess(e)}))):(e.textContent=document.querySelector("meta[name=translation-terms-required]").content,e.hidden=!1,void console.log("Terms"))}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}var t,n,o;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.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")}}])&&a(t.prototype,n),o&&a(t,o),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===(o=document.querySelector('meta[name="stripe-account-id"]'))||void 0===o?void 0:o.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 3343cf7e7f0f..c34f49f64e82 100755 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -2,11 +2,11 @@ "/js/app.js": "/js/app.js?id=0e3959ab851d3350364d", "/js/clients/payment_methods/authorize-authorize-card.js": "/js/clients/payment_methods/authorize-authorize-card.js?id=de4468c682d6861847de", "/js/clients/payments/authorize-credit-card-payment.js": "/js/clients/payments/authorize-credit-card-payment.js?id=cfe5de1cf87a0b01568d", - "/js/clients/payments/stripe-ach.js": "/js/clients/payments/stripe-ach.js?id=5e74bc0d346beeb57ee9", + "/js/clients/payments/stripe-ach.js": "/js/clients/payments/stripe-ach.js?id=a5f14c885c3aeef6c744", "/js/clients/invoices/action-selectors.js": "/js/clients/invoices/action-selectors.js?id=6b79265cbb8c963eef19", "/js/clients/invoices/payment.js": "/js/clients/invoices/payment.js?id=2cccf9e51b60a0ab17b8", "/js/clients/payments/stripe-sofort.js": "/js/clients/payments/stripe-sofort.js?id=22fc06e698dea2c3bdf3", - "/js/clients/payments/stripe-alipay.js": "/js/clients/payments/stripe-alipay.js?id=1e159400d6a5ca4662c1", + "/js/clients/payments/stripe-alipay.js": "/js/clients/payments/stripe-alipay.js?id=d471e0433c57e23051ed", "/js/clients/payments/checkout-credit-card.js": "/js/clients/payments/checkout-credit-card.js?id=0b47ce36fe20191adb33", "/js/clients/quotes/action-selectors.js": "/js/clients/quotes/action-selectors.js?id=63f0688329be80ee8693", "/js/clients/quotes/approve.js": "/js/clients/quotes/approve.js?id=795d2f44cf3d117a554e", @@ -27,17 +27,17 @@ "/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=cbd7bb4c483ca75333f4", + "/js/clients/payments/stripe-sepa.js": "/js/clients/payments/stripe-sepa.js?id=2daa1a70aa5f8e6988f5", "/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=cdf300d72a1564d19b72", - "/js/clients/payments/stripe-acss.js": "/js/clients/payments/stripe-acss.js?id=ec4f85eaeacd1d2135f5", - "/js/clients/payments/stripe-bancontact.js": "/js/clients/payments/stripe-bancontact.js?id=66bbac90bf652dd16313", - "/js/clients/payments/stripe-becs.js": "/js/clients/payments/stripe-becs.js?id=46f2e5093f6c879f274e", - "/js/clients/payments/stripe-eps.js": "/js/clients/payments/stripe-eps.js?id=1ed972f879869de66c8a", - "/js/clients/payments/stripe-ideal.js": "/js/clients/payments/stripe-ideal.js?id=73ce56676f9252b0cecf", - "/js/clients/payments/stripe-przelewy24.js": "/js/clients/payments/stripe-przelewy24.js?id=f3a14f78bec8209c30ba", + "/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", + "/js/clients/payments/stripe-bancontact.js": "/js/clients/payments/stripe-bancontact.js?id=8469db468493337fc122", + "/js/clients/payments/stripe-becs.js": "/js/clients/payments/stripe-becs.js?id=b378dd507ceacebc99e4", + "/js/clients/payments/stripe-eps.js": "/js/clients/payments/stripe-eps.js?id=6bed81ba3f73a695de95", + "/js/clients/payments/stripe-ideal.js": "/js/clients/payments/stripe-ideal.js?id=188426574f27660936e2", + "/js/clients/payments/stripe-przelewy24.js": "/js/clients/payments/stripe-przelewy24.js?id=e240b907ad163cac04c0", "/js/clients/payments/stripe-browserpay.js": "/js/clients/payments/stripe-browserpay.js?id=71e49866d66a6d85b88a", - "/js/clients/payments/stripe-fpx.js": "/js/clients/payments/stripe-fpx.js?id=915712157bc0634b9b21", + "/js/clients/payments/stripe-fpx.js": "/js/clients/payments/stripe-fpx.js?id=3a1cac8fb671c2e4337f", "/css/app.css": "/css/app.css?id=cab8a6526b0f9f71842d", "/css/card-js.min.css": "/css/card-js.min.css?id=62afeb675235451543ad" } diff --git a/resources/js/clients/payments/stripe-ach.js b/resources/js/clients/payments/stripe-ach.js index b942da7e49d6..e8f84827f78b 100644 --- a/resources/js/clients/payments/stripe-ach.js +++ b/resources/js/clients/payments/stripe-ach.js @@ -20,10 +20,19 @@ class AuthorizeACH { } setupStripe = () => { - this.stripe = Stripe(this.key); - if(this.stripe_connect) - this.stripe.stripeAccount = this.stripe_connect; + if (this.stripeConnect){ + // this.stripe.stripeAccount = this.stripeConnect; + + this.stripe = Stripe(this.key, { + stripeAccount: this.stripeConnect, + }); + + } + else { + this.stripe = Stripe(this.key); + } + return this; }; diff --git a/resources/js/clients/payments/stripe-acss.js b/resources/js/clients/payments/stripe-acss.js index 1885374d43d1..9d09e9a9ed0c 100644 --- a/resources/js/clients/payments/stripe-acss.js +++ b/resources/js/clients/payments/stripe-acss.js @@ -16,10 +16,19 @@ class ProcessACSS { } setupStripe = () => { - this.stripe = Stripe(this.key); - if(this.stripeConnect) - this.stripe.stripeAccount = stripeConnect; + if (this.stripeConnect){ + // this.stripe.stripeAccount = this.stripeConnect; + + this.stripe = Stripe(this.key, { + stripeAccount: this.stripeConnect, + }); + + } + else { + this.stripe = Stripe(this.key); + } + return this; }; diff --git a/resources/js/clients/payments/stripe-alipay.js b/resources/js/clients/payments/stripe-alipay.js index d026a678e475..2ab214165e53 100644 --- a/resources/js/clients/payments/stripe-alipay.js +++ b/resources/js/clients/payments/stripe-alipay.js @@ -17,10 +17,19 @@ class ProcessAlipay { } setupStripe = () => { - this.stripe = Stripe(this.key); - if(this.stripeConnect) - this.stripe.stripeAccount = this.stripeConnect; + if (this.stripeConnect){ + // this.stripe.stripeAccount = this.stripeConnect; + + this.stripe = Stripe(this.key, { + stripeAccount: this.stripeConnect, + }); + + } + else { + this.stripe = Stripe(this.key); + } + return this; }; diff --git a/resources/js/clients/payments/stripe-bancontact.js b/resources/js/clients/payments/stripe-bancontact.js index 8b5b468d705a..793a2278c96b 100644 --- a/resources/js/clients/payments/stripe-bancontact.js +++ b/resources/js/clients/payments/stripe-bancontact.js @@ -16,10 +16,19 @@ class ProcessBANCONTACTPay { } setupStripe = () => { - this.stripe = Stripe(this.key); - if(this.stripeConnect) - this.stripe.stripeAccount = stripeConnect; + if (this.stripeConnect){ + // this.stripe.stripeAccount = this.stripeConnect; + + this.stripe = Stripe(this.key, { + stripeAccount: this.stripeConnect, + }); + + } + else { + this.stripe = Stripe(this.key); + } + return this; }; diff --git a/resources/js/clients/payments/stripe-becs.js b/resources/js/clients/payments/stripe-becs.js index 843870efce78..774d67882099 100644 --- a/resources/js/clients/payments/stripe-becs.js +++ b/resources/js/clients/payments/stripe-becs.js @@ -16,10 +16,19 @@ class ProcessBECS { } setupStripe = () => { - this.stripe = Stripe(this.key); - if(this.stripeConnect) - this.stripe.stripeAccount = stripeConnect; + if (this.stripeConnect){ + // this.stripe.stripeAccount = this.stripeConnect; + + this.stripe = Stripe(this.key, { + stripeAccount: this.stripeConnect, + }); + + } + else { + this.stripe = Stripe(this.key); + } + const elements = this.stripe.elements(); const style = { base: { diff --git a/resources/js/clients/payments/stripe-eps.js b/resources/js/clients/payments/stripe-eps.js index f99a3f7ee754..55157796f420 100644 --- a/resources/js/clients/payments/stripe-eps.js +++ b/resources/js/clients/payments/stripe-eps.js @@ -16,10 +16,21 @@ class ProcessEPSPay { } setupStripe = () => { - this.stripe = Stripe(this.key); - if(this.stripeConnect) - this.stripe.stripeAccount = stripeConnect; + + if (this.stripeConnect){ + // this.stripe.stripeAccount = this.stripeConnect; + + this.stripe = Stripe(this.key, { + stripeAccount: this.stripeConnect, + }); + + } + else { + this.stripe = Stripe(this.key); + } + + let elements = this.stripe.elements(); var options = { style: { diff --git a/resources/js/clients/payments/stripe-fpx.js b/resources/js/clients/payments/stripe-fpx.js index 415cb6449469..7304af4ebe74 100644 --- a/resources/js/clients/payments/stripe-fpx.js +++ b/resources/js/clients/payments/stripe-fpx.js @@ -16,10 +16,20 @@ class ProcessFPXPay { } setupStripe = () => { - this.stripe = Stripe(this.key); - if(this.stripeConnect) - this.stripe.stripeAccount = stripeConnect; + + if (this.stripeConnect){ + // this.stripe.stripeAccount = this.stripeConnect; + + this.stripe = Stripe(this.key, { + stripeAccount: this.stripeConnect, + }); + + } + else { + this.stripe = Stripe(this.key); + } + let elements = this.stripe.elements(); let style = { base: { diff --git a/resources/js/clients/payments/stripe-giropay.js b/resources/js/clients/payments/stripe-giropay.js index 55eb1d0733c4..d0443b44d3c9 100644 --- a/resources/js/clients/payments/stripe-giropay.js +++ b/resources/js/clients/payments/stripe-giropay.js @@ -16,10 +16,19 @@ class ProcessGiroPay { } setupStripe = () => { - this.stripe = Stripe(this.key); - if(this.stripeConnect) - this.stripe.stripeAccount = stripeConnect; + if (this.stripeConnect){ + // this.stripe.stripeAccount = this.stripeConnect; + + this.stripe = Stripe(this.key, { + stripeAccount: this.stripeConnect, + }); + + } + else { + this.stripe = Stripe(this.key); + } + return this; }; diff --git a/resources/js/clients/payments/stripe-ideal.js b/resources/js/clients/payments/stripe-ideal.js index 56d7470be15b..7159e29301e8 100644 --- a/resources/js/clients/payments/stripe-ideal.js +++ b/resources/js/clients/payments/stripe-ideal.js @@ -16,10 +16,21 @@ class ProcessIDEALPay { } setupStripe = () => { - this.stripe = Stripe(this.key); - if(this.stripeConnect) - this.stripe.stripeAccount = stripeConnect; + + if (this.stripeConnect){ + // this.stripe.stripeAccount = this.stripeConnect; + + this.stripe = Stripe(this.key, { + stripeAccount: this.stripeConnect, + }); + + } + else { + this.stripe = Stripe(this.key); + } + + let elements = this.stripe.elements(); var options = { style: { diff --git a/resources/js/clients/payments/stripe-przelewy24.js b/resources/js/clients/payments/stripe-przelewy24.js index ca6df2654e46..15b8fb396d87 100644 --- a/resources/js/clients/payments/stripe-przelewy24.js +++ b/resources/js/clients/payments/stripe-przelewy24.js @@ -16,10 +16,20 @@ class ProcessPRZELEWY24 { } setupStripe = () => { - this.stripe = Stripe(this.key); - if(this.stripeConnect) - this.stripe.stripeAccount = stripeConnect; + if (this.stripeConnect){ + // this.stripe.stripeAccount = this.stripeConnect; + + this.stripe = Stripe(this.key, { + stripeAccount: this.stripeConnect, + }); + + } + else { + this.stripe = Stripe(this.key); + } + + let elements = this.stripe.elements() var options = { // Custom styling can be passed to options when creating an Element diff --git a/resources/js/clients/payments/stripe-sepa.js b/resources/js/clients/payments/stripe-sepa.js index 9760d8a75674..e794eb9c823e 100644 --- a/resources/js/clients/payments/stripe-sepa.js +++ b/resources/js/clients/payments/stripe-sepa.js @@ -16,9 +16,21 @@ class ProcessSEPA { } setupStripe = () => { - this.stripe = Stripe(this.key); - if (this.stripeConnect) this.stripe.stripeAccount = stripeConnect; + if (this.stripeConnect){ + // this.stripe.stripeAccount = this.stripeConnect; + + this.stripe = Stripe(this.key, { + stripeAccount: this.stripeConnect, + }); + + } + else { + this.stripe = Stripe(this.key); + } + + + const elements = this.stripe.elements(); var style = { base: { From 048b792da0c2ad1cdb8d1ac05dc65a344bcb0c3f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 23 Jan 2022 10:28:13 +1100 Subject: [PATCH 11/11] Additional analytic metrics --- app/DataMapper/Analytics/AccountPlatform.php | 61 ++++++++++++++++++ app/Jobs/Account/CreateAccount.php | 66 +++++++++++--------- 2 files changed, 96 insertions(+), 31 deletions(-) create mode 100644 app/DataMapper/Analytics/AccountPlatform.php diff --git a/app/DataMapper/Analytics/AccountPlatform.php b/app/DataMapper/Analytics/AccountPlatform.php new file mode 100644 index 000000000000..b495601d421b --- /dev/null +++ b/app/DataMapper/Analytics/AccountPlatform.php @@ -0,0 +1,61 @@ +string_metric5 = $string_metric5; + $this->string_metric6 = $string_metric6; + $this->string_metric7 = $string_metric7; + } +} diff --git a/app/Jobs/Account/CreateAccount.php b/app/Jobs/Account/CreateAccount.php index 75b230298e06..3277c08479ea 100644 --- a/app/Jobs/Account/CreateAccount.php +++ b/app/Jobs/Account/CreateAccount.php @@ -12,6 +12,7 @@ namespace App\Jobs\Account; use App\DataMapper\Analytics\AccountCreated as AnalyticsAccountCreated; +use App\DataMapper\Analytics\AccountPlatform; use App\Events\Account\AccountCreated; use App\Jobs\Company\CreateCompany; use App\Jobs\Company\CreateCompanyPaymentTerms; @@ -137,52 +138,55 @@ class CreateAccount LightLogs::create(new AnalyticsAccountCreated()) ->increment() ->queue(); + + $ip = request()->hasHeader('Cf-Connecting-Ip') ? request()->header('Cf-Connecting-Ip') : request()->getClientIp(); + $platform = request()->has('platform') ? request()->input('platform') : 'www'; - - + LightLogs::create(new AccountPlatform($platform, request()->server('HTTP_USER_AGENT'), $ip)) + ->queue(); return $sp794f3f; } - private function processSettings($settings) - { - if(Ninja::isHosted() && Cache::get('currencies')) - { + // private function processSettings($settings) + // { + // if(Ninja::isHosted() && Cache::get('currencies')) + // { - $currency = Cache::get('currencies')->filter(function ($item) use ($currency_code) { - return strtolower($item->code) == $currency_code; - })->first(); + // $currency = Cache::get('currencies')->filter(function ($item) use ($currency_code) { + // return strtolower($item->code) == $currency_code; + // })->first(); - if ($currency) { - $settings->currency_id = (string)$currency->id; - } + // if ($currency) { + // $settings->currency_id = (string)$currency->id; + // } - $country = Cache::get('countries')->filter(function ($item) use ($country_code) { - return strtolower($item->iso_3166_2) == $country_code || strtolower($item->iso_3166_3) == $country_code; - })->first(); + // $country = Cache::get('countries')->filter(function ($item) use ($country_code) { + // return strtolower($item->iso_3166_2) == $country_code || strtolower($item->iso_3166_3) == $country_code; + // })->first(); - if ($country) { - $settings->country_id = (string)$country->id; - } + // if ($country) { + // $settings->country_id = (string)$country->id; + // } - $language = Cache::get('languages')->filter(function ($item) use ($currency_code) { - return strtolower($item->locale) == $currency_code; - })->first(); + // $language = Cache::get('languages')->filter(function ($item) use ($currency_code) { + // return strtolower($item->locale) == $currency_code; + // })->first(); - if ($language) { - $settings->language_id = (string)$language->id; - } + // if ($language) { + // $settings->language_id = (string)$language->id; + // } - if($timezone) { - $settings->timezone_id = (string)$timezone->id; - } + // if($timezone) { + // $settings->timezone_id = (string)$timezone->id; + // } - return $settings; - } + // return $settings; + // } - return $settings; - } + // return $settings; + // } }