From 19c7a366a64df3f66645e148bffebfbc527ffbaa Mon Sep 17 00:00:00 2001
From: sriramv ';
// 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
/assets/member_images/cart-icon.png" alt="" width="70" height="70">
';
// 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
Billing Address
+
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 @@ + + +
+
+ + + + /assets/member_images/favicon.png" sizes="192x192" /> + /assets/member_images/favicon.png" /> + + + + /assets/member_css/front-style.css"> + + + + + +
+