suseendhiran
This commit is contained in:
parent
898095676a
commit
f78ccd1d4a
@ -32,6 +32,7 @@ class Cart_controller extends BaseController
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$pack_data['pack_data'] = $this->credits_pack();
|
$pack_data['pack_data'] = $this->credits_pack();
|
||||||
|
$pack_data['token'] = '';
|
||||||
echo view('membership.php' , $pack_data);
|
echo view('membership.php' , $pack_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,9 @@ use App\Models\Member_credits_model;
|
|||||||
use App\Models\Packages_and_pricing_model;
|
use App\Models\Packages_and_pricing_model;
|
||||||
use App\Models\Cart_model;
|
use App\Models\Cart_model;
|
||||||
use App\Models\Credits_usage_tracking_model;
|
use App\Models\Credits_usage_tracking_model;
|
||||||
|
use Config\Services;
|
||||||
|
use App\Libraries\SquareService;
|
||||||
|
use App\Models\Cart_token_model;
|
||||||
|
|
||||||
class Member_controller extends BaseController
|
class Member_controller extends BaseController
|
||||||
{
|
{
|
||||||
@ -26,9 +28,10 @@ class Member_controller extends BaseController
|
|||||||
$this->PackagesModel = new Packages_and_pricing_model();
|
$this->PackagesModel = new Packages_and_pricing_model();
|
||||||
$this->cartModel = new Cart_model();
|
$this->cartModel = new Cart_model();
|
||||||
$this->CreditsUsageTrackingModel = new Credits_usage_tracking_model();
|
$this->CreditsUsageTrackingModel = new Credits_usage_tracking_model();
|
||||||
|
$this->Cart_token_model = new Cart_token_model();
|
||||||
helper('form');
|
helper('form');
|
||||||
}
|
}
|
||||||
public function index($token = null)
|
public function index()
|
||||||
{
|
{
|
||||||
$data=[];
|
$data=[];
|
||||||
|
|
||||||
@ -48,11 +51,30 @@ class Member_controller extends BaseController
|
|||||||
|
|
||||||
if (password_verify($password, $memberdata['password']))
|
if (password_verify($password, $memberdata['password']))
|
||||||
{
|
{
|
||||||
|
$token = $this->session->get("token");
|
||||||
$this->session->set('logged_user',$memberdata['id']);
|
$this->session->set('logged_user',$memberdata['id']);
|
||||||
// insetr data in cart table and then delete dummy in token table
|
if ($token)
|
||||||
|
{
|
||||||
|
$tokendata = $this->Cart_token_model->where('md5(token)', $token )->findAll();
|
||||||
|
foreach ($tokendata as $value)
|
||||||
|
{
|
||||||
|
$data['member_id'] = $memberdata['id'];
|
||||||
|
$data['pack_id'] = $value['primary_id'];
|
||||||
|
$data['count'] = $value['count'];
|
||||||
|
$successdata = $this->cartModel->save($data);
|
||||||
|
if ($successdata)
|
||||||
|
{
|
||||||
|
$deletedata = $this->Cart_token_model->where('id', $value['id'] )->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return redirect()->to(base_url().'payment');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return redirect()->to(base_url().'member_home');
|
return redirect()->to(base_url().'member_home');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
else{
|
else{
|
||||||
$this->session->setTempdata('error','sorry wrong password entered for the Email',3);
|
$this->session->setTempdata('error','sorry wrong password entered for the Email',3);
|
||||||
return redirect()->to(base_url());
|
return redirect()->to(base_url());
|
||||||
@ -456,7 +478,63 @@ class Member_controller extends BaseController
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function processPayment()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$amount = 100; // Amount in cents
|
||||||
|
|
||||||
|
$square = new SquareService();
|
||||||
|
$response = $square->processPayment($amount);
|
||||||
|
|
||||||
|
// Handle the payment response
|
||||||
|
if ($response->isSuccess()) {
|
||||||
|
// Payment succeeded
|
||||||
|
} else {
|
||||||
|
// Payment failed
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// Handle exceptions
|
||||||
|
echo $e->getMessage();
|
||||||
|
log_message('error', 'Exception: ' . $e->getMessage());
|
||||||
|
// ...
|
||||||
|
} catch (\Error $e) {
|
||||||
|
// Handle errors
|
||||||
|
echo $e->getMessage();
|
||||||
|
log_message('error', 'Error: ' . $e->getMessage());
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function processCardPayment()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
//echo "hai"; die();
|
||||||
|
// Get the payment nonce and amount from the submitted form
|
||||||
|
$nonce = 'test';
|
||||||
|
$amount = 100;
|
||||||
|
// echo $nonce;die();
|
||||||
|
$square = new SquareService();
|
||||||
|
$response = $square->processCardPayment($nonce, $amount);
|
||||||
|
|
||||||
|
// Handle the payment response
|
||||||
|
if ($response && $response->isSuccess()) {
|
||||||
|
// Payment succeeded
|
||||||
|
} else {
|
||||||
|
// Payment failed
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// Handle exceptions
|
||||||
|
echo $e->getMessage();
|
||||||
|
log_message('error', 'Exception: ' . $e->getMessage());
|
||||||
|
// ...
|
||||||
|
} catch (\Error $e) {
|
||||||
|
// Handle errors
|
||||||
|
echo $e->getMessage();
|
||||||
|
log_message('error', 'Error: ' . $e->getMessage());
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------
|
// -----------------------------------------------
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,13 +31,19 @@ class Test_controller extends BaseController
|
|||||||
}
|
}
|
||||||
public function index($token = null)
|
public function index($token = null)
|
||||||
{
|
{
|
||||||
|
$count = $this->request->getVar('count');
|
||||||
|
foreach ($count as $key => $value)
|
||||||
|
{
|
||||||
|
$this->Cart_token_model->where('id', $this->request->getVar('cart_token_id')[$key] )->set(array( 'count' => $value ))->update();
|
||||||
|
}
|
||||||
if(!session()->has('logged_user'))
|
if(!session()->has('logged_user'))
|
||||||
{
|
{
|
||||||
return redirect()->to(base_url().$token);
|
$this->session->set('token',$token);
|
||||||
|
return redirect()->to(base_url());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
echo 'gopi';
|
echo 'gop';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@ class Cart_model extends Model
|
|||||||
protected $table = 'cart';
|
protected $table = 'cart';
|
||||||
protected $primaryKey = 'id';
|
protected $primaryKey = 'id';
|
||||||
|
|
||||||
protected $allowedFields = ['member_id','pack_id'];
|
protected $allowedFields = ['member_id','pack_id','count'];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -7,7 +7,7 @@ class Cart_token_model extends Model
|
|||||||
protected $table = 'cart_token';
|
protected $table = 'cart_token';
|
||||||
protected $primaryKey = 'id';
|
protected $primaryKey = 'id';
|
||||||
|
|
||||||
protected $allowedFields = ['primary_id','table_name','token'];
|
protected $allowedFields = ['primary_id','table_name','token','count'];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -29,6 +29,7 @@
|
|||||||
<?php foreach ($tokendata as $key => $value) { ?>
|
<?php foreach ($tokendata as $key => $value) { ?>
|
||||||
|
|
||||||
<input type ="hidden" name="pack_id[]" value="<?= $value['id'] ?>">
|
<input type ="hidden" name="pack_id[]" value="<?= $value['id'] ?>">
|
||||||
|
<input type ="hidden" name="cart_token_id[]" value="<?= $pack_id[$key]['id'] ?>">
|
||||||
|
|
||||||
<!-- List of Products -->
|
<!-- List of Products -->
|
||||||
<div class="row border-bottom pt-4 pb-4">
|
<div class="row border-bottom pt-4 pb-4">
|
||||||
@ -98,7 +99,6 @@
|
|||||||
<div class="col-3 pb-4">
|
<div class="col-3 pb-4">
|
||||||
<form class="coupon-field">
|
<form class="coupon-field">
|
||||||
<a href="<?= base_url('/continue_shopping/').md5($token); ?>" >Continue Shopping</a>
|
<a href="<?= base_url('/continue_shopping/').md5($token); ?>" >Continue Shopping</a>
|
||||||
<!-- <input type="text" placeholder="Have Coupon Code" name="coupon-code" class="coupon-input"/> -->
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-9 checkout-btn">
|
<div class="col-9 checkout-btn">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user