diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 5818a03..92a445d 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -55,6 +55,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/Member_controller.php b/app/Controllers/Member_controller.php index 2b2f9ec..96dc5cc 100644 --- a/app/Controllers/Member_controller.php +++ b/app/Controllers/Member_controller.php @@ -568,7 +568,6 @@ class Member_controller extends BaseController } echo view('memberaccess',$data); //dashboard } - // ----------------------------------------------- } diff --git a/app/Controllers/PaymentController.php b/app/Controllers/PaymentController.php index 725827e..7ceec71 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; @@ -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)); @@ -276,8 +303,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 +319,7 @@ class PaymentController extends BaseController $Subtotal = 0; foreach ($memberCredits as $key => $ele) { - $Subtotal = $Subtotal + $ele['cost']; + $Subtotal = $Subtotal + $ele['costSum']; } $data['memberCredits'] =$memberCredits; @@ -306,21 +334,36 @@ class PaymentController extends BaseController // echo '
';
                 // 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..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', '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']; 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 247cee2..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
get('logged_user')); ?>"> Back to Cart -

Billing Address

+
@@ -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
-
+ +
-
+
-->
@@ -196,8 +220,8 @@ $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.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 @@
-
$
+
$
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