From 19c7a366a64df3f66645e148bffebfbc527ffbaa Mon Sep 17 00:00:00 2001 From: sriramv Date: Tue, 6 Jun 2023 18:10:41 +0530 Subject: [PATCH 1/3] gwm:multipleAddress --- app/Controllers/PaymentController.php | 8 +++++--- app/Views/checkout.php | 4 ++-- app/Views/payment.php | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/Controllers/PaymentController.php b/app/Controllers/PaymentController.php index e5f7498..340d456 100644 --- a/app/Controllers/PaymentController.php +++ b/app/Controllers/PaymentController.php @@ -135,7 +135,7 @@ class PaymentController extends BaseController $amount = $amount + $cost; - $item_count = $item_count + $single_pack_no_of_count; + $item_count = $item_count + $CartData[$i]['count']; } $data['amount'] = $amount; @@ -276,8 +276,9 @@ class PaymentController extends BaseController $memberCredits = $this->creditsModel->where('order_id', $local_order_id ) ->where('member_id', session()->get('logged_user')) ->select('package_name') + ->select('cost') ->selectSum('credit_points', 'credit_points') - ->selectSum('cost', 'cost') + ->selectSum('cost', 'costSum') ->selectCount('package_name', 'pack_count') ->groupBy('package_name')->findAll(); @@ -291,7 +292,7 @@ class PaymentController extends BaseController $Subtotal = 0; foreach ($memberCredits as $key => $ele) { - $Subtotal = $Subtotal + $ele['cost']; + $Subtotal = $Subtotal + $ele['costSum']; } $data['memberCredits'] =$memberCredits; @@ -306,6 +307,7 @@ class PaymentController extends BaseController // echo '
';
                 // print_r(  $data['memberCredits']);
                 // echo '
'; + // die(); diff --git a/app/Views/checkout.php b/app/Views/checkout.php index 247cee2..1850af3 100644 --- a/app/Views/checkout.php +++ b/app/Views/checkout.php @@ -196,8 +196,8 @@ $web_payment_sdk_url = $_ENV["ENVIRONMENT"] === Environment::PRODUCTION ? "https
-
-
$
+
+
$
diff --git a/app/Views/payment.php b/app/Views/payment.php index e4d6a5f..4f6e1c0 100644 --- a/app/Views/payment.php +++ b/app/Views/payment.php @@ -64,7 +64,7 @@ /assets/member_images/cart-icon.png" alt="" width="70" height="70">
-
+
Credits
@@ -74,7 +74,7 @@
-
$
+
$
From 5a28c9cec3e413f6b733e62d850842fdebe7e1eb Mon Sep 17 00:00:00 2001 From: sriramv Date: Wed, 7 Jun 2023 09:48:42 +0530 Subject: [PATCH 2/3] payment_failed:GWM --- app/Config/Routes.php | 1 + app/Controllers/PaymentController.php | 75 +++++++++++++++++------ app/Models/Member_model.php | 2 +- app/Models/transaction_model.php | 2 +- app/Views/checkout.php | 86 +++++++++++++++++---------- app/Views/payment_failed.php | 77 ++++++++++++++++++++++++ 6 files changed, 193 insertions(+), 50 deletions(-) create mode 100644 app/Views/payment_failed.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index bff79ee..38b9d78 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -54,6 +54,7 @@ $routes->match(['get'],'/scheduler','Member_controller::scheduler'); $routes->get('/payment', 'PaymentController::index'); $routes->get('/payment_success/(:any)', 'PaymentController::payment_success/$1'); +$routes->get('/payment_failed/(:any)', 'PaymentController::payment_failed/$1'); $routes->post('/payment/(:any)', 'PaymentController::index/$1'); $routes->get('payment_form', 'PaymentController::payment_form'); $routes->post('processPayment', 'PaymentController::processPayment'); diff --git a/app/Controllers/PaymentController.php b/app/Controllers/PaymentController.php index 7be0031..7ceec71 100644 --- a/app/Controllers/PaymentController.php +++ b/app/Controllers/PaymentController.php @@ -144,9 +144,8 @@ class PaymentController extends BaseController $data['gst'] = $gst; $data['pst'] = $pst; $data['packageArray'] = $packageArray; - $data['userdata']=$this->dModel->getLoggedInMemberData(session()->get('logged_user')); - $data['userDefaultAddress'] = $this->MemberModel->getDefaultAddress(session()->get('logged_user')); - $data['userAddress'] = $this->MemberAddressModel->where('member_id',session()->get('logged_user'))->findAll(); + $data['userdata'] = $this->MemberModel->where('id',session()->get('logged_user'))->find(); + //$data['userAddress'] = $this->MemberAddressModel->where('member_id',session()->get('logged_user'))->findAll(); // echo '
';
                 //  print_r($data);
                 //  echo '
