FIX LOGICAL ISSUES IN PAYMENT CALLBACK PAGE
This commit is contained in:
parent
cdba8b8c82
commit
bea5fee7ff
@ -507,6 +507,20 @@ public function create_or_update_invoice_items($invoice_id)
|
|||||||
{
|
{
|
||||||
$this->save_invoice_item($invoice_id, $this->request->getPost(), (int)$this->request->getVar('product'));
|
$this->save_invoice_item($invoice_id, $this->request->getPost(), (int)$this->request->getVar('product'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function generate_membership_id($length = 6) {
|
||||||
|
$characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||||
|
$charactersLength = strlen($characters);
|
||||||
|
$randomString = '';
|
||||||
|
|
||||||
|
for ($i = 0; $i < $length; $i++) {
|
||||||
|
$randomIndex = random_int(0, $charactersLength - 1);
|
||||||
|
$randomString .= $characters[$randomIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $randomString;
|
||||||
|
}
|
||||||
|
|
||||||
public function create_or_update_subscription($invoice_id, $msg_flag_name = null)
|
public function create_or_update_subscription($invoice_id, $msg_flag_name = null)
|
||||||
{
|
{
|
||||||
$model = new InvoiceModel();
|
$model = new InvoiceModel();
|
||||||
@ -519,10 +533,10 @@ public function create_or_update_subscription($invoice_id, $msg_flag_name = null
|
|||||||
$product_id = $item['product'];
|
$product_id = $item['product'];
|
||||||
$from_sub_date = $item['from_subscription'];
|
$from_sub_date = $item['from_subscription'];
|
||||||
$to_sub_date = $item['to_subscription'];
|
$to_sub_date = $item['to_subscription'];
|
||||||
$membership_id =random_int(100000, 999999);
|
$membership_id = $this->generate_membership_id(6);
|
||||||
$result = $subModel->where('membership_id',$membership_id)->findAll();
|
$result = $subModel->where('membership_id',$membership_id)->findAll();
|
||||||
if (count($result)>0){
|
if (count($result)>0){
|
||||||
$membership_id = random_int(100000,999999);
|
$membership_id = $this->generate_membership_id(6);
|
||||||
}
|
}
|
||||||
// Prepare subscription data
|
// Prepare subscription data
|
||||||
$subscription_data = [
|
$subscription_data = [
|
||||||
@ -541,6 +555,7 @@ public function create_or_update_subscription($invoice_id, $msg_flag_name = null
|
|||||||
$model->insertSubscriptionData($subscription_data);
|
$model->insertSubscriptionData($subscription_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
## For Updating Events Details ..
|
## For Updating Events Details ..
|
||||||
public function update_number_formatting($update_events)
|
public function update_number_formatting($update_events)
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
|
use App\Models\BooksModel;
|
||||||
use App\Models\CustomerModel;
|
use App\Models\CustomerModel;
|
||||||
use App\Models\InvoiceModel;
|
use App\Models\InvoiceModel;
|
||||||
use App\Models\TransactionModel;
|
use App\Models\TransactionModel;
|
||||||
@ -22,17 +23,23 @@ class Payment extends BaseController
|
|||||||
{
|
{
|
||||||
$model = new CustomerModel();
|
$model = new CustomerModel();
|
||||||
$model2 = new SubscriptionModel();
|
$model2 = new SubscriptionModel();
|
||||||
|
$bookModel = new BooksModel();
|
||||||
|
|
||||||
if ($membership_id != null){
|
if ($membership_id != null){
|
||||||
|
|
||||||
$customer_id = $model2->select('customer_id')->where('membership_id',$membership_id)->first();
|
$customer_id = $model2->select('customer_id')->where('membership_id',$membership_id)->first();
|
||||||
$customer_details = $model->get_customer_details_by_customer_id($customer_id);
|
$customer_details = $model->get_customer_details_by_customer_id($customer_id);
|
||||||
$scheme = $model2->get_subscription_details_by_membership_id($membership_id);
|
$scheme = $model2->get_subscription_details_by_membership_id($membership_id);
|
||||||
//var_dump($customer_details);die();
|
//var_dump($customer_details);die();
|
||||||
|
$price = $bookModel->select('price')->where('book_id', 3)->first();
|
||||||
|
$amount = $price['price'];
|
||||||
|
log_message('debug','amount is '.$amount);
|
||||||
$response = [
|
$response = [
|
||||||
'customer_details' => $customer_details,
|
'customer_details' => $customer_details,
|
||||||
'scheme' => $scheme,
|
'scheme' => $scheme,
|
||||||
'membership_id' =>$membership_id,
|
'membership_id' =>$membership_id,
|
||||||
'CustomerID' =>$customer_id
|
'CustomerID' =>$customer_id,
|
||||||
|
'amount' =>$amount
|
||||||
];
|
];
|
||||||
//var_dump($response);die();
|
//var_dump($response);die();
|
||||||
return view('subscription_renewal',$response);
|
return view('subscription_renewal',$response);
|
||||||
@ -49,10 +56,13 @@ class Payment extends BaseController
|
|||||||
$customer_id = $model2->select('customer_id')->where('membership_id',$membership_id)->first();
|
$customer_id = $model2->select('customer_id')->where('membership_id',$membership_id)->first();
|
||||||
$customer_details = $model->get_customer_details_by_customer_id($customer_id);
|
$customer_details = $model->get_customer_details_by_customer_id($customer_id);
|
||||||
log_message('info','inside the method post');
|
log_message('info','inside the method post');
|
||||||
|
$price = $bookModel->select('price')->where('book_id', 3)->first();
|
||||||
|
$amount = $price['price'];
|
||||||
$response = [
|
$response = [
|
||||||
'customer_details' => $customer_details,
|
'customer_details' => $customer_details,
|
||||||
'scheme' => $scheme,
|
'scheme' => $scheme,
|
||||||
'CustomerID' =>$customer_id
|
'CustomerID' =>$customer_id,
|
||||||
|
'amount' =>$amount
|
||||||
];
|
];
|
||||||
return $this->response->setJSON($response);
|
return $this->response->setJSON($response);
|
||||||
}
|
}
|
||||||
@ -142,7 +152,7 @@ public function payment_failure(){
|
|||||||
];
|
];
|
||||||
|
|
||||||
$model4 = new TransactionModel();
|
$model4 = new TransactionModel();
|
||||||
$model4->save($paramList);
|
$model4->insert($paramList);
|
||||||
|
|
||||||
return view('/payment_failure');
|
return view('/payment_failure');
|
||||||
}
|
}
|
||||||
@ -216,31 +226,18 @@ public function payment_success() {
|
|||||||
|
|
||||||
$db->table('invoiceitems')->insert($requestData);
|
$db->table('invoiceitems')->insert($requestData);
|
||||||
$model3 = new SubscriptionModel();
|
$model3 = new SubscriptionModel();
|
||||||
$id_exist = $model3->where('customer_id',$customer_id)->first();
|
$subscriptionData = [
|
||||||
if (count($id_exist)>0){
|
'scheme_id' =>3,
|
||||||
$subscriptionData = [
|
'customer_id' => $customer_id,
|
||||||
'scheme_id' =>3,
|
'invoice_id' => $invoice_id,
|
||||||
'customer_id' => $customer_id,
|
'from_subscription'=>$fsubscription,
|
||||||
'invoice_id' => $invoice_id,
|
'to_subscription'=>$tsubscription,
|
||||||
'from_subscription'=>$fsubscription,
|
'is_renew' => 1,
|
||||||
'to_subscription'=>$tsubscription,
|
'business_id'=>2,
|
||||||
'is_renew' => 1,
|
'status' =>1
|
||||||
'business_id'=>2
|
];
|
||||||
|
|
||||||
];
|
|
||||||
$db->table('subscription')->where('customer_id', $customer_id)->update($subscriptionData);
|
|
||||||
}else{
|
|
||||||
$subscriptionData = [
|
|
||||||
'scheme_id' =>3,
|
|
||||||
'customer_id' => $customer_id,
|
|
||||||
'invoice_id' => $invoice_id,
|
|
||||||
'from_subscription'=>$fsubscription,
|
|
||||||
'to_subscription'=>$tsubscription,
|
|
||||||
'is_renew' =>0,
|
|
||||||
'business_id'=>2
|
|
||||||
];
|
|
||||||
$db->table('subscription')->insert($subscriptionData);
|
$db->table('subscription')->insert($subscriptionData);
|
||||||
}
|
|
||||||
|
|
||||||
$paramList = [
|
$paramList = [
|
||||||
'BANKTXNID' => $this->request->getVar('BANKTXNID'),
|
'BANKTXNID' => $this->request->getVar('BANKTXNID'),
|
||||||
|
|||||||
@ -344,14 +344,13 @@ public function getQueryforSubscriptionDetailsBySchemeName($flag,$condition, $va
|
|||||||
$builder->select('subscription.from_subscription, subscription.to_subscription, subscription.scheme_id,books.price ,books.short_code');
|
$builder->select('subscription.from_subscription, subscription.to_subscription, subscription.scheme_id,books.price ,books.short_code');
|
||||||
$builder->join('books', 'subscription.scheme_id = books.book_id');
|
$builder->join('books', 'subscription.scheme_id = books.book_id');
|
||||||
$builder->where('subscription.membership_id', $membership_id);
|
$builder->where('subscription.membership_id', $membership_id);
|
||||||
|
$builder->where('subscription.status',1);
|
||||||
$result = $builder->get()->getRowArray();
|
$result = $builder->get()->getRowArray();
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -60,7 +60,7 @@
|
|||||||
<label for="membership_id">Membership ID</label>
|
<label for="membership_id">Membership ID</label>
|
||||||
<input type="text" value="<?= isset($membership_id) && ($membership_id != null) ? $membership_id : '' ?>" class="form-control" id="membership_id" name="membership_id" placeholder="Enter your Membership ID" required>
|
<input type="text" value="<?= isset($membership_id) && ($membership_id != null) ? $membership_id : '' ?>" class="form-control" id="membership_id" name="membership_id" placeholder="Enter your Membership ID" required>
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" name = 'amount' value = 1>
|
<input type="hidden" id="amount" name = 'amount' value = "<?=isset($amount)?$amount: ''?>">
|
||||||
<input type="hidden" id="CustomerID" name = 'CustomerID' value = <?=isset($CustomerID)? $CustomerID['customer_id']: '' ?>>
|
<input type="hidden" id="CustomerID" name = 'CustomerID' value = <?=isset($CustomerID)? $CustomerID['customer_id']: '' ?>>
|
||||||
<!-- Customer Information Section (Hidden Initially) -->
|
<!-- Customer Information Section (Hidden Initially) -->
|
||||||
<div id="customerInfo" class="hidden-details d-none">
|
<div id="customerInfo" class="hidden-details d-none">
|
||||||
@ -78,7 +78,7 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<select required class="form-control" id="subscriptionPlans">
|
<select required class="form-control" id="subscriptionPlans">
|
||||||
<option value="" disabled selected>Select a plan</option>
|
<option value="" disabled selected>Select a plan</option>
|
||||||
<option value="1500">PUSTHAKAM Membership - 1 Year (RENEWAL) - ₹1500</option>
|
<option value="<?= isset($amount)?$amount: '' ?>">PUSTHAKAM Membership - 1 Year (RENEWAL) - ₹<?= isset($amount)?$amount: '' ?> </option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -171,6 +171,13 @@
|
|||||||
// Display customer information
|
// Display customer information
|
||||||
$('#customerInfo').removeClass('d-none');
|
$('#customerInfo').removeClass('d-none');
|
||||||
$('#CustomerID').val(response.CustomerID.customer_id);
|
$('#CustomerID').val(response.CustomerID.customer_id);
|
||||||
|
$('#amount').val(response.amount);
|
||||||
|
$('#subscriptionPlans').val(response.amount);
|
||||||
|
$('#subscriptionPlans').html(`
|
||||||
|
<option value="${response.amount}">
|
||||||
|
PUSTHAKAM Membership - 1 Year (RENEWAL) - ₹${response.amount}
|
||||||
|
</option>
|
||||||
|
`);
|
||||||
if (response.scheme) {
|
if (response.scheme) {
|
||||||
// Calculate expiration
|
// Calculate expiration
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user