From b2ab44d60f7e01ed4c9713db34beca6d672302c9 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 6 Oct 2022 08:16:43 +0200 Subject: [PATCH 1/7] Use blade as html verification template for Fawry Payment Gateway --- resources/views/html/fawry.blade.php | 27 ++++++++++++++++++++++++++ src/Classes/FawryPayment.php | 26 +------------------------ src/NafezlyPaymentsServiceProvider.php | 5 ++++- 3 files changed, 32 insertions(+), 26 deletions(-) create mode 100644 resources/views/html/fawry.blade.php diff --git a/resources/views/html/fawry.blade.php b/resources/views/html/fawry.blade.php new file mode 100644 index 0000000..8fabd36 --- /dev/null +++ b/resources/views/html/fawry.blade.php @@ -0,0 +1,27 @@ + + + \ No newline at end of file diff --git a/src/Classes/FawryPayment.php b/src/Classes/FawryPayment.php index 22a1e14..b6a2062 100644 --- a/src/Classes/FawryPayment.php +++ b/src/Classes/FawryPayment.php @@ -102,31 +102,7 @@ public function verify(Request $request) private function generate_html($data): string { - return ""; + return view('nafezly::html.fawry', ['data' => $data, 'verify_route_name' => $this->verify_route_name]); } } \ No newline at end of file diff --git a/src/NafezlyPaymentsServiceProvider.php b/src/NafezlyPaymentsServiceProvider.php index da0288a..a749f85 100644 --- a/src/NafezlyPaymentsServiceProvider.php +++ b/src/NafezlyPaymentsServiceProvider.php @@ -25,7 +25,10 @@ public function boot() { $this->configure(); $this->registerPublishing(); - + $this->loadViewsFrom(__DIR__.'/../resources/views', 'nafezly'); + $this->publishes([ + __DIR__.'/../resources/views' => resource_path('views/vendor/nafezly'), + ]); } /** From a6d3f904099add34f860cb47dfb58edaad741b53 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 6 Oct 2022 10:27:15 +0200 Subject: [PATCH 2/7] Change variables accessibility from private to public --- src/Traits/SetVariables.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Traits/SetVariables.php b/src/Traits/SetVariables.php index 672b89a..cb2991c 100644 --- a/src/Traits/SetVariables.php +++ b/src/Traits/SetVariables.php @@ -3,14 +3,14 @@ trait SetVariables { - private $user_id = null; - private $user_first_name = null; - private $user_last_name = null; - private $user_email = null; - private $user_phone = null; - private $source = null; - private $currency = null; - private $amount = null; + public $user_id = null; + public $user_first_name = null; + public $user_last_name = null; + public $user_email = null; + public $user_phone = null; + public $source = null; + public $currency = null; + public $amount = null; /** * Sets user ID From a5c37fcd4aa728694fcd4f436ab1f0e6eef50da7 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 6 Oct 2022 12:45:52 +0200 Subject: [PATCH 3/7] Use blade as html verification template for HyperPay Payment Gateway --- resources/views/html/hyper_pay.blade.php | 44 +++++++++++++ src/Classes/HyperPayPayment.php | 82 +++++++----------------- 2 files changed, 66 insertions(+), 60 deletions(-) create mode 100644 resources/views/html/hyper_pay.blade.php diff --git a/resources/views/html/hyper_pay.blade.php b/resources/views/html/hyper_pay.blade.php new file mode 100644 index 0000000..352d39e --- /dev/null +++ b/resources/views/html/hyper_pay.blade.php @@ -0,0 +1,44 @@ +
+ + \ No newline at end of file diff --git a/src/Classes/HyperPayPayment.php b/src/Classes/HyperPayPayment.php index 635de4a..d3b4c15 100644 --- a/src/Classes/HyperPayPayment.php +++ b/src/Classes/HyperPayPayment.php @@ -12,13 +12,14 @@ class HyperPayPayment { use SetVariables, SetRequiredFields; private $hyperpay_url; - private $hyperpay_base_url; + public $hyperpay_base_url; private $hyperpay_token; private $hyperpay_credit_id; private $hyperpay_mada_id; private $hyperpay_apple_id; - private $app_name; - private $verify_route_name; + public $app_name; + public $verify_route_name; + public $payment_id; public function __construct() { @@ -50,7 +51,7 @@ public function pay($amount = null, $user_id = null, $user_first_name = null, $u $this->checkRequiredFields($required_fields, 'HYPERPAY', func_get_args()); $data = http_build_query([ - 'entityId' => $this->getEntityId($source), + 'entityId' => $this->getEntityId($this->source), 'amount' => $this->amount, 'currency' => $this->currency, 'paymentType' => 'DB', @@ -79,11 +80,11 @@ public function pay($amount = null, $user_id = null, $user_first_name = null, $u return curl_error($ch); } curl_close($ch); - $payment_id = json_decode($responseData)->id; - Cache::forever($payment_id . '_source', $source); + $this->payment_id = json_decode($responseData)->id; + Cache::forever($this->payment_id . '_source', $this->source); return [ - 'payment_id' => $payment_id, - 'html' => $this->generate_html($source, $amount, $payment_id), + 'payment_id' => $this->payment_id, + 'html' => $this->generate_html(), 'redirect_url'=>"" ]; } @@ -130,59 +131,9 @@ public function verify(Request $request) } } - private function generate_html($source, $amount, $payment_id): string + public function generate_html(): string { - - $form_brands = "VISA MASTER"; - if ($source == "MADA") - $form_brands = "MADA"; - elseif ($source == "APPLE") - $form_brands = "APPLEPAY"; - - return "
'hyperpay']) . "' class='paymentWidgets' data-brands='" . $form_brands . "'>
- - "; + return view('nafezly::html.hyper_pay', ['model' => $this, 'brand' => $this->getBrand()])->render(); } private function getEntityId($source) @@ -199,6 +150,17 @@ private function getEntityId($source) return ""; } } + + private function getBrand() + { + $form_brands = "VISA MASTER"; + if ($this->source == "MADA"){ + $form_brands = "MADA"; + }elseif ($this->source == "APPLE"){ + $form_brands = "APPLEPAY"; + } + return $form_brands; + } } From bad940e608078f3fb7554edd965b6695f6079906 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 6 Oct 2022 12:46:09 +0200 Subject: [PATCH 4/7] Use blade as html verification template for Kashier Payment Gateway --- resources/views/html/kashier.blade.php | 16 ++++++++++++++++ src/Classes/KashierPayment.php | 24 ++++++------------------ 2 files changed, 22 insertions(+), 18 deletions(-) create mode 100644 resources/views/html/kashier.blade.php diff --git a/resources/views/html/kashier.blade.php b/resources/views/html/kashier.blade.php new file mode 100644 index 0000000..32082be --- /dev/null +++ b/resources/views/html/kashier.blade.php @@ -0,0 +1,16 @@ + + + \ No newline at end of file diff --git a/src/Classes/KashierPayment.php b/src/Classes/KashierPayment.php index d5f26f5..b848aae 100644 --- a/src/Classes/KashierPayment.php +++ b/src/Classes/KashierPayment.php @@ -11,11 +11,11 @@ class KashierPayment implements PaymentInterface { use SetVariables, SetRequiredFields; - private $kashier_url; - private $kashier_mode; + public $kashier_url; + public $kashier_mode; private $kashier_account_key; private $kashier_iframe_key; - private $app_name; + public $app_name; private $verify_route_name; public function __construct() @@ -66,7 +66,7 @@ public function pay($amount = null, $user_id = null, $user_first_name = null, $u return [ 'payment_id' => $payment_id, - 'html' => $this->generate_html($amount, $data), + 'html' => $this->generate_html($data), 'redirect_url'=>"" ]; @@ -120,21 +120,9 @@ public function verify(Request $request): array * @param $data * @return string */ - private function generate_html($amount, $data): string + private function generate_html($data): string { - return ''; + return view('nafezly::html.kashier', ['model' => $this, 'data' => $data])->render(); } } \ No newline at end of file From 289704ae09ddb9c0e2eb4f70e7a13df999f09237 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 6 Oct 2022 12:46:41 +0200 Subject: [PATCH 5/7] Update: Use blade as html verification template for Fawry Payment Gateway --- resources/views/html/fawry.blade.php | 2 +- src/Classes/FawryPayment.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/views/html/fawry.blade.php b/resources/views/html/fawry.blade.php index 8fabd36..2b69386 100644 --- a/resources/views/html/fawry.blade.php +++ b/resources/views/html/fawry.blade.php @@ -22,6 +22,6 @@ chargeRequest.order.orderItems.push(item); chargeRequest.signature = "{{ $data['secret'] }}"; setTimeout(function(){ - FawryPay.checkout(chargeRequest,'{{ route($verify_route_name, ["payment" => "fawry"]) }}', '{{ route($verify_route_name, ["payment" => "fawry"]) }}'); + FawryPay.checkout(chargeRequest,'{{ route($this->verify_route_name, ["payment" => "fawry"]) }}', '{{ route($this->verify_route_name, ["payment" => "fawry"]) }}'); },100); \ No newline at end of file diff --git a/src/Classes/FawryPayment.php b/src/Classes/FawryPayment.php index b6a2062..a6941db 100644 --- a/src/Classes/FawryPayment.php +++ b/src/Classes/FawryPayment.php @@ -12,10 +12,10 @@ class FawryPayment implements PaymentInterface { use SetVariables, SetRequiredFields; - private $fawry_url; - private $fawry_secret; - private $fawry_merchant; - private $verify_route_name; + public $fawry_url; + public $fawry_secret; + public $fawry_merchant; + public $verify_route_name; public function __construct() { @@ -102,7 +102,7 @@ public function verify(Request $request) private function generate_html($data): string { - return view('nafezly::html.fawry', ['data' => $data, 'verify_route_name' => $this->verify_route_name]); + return view('nafezly::html.fawry', ['model' => $this, 'data' => $data])->render(); } } \ No newline at end of file From 4e88c6a46dc6be166c5b46509bc92d64337ba25c Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 6 Oct 2022 12:49:42 +0200 Subject: [PATCH 6/7] Update FawryPayment.php --- src/Classes/FawryPayment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Classes/FawryPayment.php b/src/Classes/FawryPayment.php index a6941db..b332afd 100644 --- a/src/Classes/FawryPayment.php +++ b/src/Classes/FawryPayment.php @@ -55,7 +55,7 @@ public function pay($amount = null, $user_id = null, $user_first_name = null, $u 'unique_id' => $unique_id, 'item_id' => 1, 'item_quantity' => 1, - 'amount' => $amount, + 'amount' => $this->amount, 'payment_id'=>$unique_id ]; From ae16c55515be8d02069cfec65fb4e690e9c647b7 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 6 Oct 2022 13:16:38 +0200 Subject: [PATCH 7/7] Update fawry.blade.php --- resources/views/html/fawry.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/html/fawry.blade.php b/resources/views/html/fawry.blade.php index 2b69386..f50a151 100644 --- a/resources/views/html/fawry.blade.php +++ b/resources/views/html/fawry.blade.php @@ -22,6 +22,6 @@ chargeRequest.order.orderItems.push(item); chargeRequest.signature = "{{ $data['secret'] }}"; setTimeout(function(){ - FawryPay.checkout(chargeRequest,'{{ route($this->verify_route_name, ["payment" => "fawry"]) }}', '{{ route($this->verify_route_name, ["payment" => "fawry"]) }}'); + FawryPay.checkout(chargeRequest,'{{ route($model->verify_route_name, ["payment" => "fawry"]) }}', '{{ route($model->verify_route_name, ["payment" => "fawry"]) }}'); },100); \ No newline at end of file