'; @@ -180,7 +179,11 @@ class PaymentController extends BaseController $idempotencyKey = $data->idempotencyKey; $amount = $data->amount; $order_id = $data->order_id; - $address_id = $data->address_id; + $add = $data->address; + parse_str( $add, $address); + + //print_r($add);die(); + $Final_amount = round( ( $amount + (($amount * ($gst + $pst) ) / 100) ) , 2 ); $square_client = new SquareClient([ @@ -219,13 +222,17 @@ class PaymentController extends BaseController $data = json_encode($response->getResult()); $result = json_decode( $data ,true); - - $TrancactionId = $result['payment']['id']; - $payment_order_id = $result['payment']['order_id']; + //Trancaction Table Data + $TrancactionData['status'] = 'success'; $TrancactionData['member_id'] = session()->get('logged_user'); - $TrancactionData['address_id'] = $address_id; - $TrancactionData['transaction_id'] = $TrancactionId; - $TrancactionData['payment_order_id'] = $payment_order_id; + $TrancactionData['first_name'] = $address['name']; + $TrancactionData['last_name'] = $address['last_name']; + $TrancactionData['address'] = $address['address']; + $TrancactionData['state'] = $address['state']; + $TrancactionData['city'] = $address['city']; + $TrancactionData['zip_code'] = $address['pincode']; + $TrancactionData['transaction_id'] = $result['payment']['id']; + $TrancactionData['payment_order_id'] = $result['payment']['order_id']; $TrancactionData['order_id'] = $order_id; $TrancactionData['transaction'] = json_encode($response->getResult()); $insert = $this->TransactionModel->save($TrancactionData); @@ -240,7 +247,27 @@ class PaymentController extends BaseController } else { - echo json_encode(array('errors' => $response->getErrors())); + $data = json_encode($response->getErrors()); + $result = json_decode( $data ,true); + //Trancaction Table Data + $TrancactionData['status'] = 'failed'; + $TrancactionData['member_id'] = session()->get('logged_user'); + $TrancactionData['first_name'] = $address['name']; + $TrancactionData['last_name'] = $address['last_name']; + $TrancactionData['address'] = $address['address']; + $TrancactionData['state'] = $address['state']; + $TrancactionData['city'] = $address['city']; + $TrancactionData['zip_code'] = $address['pincode']; + $TrancactionData['order_id'] = $order_id; + $TrancactionData['transaction'] = json_encode($response->getErrors()); + $insert = $this->TransactionModel->save($TrancactionData); + if( $insert) + { + + $this->creditsModel->where('order_id', $order_id )->delete(); + } + + echo json_encode(array('errors' => $response->getErrors())); } } catch (ApiException $e) { echo json_encode(array('errors' => $e)); @@ -308,21 +335,35 @@ class PaymentController extends BaseController // print_r( $data['memberCredits']); // echo ''; // die(); - - - echo view('payment',$data); }else{ echo 'invalid order_id'; } - } - - } + public function payment_failed( $local_order_id = null) + { + if( $local_order_id != null) + { + $data['TransactionData'] = $this->TransactionModel->where('order_id', $local_order_id )->where('member_id', session()->get('logged_user'))->find(); + if($data['TransactionData']){ + + $data['category'] = json_decode($data['TransactionData'][0]['transaction'] , true)[0]['category']; + $data['code'] = json_decode($data['TransactionData'][0]['transaction'] , true)[0]['code']; + $data['detail'] = json_decode($data['TransactionData'][0]['transaction'] , true)[0]['detail']; + $data['order_id'] = $data['TransactionData'][0]['order_id']; + $timestamp = strtotime($data['TransactionData'][0]['created_at']); + $data['formattedDate'] = date('l, F j, Y', $timestamp); + + echo view('payment_failed',$data); + }else{ + echo 'invalid order_id'; + } + } + } diff --git a/app/Models/Member_model.php b/app/Models/Member_model.php index 146b746..c0a1521 100644 --- a/app/Models/Member_model.php +++ b/app/Models/Member_model.php @@ -7,7 +7,7 @@ class Member_model extends Model protected $table = 'member'; protected $primaryKey = 'id'; - protected $allowedFields = ['name', 'mobile','email','username', 'password', 'address' , 'city' , 'state' , 'country' , 'pincode' , 'is_email_verified' , 'verification_code' , 'is_active' , 'created_by','updated_by']; + protected $allowedFields = ['name', 'last_name' , 'mobile','email','username', 'password', 'address' , 'city' , 'state' , 'country' , 'pincode' , 'is_email_verified' , 'verification_code' , 'is_active' , 'created_by','updated_by']; protected $beforeInsert = ['beforeInsert']; protected $beforeUpdate = ['beforeUpdate']; diff --git a/app/Models/transaction_model.php b/app/Models/transaction_model.php index 4e38478..9c1c3ec 100644 --- a/app/Models/transaction_model.php +++ b/app/Models/transaction_model.php @@ -7,7 +7,7 @@ class transaction_model extends Model protected $table = 'transactions'; protected $primaryKey = 'id'; - protected $allowedFields = ['member_id','address_id','transaction_id','payment_order_id','order_id','transaction','is_mail_triggered']; + protected $allowedFields = ['status','member_id','transaction_id','payment_order_id','order_id','transaction','is_mail_triggered', 'first_name','last_name','address', 'city' , 'state' , 'zip_code']; } \ No newline at end of file diff --git a/app/Views/checkout.php b/app/Views/checkout.php index 1850af3..6801011 100644 --- a/app/Views/checkout.php +++ b/app/Views/checkout.php @@ -112,7 +112,7 @@ $web_payment_sdk_url = $_ENV["ENVIRONMENT"] === Environment::PRODUCTION ? "https @@ -122,33 +122,57 @@ $web_payment_sdk_url = $_ENV["ENVIRONMENT"] === Environment::PRODUCTION ? "https
-
- -
-
- - " name="member_address" value="" class="select-address checked" checked> - - " name="member_address" value="" class="select-address" > - - -
-
-
- + + + +
+
+
+
+ +
+ +
+ + +
+
+ + +
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
-
-
- Edit -
- + +
- -
- +
@@ -173,17 +197,17 @@ $web_payment_sdk_url = $_ENV["ENVIRONMENT"] === Environment::PRODUCTION ? "https
-
+ +
-
+
-->
@@ -236,9 +260,9 @@ $web_payment_sdk_url = $_ENV["ENVIRONMENT"] === Environment::PRODUCTION ? "https - + diff --git a/app/Views/payment_failed.php b/app/Views/payment_failed.php new file mode 100644 index 0000000..a5c951a --- /dev/null +++ b/app/Views/payment_failed.php @@ -0,0 +1,77 @@ + + + + Payment Failed - Golf Evolution + + + + /assets/member_images/favicon.png" sizes="192x192" /> + /assets/member_images/favicon.png" /> + + + + /assets/member_css/front-style.css"> + + + + + + + + + +
+
+
+
+
+
+
+
+
+ /assets/member_images/failed_Icon.png" alt="" width="60" height="60"/> +

