From 57852a6ca4125b613685d66ba772846c40253c37 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 10:07:29 +1000 Subject: [PATCH 01/50] Fixes for token billing - payfast --- app/PaymentDrivers/PayFast/Token.php | 7 +++++-- app/PaymentDrivers/PayFastPaymentDriver.php | 2 +- database/seeders/PaymentLibrariesSeeder.php | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index fc1235a0d3cc..52a93b87d027 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -88,13 +88,16 @@ class Token $body = [ 'amount' => $amount, 'item_name' => 'purchase', - 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), 'm_payment_id' => $payment_hash->hash, - 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), ]; $header['signature'] = $this->genSig(array_merge($header, $body)); + $body = array_merge($body,[ + 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), + 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), + ]); + nlog($header['signature']); nlog($header['timestamp']); nlog($this->payfast->company_gateway->getConfigField('merchantId')); diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 6f56aebe9d3f..864973ce3214 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -77,7 +77,7 @@ class PayFastPaymentDriver extends BaseDriver ] ); - } catch(Exception $e) { + } catch(\Exception $e) { echo '##PAYFAST## There was an exception: '.$e->getMessage(); diff --git a/database/seeders/PaymentLibrariesSeeder.php b/database/seeders/PaymentLibrariesSeeder.php index 17a9ac173588..818431f7de96 100644 --- a/database/seeders/PaymentLibrariesSeeder.php +++ b/database/seeders/PaymentLibrariesSeeder.php @@ -97,7 +97,7 @@ class PaymentLibrariesSeeder extends Seeder Gateway::query()->update(['visible' => 0]); - Gateway::whereIn('id', [1,7,15,20,39,46,55,50,57])->update(['visible' => 1]); + Gateway::whereIn('id', [1,7,11,15,20,39,46,55,50,57])->update(['visible' => 1]); if (Ninja::isHosted()) { Gateway::whereIn('id', [20])->update(['visible' => 0]); From 2d06fa200c85d416254ec1d846df967d4bd26016 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 10:22:33 +1000 Subject: [PATCH 02/50] Turning on token billing for PayFast --- app/Models/Gateway.php | 2 +- app/PaymentDrivers/PayFastPaymentDriver.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/Gateway.php b/app/Models/Gateway.php index 4414a685c9b0..4fa03256328b 100644 --- a/app/Models/Gateway.php +++ b/app/Models/Gateway.php @@ -85,7 +85,7 @@ class Gateway extends StaticModel return [GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => true]];//eWay break; case 11: - return [GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => false]];//Payfast + return [GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => true]];//Payfast break; case 7: return [ diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 864973ce3214..342442b6f7dc 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -28,7 +28,7 @@ class PayFastPaymentDriver extends BaseDriver public $refundable = false; //does this gateway support refunds? - public $token_billing = false; //does this gateway support token billing? + public $token_billing = true; //does this gateway support token billing? public $can_authorise_credit_card = true; //does this gateway support authorizations? From 70e08cf3f9b15907aa27ab8e450c51a2008a3aac Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 10:24:28 +1000 Subject: [PATCH 03/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 52a93b87d027..97cedb741a9d 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -89,13 +89,13 @@ class Token 'amount' => $amount, 'item_name' => 'purchase', 'm_payment_id' => $payment_hash->hash, + 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), ]; $header['signature'] = $this->genSig(array_merge($header, $body)); $body = array_merge($body,[ 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), - 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), ]); nlog($header['signature']); From 6fa87affdbd0a459bc44d78fc660c3f104029725 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 10:31:53 +1000 Subject: [PATCH 04/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 97cedb741a9d..a164bd5e3fa6 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -83,8 +83,6 @@ class Token 'version' => 'v1', ]; - nlog($header); - $body = [ 'amount' => $amount, 'item_name' => 'purchase', @@ -92,14 +90,13 @@ class Token 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), ]; - $header['signature'] = $this->genSig(array_merge($header, $body)); + // $header['signature'] = $this->genSig(array_merge($header, $body)); + $header['signature'] = $this->genSig($body); $body = array_merge($body,[ 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), ]); - nlog($header['signature']); - nlog($header['timestamp']); nlog($this->payfast->company_gateway->getConfigField('merchantId')); $result = $this->send($header, $body, $cgt->token); From 63d4e1f153bd10d71df7d18817b23c5fbf3e4527 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 10:33:11 +1000 Subject: [PATCH 05/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index a164bd5e3fa6..03df0e6058b4 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -87,13 +87,13 @@ class Token 'amount' => $amount, 'item_name' => 'purchase', 'm_payment_id' => $payment_hash->hash, - 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), ]; // $header['signature'] = $this->genSig(array_merge($header, $body)); $header['signature'] = $this->genSig($body); $body = array_merge($body,[ + 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), ]); From cc4e3cdef3295b63a5deb2c20364154397b7b5c5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 10:37:00 +1000 Subject: [PATCH 06/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 03df0e6058b4..a6b6bac5be77 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -87,16 +87,13 @@ class Token 'amount' => $amount, 'item_name' => 'purchase', 'm_payment_id' => $payment_hash->hash, + 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), + 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), ]; // $header['signature'] = $this->genSig(array_merge($header, $body)); $header['signature'] = $this->genSig($body); - $body = array_merge($body,[ - 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), - 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), - ]); - nlog($this->payfast->company_gateway->getConfigField('merchantId')); $result = $this->send($header, $body, $cgt->token); From 721e6d442ca01e59c645a7556a7b0dea30272e5c Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 10:54:24 +1000 Subject: [PATCH 07/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index a6b6bac5be77..56a144bd3a04 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -91,8 +91,8 @@ class Token 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), ]; - // $header['signature'] = $this->genSig(array_merge($header, $body)); - $header['signature'] = $this->genSig($body); + $header['signature'] = $this->genSig(array_merge($header, $body)); + // $header['signature'] = $this->genSig($body); nlog($this->payfast->company_gateway->getConfigField('merchantId')); From 875b4fc2f6cc5642768962902324eceaa6fb1d26 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 10:55:33 +1000 Subject: [PATCH 08/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 56a144bd3a04..84626a1c714b 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -79,8 +79,8 @@ class Token $header =[ 'merchant-id' => $this->payfast->company_gateway->getConfigField('merchantId'), - 'timestamp' => now()->format('c'), 'version' => 'v1', + 'timestamp' => now()->format('c'), ]; $body = [ From 307dbdcb0796c16c28f9b13610f953f7de4729a0 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 11:03:27 +1000 Subject: [PATCH 09/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 84626a1c714b..a4e624b78271 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -91,7 +91,7 @@ class Token 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), ]; - $header['signature'] = $this->genSig(array_merge($header, $body)); + $header['signature'] = $this->payfast->generateSignature(array_merge($header, $body)); // $header['signature'] = $this->genSig($body); nlog($this->payfast->company_gateway->getConfigField('merchantId')); From c9bb97f4d00da3a75e3d79904f851e51a320bc1a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 12:03:49 +1000 Subject: [PATCH 10/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 4 ++-- app/PaymentDrivers/PayFastPaymentDriver.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index a4e624b78271..38fcd88466e1 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -87,11 +87,11 @@ class Token 'amount' => $amount, 'item_name' => 'purchase', 'm_payment_id' => $payment_hash->hash, - 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), + 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), ]; - $header['signature'] = $this->payfast->generateSignature(array_merge($header, $body)); + $header['signature'] = $this->payfast->generateSignature($body); // $header['signature'] = $this->genSig($body); nlog($this->payfast->company_gateway->getConfigField('merchantId')); diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 342442b6f7dc..d644a87dab41 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -134,7 +134,7 @@ class PayFastPaymentDriver extends BaseDriver /** * Transaction Details */ - 'm_payment_id', 'amount', 'item_name', 'item_description', + 'amount', 'item_name', 'm_payment_id', 'item_description', /** * Custom return data */ From a183df8090b18ad8881c25733c4b1c18d8787858 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 12:09:12 +1000 Subject: [PATCH 11/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 8 ++++---- app/PaymentDrivers/PayFastPaymentDriver.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 38fcd88466e1..6110a2e14bb2 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -87,12 +87,12 @@ class Token 'amount' => $amount, 'item_name' => 'purchase', 'm_payment_id' => $payment_hash->hash, - 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), - 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), + // 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), + // 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), ]; - $header['signature'] = $this->payfast->generateSignature($body); - // $header['signature'] = $this->genSig($body); + // $header['signature'] = $this->payfast->generateSignature($body); + $header['signature'] = $this->genSig($body); nlog($this->payfast->company_gateway->getConfigField('merchantId')); diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index d644a87dab41..342442b6f7dc 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -134,7 +134,7 @@ class PayFastPaymentDriver extends BaseDriver /** * Transaction Details */ - 'amount', 'item_name', 'm_payment_id', 'item_description', + 'm_payment_id', 'amount', 'item_name', 'item_description', /** * Custom return data */ From a1b19b46d61647313bf72427c76a2e2eb1ae5f82 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 13:14:41 +1000 Subject: [PATCH 12/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 6110a2e14bb2..aacdde7bfe5b 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -84,6 +84,9 @@ class Token ]; $body = [ + 'merchant_id' => $this->payfast->company_gateway->getConfigField('merchantId'), + 'merchant_key' => $this->company_gateway->getConfigField('merchantKey'), + 'passphrase' => $this->payfast->cpayfast->ompany_gateway->getConfigField('passPhrase'), 'amount' => $amount, 'item_name' => 'purchase', 'm_payment_id' => $payment_hash->hash, @@ -91,8 +94,8 @@ class Token // 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), ]; - // $header['signature'] = $this->payfast->generateSignature($body); - $header['signature'] = $this->genSig($body); + $header['signature'] = $this->payfast->generateSignature($body); + //$header['signature'] = $this->genSig($body); nlog($this->payfast->company_gateway->getConfigField('merchantId')); From 4314f71f6384762ced0ca0a1fd8ed3428f2d68a2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 13:15:20 +1000 Subject: [PATCH 13/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index aacdde7bfe5b..964a72725583 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -85,7 +85,7 @@ class Token $body = [ 'merchant_id' => $this->payfast->company_gateway->getConfigField('merchantId'), - 'merchant_key' => $this->company_gateway->getConfigField('merchantKey'), + 'merchant_key' => $this->payfast->company_gateway->getConfigField('merchantKey'), 'passphrase' => $this->payfast->cpayfast->ompany_gateway->getConfigField('passPhrase'), 'amount' => $amount, 'item_name' => 'purchase', From c0d7b07f1706b7a0daae4096bde3a72fb5ab1231 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 13:15:54 +1000 Subject: [PATCH 14/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 964a72725583..3dd2be832b12 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -86,7 +86,7 @@ class Token $body = [ 'merchant_id' => $this->payfast->company_gateway->getConfigField('merchantId'), 'merchant_key' => $this->payfast->company_gateway->getConfigField('merchantKey'), - 'passphrase' => $this->payfast->cpayfast->ompany_gateway->getConfigField('passPhrase'), + 'passphrase' => $this->payfast->company_gateway->getConfigField('passPhrase'), 'amount' => $amount, 'item_name' => 'purchase', 'm_payment_id' => $payment_hash->hash, From d2735df1c37e71a313e5a6559fea0f510ba80903 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 13:19:06 +1000 Subject: [PATCH 15/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 3dd2be832b12..6e2dfe8dc536 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -86,12 +86,16 @@ class Token $body = [ 'merchant_id' => $this->payfast->company_gateway->getConfigField('merchantId'), 'merchant_key' => $this->payfast->company_gateway->getConfigField('merchantKey'), - 'passphrase' => $this->payfast->company_gateway->getConfigField('passPhrase'), + 'return_url' => route('client.payment_methods.index'), + 'cancel_url' => route('client.payment_methods.index'), + 'notify_url' => $this->payfast->genericWebhookUrl(), + 'm_payment_id' => $payment_hash->hash, 'amount' => $amount, 'item_name' => 'purchase', - 'm_payment_id' => $payment_hash->hash, - // 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), - // 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), + 'item_description' => 'Purchase', + 'subscription_type' => 1, + 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), + ]; $header['signature'] = $this->payfast->generateSignature($body); From e08daf23fc5b580ee8a723987d58372e5d4c65a0 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 13:26:50 +1000 Subject: [PATCH 16/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 52 +++++++++++++++++++++------- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 6e2dfe8dc536..cb8f02513fa1 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -79,26 +79,17 @@ class Token $header =[ 'merchant-id' => $this->payfast->company_gateway->getConfigField('merchantId'), - 'version' => 'v1', 'timestamp' => now()->format('c'), + 'version' => 'v1', ]; - $body = [ - 'merchant_id' => $this->payfast->company_gateway->getConfigField('merchantId'), - 'merchant_key' => $this->payfast->company_gateway->getConfigField('merchantKey'), - 'return_url' => route('client.payment_methods.index'), - 'cancel_url' => route('client.payment_methods.index'), - 'notify_url' => $this->payfast->genericWebhookUrl(), - 'm_payment_id' => $payment_hash->hash, + $body['body'] = [ 'amount' => $amount, 'item_name' => 'purchase', 'item_description' => 'Purchase', - 'subscription_type' => 1, - 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), - ]; - $header['signature'] = $this->payfast->generateSignature($body); + $header['signature'] = $this->generate_parameter_string(array_merge($header, $body)); //$header['signature'] = $this->genSig($body); nlog($this->payfast->company_gateway->getConfigField('merchantId')); @@ -147,6 +138,43 @@ class Token // } } + + protected function generate_parameter_string( $api_data, $sort_data_before_merge = true, $skip_empty_values = true ) { + + // if sorting is required the passphrase should be added in before sort. + if ( ! empty( $this->pass_phrase ) && $sort_data_before_merge ) { + $api_data['passphrase'] = $this->payfast->company_gateway->getConfigField('passPhrase'); + } + + if ( $sort_data_before_merge ) { + ksort( $api_data ); + } + + // concatenate the array key value pairs. + $parameter_string = ''; + foreach ( $api_data as $key => $val ) { + + if ( $skip_empty_values && empty( $val ) ) { + continue; + } + + if ( 'signature' !== $key ) { + $val = urlencode( $val ); + $parameter_string .= "$key=$val&"; + } + } + // when not sorting passphrase should be added to the end before md5 + if ( $sort_data_before_merge ) { + $parameter_string = rtrim( $parameter_string, '&' ); + } elseif ( ! empty( $this->pass_phrase ) ) { + $parameter_string .= 'passphrase=' . urlencode( $this->pass_phrase ); + } else { + $parameter_string = rtrim( $parameter_string, '&' ); + } + + return $parameter_string; + } + private function genSig($data) { $fields = []; From 412487e7934a41e72833e28fb6323739b2aa5bdc Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 13:28:05 +1000 Subject: [PATCH 17/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index cb8f02513fa1..d7c1c1f317d1 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -167,7 +167,7 @@ class Token if ( $sort_data_before_merge ) { $parameter_string = rtrim( $parameter_string, '&' ); } elseif ( ! empty( $this->pass_phrase ) ) { - $parameter_string .= 'passphrase=' . urlencode( $this->pass_phrase ); + $parameter_string .= 'passphrase=' . urlencode( $this->payfast->company_gateway->getConfigField('passPhrase') ); } else { $parameter_string = rtrim( $parameter_string, '&' ); } From 0edb026dad92cc4e0517d81c8c44fe5cc2633035 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 13:29:14 +1000 Subject: [PATCH 18/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index d7c1c1f317d1..cebd1811e6c0 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -83,7 +83,7 @@ class Token 'version' => 'v1', ]; - $body['body'] = [ + $body = [ 'amount' => $amount, 'item_name' => 'purchase', 'item_description' => 'Purchase', @@ -142,7 +142,7 @@ class Token protected function generate_parameter_string( $api_data, $sort_data_before_merge = true, $skip_empty_values = true ) { // if sorting is required the passphrase should be added in before sort. - if ( ! empty( $this->pass_phrase ) && $sort_data_before_merge ) { + if ( ! empty( $this->payfast->company_gateway->getConfigField('passPhrase') ) && $sort_data_before_merge ) { $api_data['passphrase'] = $this->payfast->company_gateway->getConfigField('passPhrase'); } From 7e1f964b3471031c982f7ed1642f2bccb4cfd0b5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 13:39:31 +1000 Subject: [PATCH 19/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 47 ++++------------------------ 1 file changed, 6 insertions(+), 41 deletions(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index cebd1811e6c0..53af1b8bd029 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -79,18 +79,20 @@ class Token $header =[ 'merchant-id' => $this->payfast->company_gateway->getConfigField('merchantId'), - 'timestamp' => now()->format('c'), 'version' => 'v1', + 'timestamp' => now()->format('c'), ]; $body = [ 'amount' => $amount, 'item_name' => 'purchase', - 'item_description' => 'Purchase', + 'm_payment_id' => $payment_hash->hash, + 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), + 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), ]; - $header['signature'] = $this->generate_parameter_string(array_merge($header, $body)); - //$header['signature'] = $this->genSig($body); + $header['signature'] = $this->payfast->generateSignature(array_merge($header, $body)); + // $header['signature'] = $this->genSig($body); nlog($this->payfast->company_gateway->getConfigField('merchantId')); @@ -138,43 +140,6 @@ class Token // } } - - protected function generate_parameter_string( $api_data, $sort_data_before_merge = true, $skip_empty_values = true ) { - - // if sorting is required the passphrase should be added in before sort. - if ( ! empty( $this->payfast->company_gateway->getConfigField('passPhrase') ) && $sort_data_before_merge ) { - $api_data['passphrase'] = $this->payfast->company_gateway->getConfigField('passPhrase'); - } - - if ( $sort_data_before_merge ) { - ksort( $api_data ); - } - - // concatenate the array key value pairs. - $parameter_string = ''; - foreach ( $api_data as $key => $val ) { - - if ( $skip_empty_values && empty( $val ) ) { - continue; - } - - if ( 'signature' !== $key ) { - $val = urlencode( $val ); - $parameter_string .= "$key=$val&"; - } - } - // when not sorting passphrase should be added to the end before md5 - if ( $sort_data_before_merge ) { - $parameter_string = rtrim( $parameter_string, '&' ); - } elseif ( ! empty( $this->pass_phrase ) ) { - $parameter_string .= 'passphrase=' . urlencode( $this->payfast->company_gateway->getConfigField('passPhrase') ); - } else { - $parameter_string = rtrim( $parameter_string, '&' ); - } - - return $parameter_string; - } - private function genSig($data) { $fields = []; From 175c8d7d8f748c2c72fb2e4cc0b040715c8f593b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 14:08:55 +1000 Subject: [PATCH 20/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 42 +++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 53af1b8bd029..7b6d7d93fd60 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -79,8 +79,8 @@ class Token $header =[ 'merchant-id' => $this->payfast->company_gateway->getConfigField('merchantId'), - 'version' => 'v1', 'timestamp' => now()->format('c'), + 'version' => 'v1', ]; $body = [ @@ -91,10 +91,9 @@ class Token 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), ]; - $header['signature'] = $this->payfast->generateSignature(array_merge($header, $body)); + // $header['signature'] = $this->payfast->generateSignature(array_merge($header, $body)); // $header['signature'] = $this->genSig($body); - - nlog($this->payfast->company_gateway->getConfigField('merchantId')); + $header['signature'] = $this->generate_parameter_string(array_merge($header, $body)); $result = $this->send($header, $body, $cgt->token); @@ -140,6 +139,41 @@ class Token // } } + protected function generate_parameter_string( $api_data, $sort_data_before_merge = true, $skip_empty_values = true ) { + + // if sorting is required the passphrase should be added in before sort. + $api_data['passphrase'] = $this->payfast->company_gateway->getConfigField('passPhrase'); + + + if ( $sort_data_before_merge ) { + ksort( $api_data ); + } + + // concatenate the array key value pairs. + $parameter_string = ''; + foreach ( $api_data as $key => $val ) { + + if ( $skip_empty_values && empty( $val ) ) { + continue; + } + + if ( 'signature' !== $key ) { + $val = urlencode( $val ); + $parameter_string .= "$key=$val&"; + } + } + // when not sorting passphrase should be added to the end before md5 + if ( $sort_data_before_merge ) { + $parameter_string = rtrim( $parameter_string, '&' ); + } elseif ( ! empty( $this->pass_phrase ) ) { + $parameter_string .= 'passphrase=' . urlencode( $this->payfast->company_gateway->getConfigField('passPhrase') ); + } else { + $parameter_string = rtrim( $parameter_string, '&' ); + } + + return $parameter_string; + } + private function genSig($data) { $fields = []; From afd2c355f1dcd41e62d3994263761c64146a5296 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 14:10:23 +1000 Subject: [PATCH 21/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 7b6d7d93fd60..c8ae7c5d98a8 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -86,9 +86,8 @@ class Token $body = [ 'amount' => $amount, 'item_name' => 'purchase', - 'm_payment_id' => $payment_hash->hash, 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), - 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), + 'm_payment_id' => $payment_hash->hash, ]; // $header['signature'] = $this->payfast->generateSignature(array_merge($header, $body)); @@ -171,6 +170,7 @@ class Token $parameter_string = rtrim( $parameter_string, '&' ); } + nlog($parameter_string); return $parameter_string; } From 3fafc46ca797b90711eed17b7e8f4eb98ea4f91f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 14:16:36 +1000 Subject: [PATCH 22/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index c8ae7c5d98a8..fe31a39eb757 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -198,9 +198,7 @@ class Token ]); try { - $response = $client->post("https://api.payfast.co.za/subscriptions/{$token}/adhoc?testing=true",[ - RequestOptions::JSON => ['body' => $body], RequestOptions::ALLOW_REDIRECTS => false - ]); + $response = $client->post("https://api.payfast.co.za/subscriptions/{$token}/adhoc?testing=true",['query' => $body]); return json_decode($response->getBody(),true); } From a2d437deaeeb251e1f738e6ae338c7c6f63e0204 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 14:20:04 +1000 Subject: [PATCH 23/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index fe31a39eb757..673b1cf73c91 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -170,8 +170,8 @@ class Token $parameter_string = rtrim( $parameter_string, '&' ); } - nlog($parameter_string); - return $parameter_string; + return md5( $parameter_string, false, false ); + } private function genSig($data) @@ -198,7 +198,9 @@ class Token ]); try { - $response = $client->post("https://api.payfast.co.za/subscriptions/{$token}/adhoc?testing=true",['query' => $body]); + $response = $client->post("https://api.payfast.co.za/subscriptions/{$token}/adhoc?testing=true",[ + RequestOptions::JSON => ['body' => $body], RequestOptions::ALLOW_REDIRECTS => false + ]); return json_decode($response->getBody(),true); } From 536cfd4a568fda027aaff89e0ba034a9a6c888d2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 14:20:35 +1000 Subject: [PATCH 24/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 673b1cf73c91..5750c7753884 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -170,7 +170,7 @@ class Token $parameter_string = rtrim( $parameter_string, '&' ); } - return md5( $parameter_string, false, false ); + return md5( $parameter_string ); } From c9b3765136e5dc5ca3b6fd7c0f98b1a346e8ac7d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 15:03:12 +1000 Subject: [PATCH 25/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 5750c7753884..d87c0c6ae244 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -90,8 +90,6 @@ class Token 'm_payment_id' => $payment_hash->hash, ]; - // $header['signature'] = $this->payfast->generateSignature(array_merge($header, $body)); - // $header['signature'] = $this->genSig($body); $header['signature'] = $this->generate_parameter_string(array_merge($header, $body)); $result = $this->send($header, $body, $cgt->token); @@ -141,8 +139,8 @@ class Token protected function generate_parameter_string( $api_data, $sort_data_before_merge = true, $skip_empty_values = true ) { // if sorting is required the passphrase should be added in before sort. - $api_data['passphrase'] = $this->payfast->company_gateway->getConfigField('passPhrase'); - + if ( ! empty( $this->payfast->company_gateway->getConfigField('passPhrase') ) && $sort_data_before_merge ) { + $api_data['passphrase'] = $this->payfast->company_gateway->getConfigField('passPhrase'); if ( $sort_data_before_merge ) { ksort( $api_data ); From 1947b0a63b6a48b6f9c98e89fc809625f8c7902d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 15:03:46 +1000 Subject: [PATCH 26/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index d87c0c6ae244..cb0be4f7c10c 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -139,7 +139,7 @@ class Token protected function generate_parameter_string( $api_data, $sort_data_before_merge = true, $skip_empty_values = true ) { // if sorting is required the passphrase should be added in before sort. - if ( ! empty( $this->payfast->company_gateway->getConfigField('passPhrase') ) && $sort_data_before_merge ) { + if ( ! empty( $this->payfast->company_gateway->getConfigField('passPhrase') ) && $sort_data_before_merge ) $api_data['passphrase'] = $this->payfast->company_gateway->getConfigField('passPhrase'); if ( $sort_data_before_merge ) { From 64711d99beff9a5f1f9621b9fb4c09011e0f0515 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 15:06:47 +1000 Subject: [PATCH 27/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index cb0be4f7c10c..6a6f34100560 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -87,7 +87,7 @@ class Token 'amount' => $amount, 'item_name' => 'purchase', 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), - 'm_payment_id' => $payment_hash->hash, + // 'm_payment_id' => $payment_hash->hash, ]; $header['signature'] = $this->generate_parameter_string(array_merge($header, $body)); From 8bc36a7c70277a386e6303b33eb09355ac7e3244 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 15:07:40 +1000 Subject: [PATCH 28/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 6a6f34100560..367c6e6b9fe1 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -86,8 +86,8 @@ class Token $body = [ 'amount' => $amount, 'item_name' => 'purchase', - 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), - // 'm_payment_id' => $payment_hash->hash, + // 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), + 'm_payment_id' => $payment_hash->hash, ]; $header['signature'] = $this->generate_parameter_string(array_merge($header, $body)); From 210a4a5993e1f8afc4cdf18137e03a20ed8385bd Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 15:34:20 +1000 Subject: [PATCH 29/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 367c6e6b9fe1..0078aa9e4eb8 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -86,11 +86,11 @@ class Token $body = [ 'amount' => $amount, 'item_name' => 'purchase', - // 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), + 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), 'm_payment_id' => $payment_hash->hash, ]; - $header['signature'] = $this->generate_parameter_string(array_merge($header, $body)); + $header['signature'] = md5( $this->generate_parameter_string(array_merge($header, $body)) ); $result = $this->send($header, $body, $cgt->token); @@ -168,7 +168,9 @@ class Token $parameter_string = rtrim( $parameter_string, '&' ); } - return md5( $parameter_string ); + nlog($parameter_string); + + return $parameter_string; } From e2668b3b3e39fece783e7d0cbe5c819f30725e75 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 15:36:31 +1000 Subject: [PATCH 30/50] Turning on token billing for PayFast --- app/Services/Invoice/AutoBillInvoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Services/Invoice/AutoBillInvoice.php b/app/Services/Invoice/AutoBillInvoice.php index 480ba0e7fb1c..df35431f42ea 100644 --- a/app/Services/Invoice/AutoBillInvoice.php +++ b/app/Services/Invoice/AutoBillInvoice.php @@ -105,7 +105,7 @@ class AutoBillInvoice extends AbstractService /* Build payment hash */ $payment_hash = PaymentHash::create([ - 'hash' => Str::random(128), + 'hash' => Str::random(64), 'data' => ['invoices' => [['invoice_id' => $this->invoice->hashed_id, 'amount' => $amount]]], 'fee_total' => $fee, 'fee_invoice_id' => $this->invoice->id, From c0b4c4bd7397537364d35d1f37b826ff881a6694 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 15:38:24 +1000 Subject: [PATCH 31/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 0078aa9e4eb8..2219e2e6c40a 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -90,8 +90,10 @@ class Token 'm_payment_id' => $payment_hash->hash, ]; - $header['signature'] = md5( $this->generate_parameter_string(array_merge($header, $body)) ); + //$header['signature'] = md5( $this->generate_parameter_string(array_merge($header, $body)) ); + $header['signature'] = $this->payfast->generateSignature(array_merge($header, $body)); + $result = $this->send($header, $body, $cgt->token); nlog($result); From 78549220b6e431e5fa8916e5d52ec04404e2129b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 15:39:48 +1000 Subject: [PATCH 32/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFastPaymentDriver.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 342442b6f7dc..15b420584976 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -161,6 +161,8 @@ class PayFastPaymentDriver extends BaseDriver } } + nlog(http_build_query($fields)); + return md5(http_build_query($fields)); } From 5256b53d794a08897ea43c14719c78febfb14836 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 15:41:32 +1000 Subject: [PATCH 33/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 2219e2e6c40a..e4dc700fea71 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -87,13 +87,11 @@ class Token 'amount' => $amount, 'item_name' => 'purchase', 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), - 'm_payment_id' => $payment_hash->hash, + // 'm_payment_id' => $payment_hash->hash, ]; - //$header['signature'] = md5( $this->generate_parameter_string(array_merge($header, $body)) ); + $header['signature'] = md5( $this->generate_parameter_string(array_merge($header, $body)) ); - $header['signature'] = $this->payfast->generateSignature(array_merge($header, $body)); - $result = $this->send($header, $body, $cgt->token); nlog($result); From 6337144b200d6af2eb7cf35e05787edfbb81758a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 15:43:35 +1000 Subject: [PATCH 34/50] Turning on token billing for PayFast --- app/PaymentDrivers/PayFast/Token.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index e4dc700fea71..2bd79f209b71 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -90,7 +90,7 @@ class Token // 'm_payment_id' => $payment_hash->hash, ]; - $header['signature'] = md5( $this->generate_parameter_string(array_merge($header, $body)) ); + $header['signature'] = md5( $this->generate_parameter_string(array_merge($header, $body), false) ); $result = $this->send($header, $body, $cgt->token); From 72093e57f66fc9ff0922543bc85034316ec91b8e Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 15:51:48 +1000 Subject: [PATCH 35/50] PayFast token billing --- app/Models/Gateway.php | 2 +- app/PaymentDrivers/PayFastPaymentDriver.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/Gateway.php b/app/Models/Gateway.php index 4fa03256328b..4414a685c9b0 100644 --- a/app/Models/Gateway.php +++ b/app/Models/Gateway.php @@ -85,7 +85,7 @@ class Gateway extends StaticModel return [GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => true]];//eWay break; case 11: - return [GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => true]];//Payfast + return [GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => false]];//Payfast break; case 7: return [ diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 15b420584976..e2e5816a85c1 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -28,7 +28,7 @@ class PayFastPaymentDriver extends BaseDriver public $refundable = false; //does this gateway support refunds? - public $token_billing = true; //does this gateway support token billing? + public $token_billing = false; //does this gateway support token billing? public $can_authorise_credit_card = true; //does this gateway support authorizations? From dbb45e705e3dd6dfe8a7b5554221224a1b82e294 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 17:50:58 +1000 Subject: [PATCH 36/50] PayFast API token billing --- app/PaymentDrivers/PayFast/Token.php | 36 +++++++++++++++++----------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 2bd79f209b71..f263d6885098 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -77,24 +77,32 @@ class Token $amount = array_sum(array_column($payment_hash->invoices(), 'amount')) + $payment_hash->fee_total; $amount = round(($amount * pow(10, $this->payfast->client->currency()->precision)),0); - $header =[ - 'merchant-id' => $this->payfast->company_gateway->getConfigField('merchantId'), - 'timestamp' => now()->format('c'), - 'version' => 'v1', - ]; + // $header =[ + // 'merchant-id' => $this->payfast->company_gateway->getConfigField('merchantId'), + // 'timestamp' => now()->format('c'), + // 'version' => 'v1', + // ]; - $body = [ - 'amount' => $amount, - 'item_name' => 'purchase', - 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), - // 'm_payment_id' => $payment_hash->hash, - ]; + // $body = [ + // 'amount' => $amount, + // 'item_name' => 'purchase', + // 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), + // // 'm_payment_id' => $payment_hash->hash, + // ]; - $header['signature'] = md5( $this->generate_parameter_string(array_merge($header, $body), false) ); + // $header['signature'] = md5( $this->generate_parameter_string(array_merge($header, $body), false) ); - $result = $this->send($header, $body, $cgt->token); + // $result = $this->send($header, $body, $cgt->token); - nlog($result); + + $adhocArray = $this->payfast + ->init() + ->payfast + ->subscriptions + ->adhoc($cgt->token, ['amount' => $amount, 'item_name' => 'purchase']); + + + nlog($adhocArray); // /*Refactor and push to BaseDriver*/ // if ($data['response'] != null && $data['response']->getMessages()->getResultCode() == 'Ok') { From b1522218540918428d03c951e5c04ed30aca0f43 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 17:55:28 +1000 Subject: [PATCH 37/50] PayFast API token billing --- app/Models/Gateway.php | 2 +- app/PaymentDrivers/PayFastPaymentDriver.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/Gateway.php b/app/Models/Gateway.php index 4414a685c9b0..4fa03256328b 100644 --- a/app/Models/Gateway.php +++ b/app/Models/Gateway.php @@ -85,7 +85,7 @@ class Gateway extends StaticModel return [GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => true]];//eWay break; case 11: - return [GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => false]];//Payfast + return [GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => true]];//Payfast break; case 7: return [ diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index e2e5816a85c1..15b420584976 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -28,7 +28,7 @@ class PayFastPaymentDriver extends BaseDriver public $refundable = false; //does this gateway support refunds? - public $token_billing = false; //does this gateway support token billing? + public $token_billing = true; //does this gateway support token billing? public $can_authorise_credit_card = true; //does this gateway support authorizations? From 5bbeaaba602e51de4fe92162f6d6c59caed14779 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 17:56:56 +1000 Subject: [PATCH 38/50] PayFast API token billing --- app/PaymentDrivers/PayFast/Token.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index f263d6885098..dc9cb5592260 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -93,10 +93,15 @@ class Token // $header['signature'] = md5( $this->generate_parameter_string(array_merge($header, $body), false) ); // $result = $this->send($header, $body, $cgt->token); + $api = new \PayFast\PayFastPayment( + [ + 'merchantId' => $this->company_gateway->getConfigField('merchantId'), + 'passPhrase' => $this->company_gateway->getConfigField('passPhrase'), + 'testMode' => $this->company_gateway->getConfigField('testMode') + ] + ); - - $adhocArray = $this->payfast - ->init() + $adhocArray = $api ->payfast ->subscriptions ->adhoc($cgt->token, ['amount' => $amount, 'item_name' => 'purchase']); From b90049001fdd2774663b9cb65a7c44f47041c02a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 17:57:24 +1000 Subject: [PATCH 39/50] PayFast API token billing --- app/PaymentDrivers/PayFast/Token.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index dc9cb5592260..aac927f77f80 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -95,9 +95,9 @@ class Token // $result = $this->send($header, $body, $cgt->token); $api = new \PayFast\PayFastPayment( [ - 'merchantId' => $this->company_gateway->getConfigField('merchantId'), - 'passPhrase' => $this->company_gateway->getConfigField('passPhrase'), - 'testMode' => $this->company_gateway->getConfigField('testMode') + 'merchantId' => $this->payfast->company_gateway->getConfigField('merchantId'), + 'passPhrase' => $this->payfast->company_gateway->getConfigField('passPhrase'), + 'testMode' => $this->payfast->company_gateway->getConfigField('testMode') ] ); From cf2b0669a7de0ca44c888e89390d0038269fbbcc Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 17:57:59 +1000 Subject: [PATCH 40/50] PayFast API token billing --- app/PaymentDrivers/PayFast/Token.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index aac927f77f80..8f4f8265fabb 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -97,6 +97,7 @@ class Token [ 'merchantId' => $this->payfast->company_gateway->getConfigField('merchantId'), 'passPhrase' => $this->payfast->company_gateway->getConfigField('passPhrase'), + 'merchantKey' => $this->payfast->company_gateway->getConfigField('merchantKey'), 'testMode' => $this->payfast->company_gateway->getConfigField('testMode') ] ); From 86b88114f8bad32b573f85260790e13ae7d36675 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 17:58:33 +1000 Subject: [PATCH 41/50] PayFast API token billing --- app/PaymentDrivers/PayFast/Token.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 8f4f8265fabb..8259885369e0 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -103,7 +103,6 @@ class Token ); $adhocArray = $api - ->payfast ->subscriptions ->adhoc($cgt->token, ['amount' => $amount, 'item_name' => 'purchase']); From 2869ee2590e66da62725773a14cb2bedd51d6777 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 18:09:06 +1000 Subject: [PATCH 42/50] PayFast API token billing --- app/PaymentDrivers/PayFast/Token.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 8259885369e0..0a812f125924 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -93,11 +93,10 @@ class Token // $header['signature'] = md5( $this->generate_parameter_string(array_merge($header, $body), false) ); // $result = $this->send($header, $body, $cgt->token); - $api = new \PayFast\PayFastPayment( + $api = new \PayFast\PayFastApi( [ 'merchantId' => $this->payfast->company_gateway->getConfigField('merchantId'), 'passPhrase' => $this->payfast->company_gateway->getConfigField('passPhrase'), - 'merchantKey' => $this->payfast->company_gateway->getConfigField('merchantKey'), 'testMode' => $this->payfast->company_gateway->getConfigField('testMode') ] ); From 4d521dfeacdcc3987f27a1fac2b1ffb6d4ea6369 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 20:06:14 +1000 Subject: [PATCH 43/50] Abandon PayFast adhoc token billing --- app/Models/Gateway.php | 2 +- app/PaymentDrivers/PayFastPaymentDriver.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/Gateway.php b/app/Models/Gateway.php index 4fa03256328b..4414a685c9b0 100644 --- a/app/Models/Gateway.php +++ b/app/Models/Gateway.php @@ -85,7 +85,7 @@ class Gateway extends StaticModel return [GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => true]];//eWay break; case 11: - return [GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => true]];//Payfast + return [GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => false]];//Payfast break; case 7: return [ diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 15b420584976..e2e5816a85c1 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -28,7 +28,7 @@ class PayFastPaymentDriver extends BaseDriver public $refundable = false; //does this gateway support refunds? - public $token_billing = true; //does this gateway support token billing? + public $token_billing = false; //does this gateway support token billing? public $can_authorise_credit_card = true; //does this gateway support authorizations? From 63cdc583ed6b80214970a7c21a96ba4f89c20f6a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 20:55:09 +1000 Subject: [PATCH 44/50] Adding currencies --- .../2021_09_23_100629_add_currencies.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 database/migrations/2021_09_23_100629_add_currencies.php diff --git a/database/migrations/2021_09_23_100629_add_currencies.php b/database/migrations/2021_09_23_100629_add_currencies.php new file mode 100644 index 000000000000..1648db78b1d0 --- /dev/null +++ b/database/migrations/2021_09_23_100629_add_currencies.php @@ -0,0 +1,28 @@ + Date: Thu, 23 Sep 2021 20:57:57 +1000 Subject: [PATCH 45/50] Adding currencies --- .../2021_09_23_100629_add_currencies.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/database/migrations/2021_09_23_100629_add_currencies.php b/database/migrations/2021_09_23_100629_add_currencies.php index 1648db78b1d0..9cb74a1af2e6 100644 --- a/database/migrations/2021_09_23_100629_add_currencies.php +++ b/database/migrations/2021_09_23_100629_add_currencies.php @@ -23,6 +23,19 @@ class AddCurrencies extends Migration */ public function down() { - // + + $currencies = [ + ['id' => 105, 'name' => 'Ethiopian Birr', 'code' => 'ETB', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + + ]; + } } + + +// Gambia Dalasi (GMD) +// Paraguayan Guarani (PYG) +// Malawi Kwacha (MWK) +// Zimbabwean Dollar (ZWL) +// Cambodian Riel (KHR) +// Vanuatu Vatu (VUV) \ No newline at end of file From 9330f51a864b325793dc99cf19084e7caa45b935 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 21:01:26 +1000 Subject: [PATCH 46/50] Include invoices with payment webhooks --- app/Observers/PaymentObserver.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Observers/PaymentObserver.php b/app/Observers/PaymentObserver.php index bacff53c5a89..976d261c3e1c 100644 --- a/app/Observers/PaymentObserver.php +++ b/app/Observers/PaymentObserver.php @@ -29,6 +29,9 @@ class PaymentObserver ->where('event_id', Webhook::EVENT_CREATE_PAYMENT) ->exists(); + if($payment->invoices()->exists()) + $payment->load('invoices'); + if ($subscriptions) { WebhookHandler::dispatch(Webhook::EVENT_CREATE_PAYMENT, $payment, $payment->company); } From 026d3e17a78419341482b7e69cf06eb86223b363 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 22:07:07 +1000 Subject: [PATCH 47/50] Additional currencieS --- app/Utils/HtmlEngine.php | 3 + .../2021_09_23_100629_add_currencies.php | 51 +++++++++----- tests/Unit/RelationExistsTest.php | 68 +++++++++++++++++++ 3 files changed, 106 insertions(+), 16 deletions(-) create mode 100644 tests/Unit/RelationExistsTest.php diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php index bf619dcd6eb6..5d51676271a8 100644 --- a/app/Utils/HtmlEngine.php +++ b/app/Utils/HtmlEngine.php @@ -232,6 +232,9 @@ class HtmlEngine $data['$user.name'] = ['value' => $this->entity->user->present()->name(), 'label' => ctrans('texts.name')]; $data['$user.first_name'] = ['value' => $this->entity->user->first_name, 'label' => ctrans('texts.first_name')]; $data['$user.last_name'] = ['value' => $this->entity->user->last_name, 'label' => ctrans('texts.last_name')]; + $data['$created_by_user'] = &$data['$user.name']; + $data['$assigned_to_user'] = ['value' => $this->entity->assigned_user ? $this->entity->assigned_user->present()->name() : '', 'label' => ctrans('texts.name')]; + $data['$user_iban'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company1', $this->settings->custom_value1, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'company1')]; $data['$invoice.custom1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice1', $this->entity->custom_value1, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'invoice1')]; $data['$invoice.custom2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice2', $this->entity->custom_value2, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'invoice2')]; diff --git a/database/migrations/2021_09_23_100629_add_currencies.php b/database/migrations/2021_09_23_100629_add_currencies.php index 9cb74a1af2e6..dd6187e4bab4 100644 --- a/database/migrations/2021_09_23_100629_add_currencies.php +++ b/database/migrations/2021_09_23_100629_add_currencies.php @@ -1,8 +1,10 @@ 105, 'name' => 'Gambia Dalasi', 'code' => 'GMD', 'symbol' => 'D', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], +['id' => 106, 'name' => 'Paraguayan Guarani', 'code' => 'PYG', 'symbol' => '₲', 'precision' => '0', 'thousand_separator' => ',', 'decimal_separator' => '.'], +['id' => 107, 'name' => 'Malawi Kwacha','code' => 'MWK', 'symbol' => 'MK', 'precision' => '2','thousand_separator' => ',', 'decimal_separator' => '.'], +['id' => 108, 'name' => 'Zimbabwean Dollar', 'code' => 'ZWL', 'symbol' => 'Z$', 'precision' => '0', 'thousand_separator' => ',', 'decimal_separator' => '.'], +['id' => 109, 'name' => 'Cambodian Riel', 'code' => 'KHR', 'symbol' => '៛', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], +['id' => 110, 'name' => 'Vanuatu Vatu','code' => 'VUV', 'symbol' => 'VT', 'precision' => '0','thousand_separator' => ',','decimal_separator' => '.'], + + ]; + + foreach ($currencies as $currency) { + $record = Currency::whereCode($currency['code'])->first(); + if ($record) { + $record->name = $currency['name']; + $record->symbol = $currency['symbol']; + $record->precision = $currency['precision']; + $record->thousand_separator = $currency['thousand_separator']; + $record->decimal_separator = $currency['decimal_separator']; + if (isset($currency['swap_currency_symbol'])) { + $record->swap_currency_symbol = $currency['swap_currency_symbol']; + } + $record->save(); + } else { + Currency::create($currency); + } + } + + + } + /** * Reverse the migrations. * @@ -23,19 +56,5 @@ class AddCurrencies extends Migration */ public function down() { - - $currencies = [ - ['id' => 105, 'name' => 'Ethiopian Birr', 'code' => 'ETB', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - - ]; - } } - - -// Gambia Dalasi (GMD) -// Paraguayan Guarani (PYG) -// Malawi Kwacha (MWK) -// Zimbabwean Dollar (ZWL) -// Cambodian Riel (KHR) -// Vanuatu Vatu (VUV) \ No newline at end of file diff --git a/tests/Unit/RelationExistsTest.php b/tests/Unit/RelationExistsTest.php new file mode 100644 index 000000000000..0ce61b8801bb --- /dev/null +++ b/tests/Unit/RelationExistsTest.php @@ -0,0 +1,68 @@ +makeTestData(); + } + + public function testAssignedUserRelationExists() + { + + foreach($this->models as $model){ + + $class = new $model; + + $this->assertTrue(method_exists($class, 'assigned_user')); + } + } +} From cde5363c9748cfbe3139f4c6fbb19596c742cf68 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Sep 2021 22:12:31 +1000 Subject: [PATCH 48/50] Fixes for client portal login --- resources/views/portal/ninja2020/auth/login.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/portal/ninja2020/auth/login.blade.php b/resources/views/portal/ninja2020/auth/login.blade.php index c8674eeb83a1..4dbeae512db3 100644 --- a/resources/views/portal/ninja2020/auth/login.blade.php +++ b/resources/views/portal/ninja2020/auth/login.blade.php @@ -77,7 +77,7 @@ @endif - @if(!empty($company->present()->website())) + @if(!is_null($company) && !empty($company->present()->website()))
{{ ctrans('texts.back_to', ['url' => parse_url($company->present()->website())['host'] ?? $company->present()->website() ]) }} From 19d4895a6403a72f41d7e94399dde23e8e1e1d55 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 24 Sep 2021 07:18:51 +1000 Subject: [PATCH 49/50] Allow public notes to convert from quote to invoices --- app/Factory/CloneQuoteToInvoiceFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Factory/CloneQuoteToInvoiceFactory.php b/app/Factory/CloneQuoteToInvoiceFactory.php index 086b6db742c5..b04b8104253d 100644 --- a/app/Factory/CloneQuoteToInvoiceFactory.php +++ b/app/Factory/CloneQuoteToInvoiceFactory.php @@ -29,7 +29,7 @@ class CloneQuoteToInvoiceFactory unset($quote_array['id']); unset($quote_array['invitations']); unset($quote_array['terms']); - unset($quote_array['public_notes']); + // unset($quote_array['public_notes']); unset($quote_array['footer']); unset($quote_array['design_id']); From 9e0bcffd6ec25dfcbbae4f437a1ffe8e41d9bc21 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 24 Sep 2021 08:50:50 +1000 Subject: [PATCH 50/50] Ensure we translate --- app/Http/Controllers/SubdomainController.php | 1 + app/Jobs/Import/CSVImport.php | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/app/Http/Controllers/SubdomainController.php b/app/Http/Controllers/SubdomainController.php index 20334c32c111..6a25f795608d 100644 --- a/app/Http/Controllers/SubdomainController.php +++ b/app/Http/Controllers/SubdomainController.php @@ -29,6 +29,7 @@ class SubdomainController extends BaseController 'preview', 'invoiceninja', 'cname', + 'sandbox', ]; public function __construct() diff --git a/app/Jobs/Import/CSVImport.php b/app/Jobs/Import/CSVImport.php index dd6d22392cc6..b5896b53203b 100644 --- a/app/Jobs/Import/CSVImport.php +++ b/app/Jobs/Import/CSVImport.php @@ -38,6 +38,7 @@ use App\Repositories\BaseRepository; use App\Repositories\ClientRepository; use App\Repositories\InvoiceRepository; use App\Repositories\PaymentRepository; +use App\Utils\Ninja; use App\Utils\Traits\CleanLineItems; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; @@ -52,6 +53,7 @@ use League\Csv\Reader; use League\Csv\Statement; use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\Request; +use Illuminate\Support\Facades\App; class CSVImport implements ShouldQueue { @@ -132,6 +134,10 @@ class CSVImport implements ShouldQueue { 'company' => $this->company, ]; + App::forgetInstance('translator'); + $t = app('translator'); + $t->replace(Ninja::transformTranslations($this->company->settings)); + $nmo = new NinjaMailerObject; $nmo->mailable = new ImportCompleted($this->company, $data); $nmo->company = $this->company;