EVOLUTION-NINJA
Edit File: Payment.php
<?php namespace App\Controllers\Subscription; use App\Controllers\BaseController; use CodeIgniter\RESTful\ResourceController; use CodeIgniter\API\ResponseTrait; use App\Models\RegisterUserModel; use App\Models\Subscription_paymentModel; class Payment extends BaseController { public function index() { } public function payments() { $pay_id = $this->request->getPost('pay_id'); $amount = $this->request->getPost('amount'); $transaction_id = $this->request->getVar('transaction_id'); $email1 = ''; if(session()->get('mail')){ $email1 = session()->get('mail'); } else if(session()->get('email')){ $email1 = session()->get('email'); } $pass = substr(str_shuffle("0123456789abcdefghijklmnopqrstvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 8); date_default_timezone_set('Asia/Kolkata'); $payment_date_added = date('d-m-Y H:i:s', time()); $model = new RegisterUserModel(); $details = $model->where('email',$email1)->first(); $suscription_till = $details['suscription_till']; $f_name = $details['f_name']; $gamer_id = $details['gamer_id']; if(date($suscription_till) < date("Y-m-d")){ $newEndingDate = date("Y-m-d", strtotime(date("Y-m-d") . " + 365 day")); } else{ $newEndingDate = date("Y-m-d", strtotime($suscription_till . " + 365 day")); } $payment = array( 'pay_id'=>$transaction_id, 'amount' => $amount, 'email' => $email1, 'user_id' => $details['id'] ); $model = new Subscription_paymentModel(); $model->save($payment); $insertedID = $model->insertID(); $setData = array( 'suscription_till'=>$newEndingDate ); $model1 = new RegisterUserModel(); $model1->set($setData); $model1->where('email',$email1); $update = $model1->update(); $email = \Config\Services::email(); $email->setFrom("Contact@medusys.in", "Medusys"); $email->setTo($email1); //$email->setTo('sowmyayp@gmail.com'); $email->setSubject('Medusys Subscription Renewal Confirmation'); $content = 'Hello Dr. '.$f_name.'<br/><br/>'; $content = $content.' We would like to thank you for renewing the annual subscription for GAS Medusys Platform. <br/><br/>'; $content = $content.'Your GAMER ID is : '.$gamer_id.'<br/>'; $content = $content.'Your current subscription ends on : '.$newEndingDate.'<br/>'; $content = $content."Your Login id and password are same as before.".'<br/>'; $content = $content.'Please login with the user name and password by clicking the link below.<br/><h4> https://medusys.in/login/ </h4><br/>'; $content = $content.'Thank you again for your time and consideration. Looking forward to the great opportunities together. Should you have any questions, please write to us at contact@medusys.in'.'<br/><br/>'; $content = $content.'Regards <br/>'; $content = $content.'Medusys Team'; $email->setMessage($content); $email->send(); if($update){ return json_encode(array( 'result' => 1 )); }else{ return json_encode(array( 'result' => 0, 'message' => 'Payment interrupted! Something went wrong.....' )); } } } ?>