Payment Failed!

+ +
+
+
+ +
+
+
+
Order Id
+
+
+
+
Transactions Date
+
+
+
+
Payment Failed Details
+
+
+
+
+ + + + + +
+
+ +
+
+
+
+
+
+
+
+ + + + + \ No newline at end of file From 936738055bd0d561a150b49ea1a4ca71fb0d0660 Mon Sep 17 00:00:00 2001 From: sriramv Date: Wed, 7 Jun 2023 11:35:21 +0530 Subject: [PATCH 3/3] gwm --- app/Controllers/Member_controller.php | 4 +++- app/Models/Member_model.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Controllers/Member_controller.php b/app/Controllers/Member_controller.php index afd57fd..6454a26 100644 --- a/app/Controllers/Member_controller.php +++ b/app/Controllers/Member_controller.php @@ -539,8 +539,10 @@ class Member_controller extends BaseController } + + - + // ----------------------------------------------- } diff --git a/app/Models/Member_model.php b/app/Models/Member_model.php index c0a1521..b988430 100644 --- a/app/Models/Member_model.php +++ b/app/Models/Member_model.php @@ -7,7 +7,7 @@ class Member_model extends Model protected $table = 'member'; protected $primaryKey = 'id'; - protected $allowedFields = ['name', 'last_name' , 'mobile','email','username', 'password', 'address' , 'city' , 'state' , 'country' , 'pincode' , 'is_email_verified' , 'verification_code' , 'is_active' , 'created_by','updated_by']; + protected $allowedFields = ['name', 'last_name' ,'gender', 'mobile','email','username', 'password', 'address' , 'city' , 'state' , 'country' , 'pincode' , 'is_email_verified' , 'verification_code' , 'is_active' , 'created_by','updated_by']; protected $beforeInsert = ['beforeInsert']; protected $beforeUpdate = ['beforeUpdate'];