| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/b2bzend/application/controllers/ |
Upload File : |
<?php
/**
* Class PackageController
*
* @name PackageController
* @author Baljeet Poonia
* @version 1.0
* @copyright Catabatic India Pvt Ltd
* Handle Package Related function
*
*/
require_once $_SERVER['DOCUMENT_ROOT'] . '/library/RazorPay/Razorpay.php';
require_once $_SERVER['DOCUMENT_ROOT'] . "/stripe/vendor/autoload.php";
use Razorpay\Api\Api;
class PublicmiscellaneousController extends Catabatic_ValidateCustomer {
public $baseUrl = '';
protected $db = NULL;
public $paymentMdl;
public function init() {
$aConfig = $this->getInvokeArg('bootstrap')->getOptions();
$this->smtpUserName = $aConfig['smtpUserName'];
$this->db = Zend_Db_Table::getDefaultAdapter();
$this->paymentMdl = new Payment_Model_Payment();
}
public function indexAction() {
die();
}
public function printinvoiceAction() {
$this->_helper->layout->disableLayout();
$MasterMiscSysId = base64_decode($this->getRequest()->getParam('id'));
$AgencySysId = base64_decode($this->getRequest()->getParam('ag'));
$obj = new Travel_Model_TblMiscellaneous();
$objAgency = new Travel_Model_TblAgency();
$post = $obj->AgencyMiscellaneousRow($MasterMiscSysId, $AgencySysId);
$postD = $obj->AgencyMisDetailList($MasterMiscSysId, $AgencySysId);
$AgencyData = $objAgency->getUserDataByAgency($AgencySysId);
$AddressAgency = $objAgency->getAddressByAgency($AgencySysId);
$BankDetailsAgency = $objAgency->getBankDetailsByAgency($AgencySysId);
$this->view->AgencySysId = $AgencySysId;
$this->view->post = $post;
$this->view->postD = $postD;
$this->view->AgencyData = $AgencyData;
$this->view->AddressAgency = $AddressAgency;
$this->view->BankDetailsAgency = $BankDetailsAgency;
$this->view->AgencySysId = $AgencySysId;
$this->view->MasterMiscSysId = $MasterMiscSysId;
//print_r($MasterMiscSysId);die;
}
public function paysubscriptioninvoiceAction() {
$TemplateId = base64_decode($this->getRequest()->getParam('id'));
$AgencySysId = base64_decode($this->getRequest()->getParam('ag'));
$objAgency = new Travel_Model_TblAgency();
$AgencyData = $objAgency->getUserDataByAgency($AgencySysId);
echo "<pre>";
print_r($AgencyData);
die;
echo $TemplateId;
die;
}
public function downloadAction() {
$this->_helper->layout->disableLayout();
$MasterMiscSysId = base64_decode($this->getRequest()->getParam('id'));
$AgencySysId = base64_decode($this->getRequest()->getParam('ag'));
$obj = new Travel_Model_TblMiscellaneous();
$post = $obj->AgencyMiscellaneousRow($MasterMiscSysId, $AgencySysId);
$result = file_get_contents($this->view->baseUrl('publicmiscellaneous/downloadpdf/id/' . base64_encode($MasterMiscSysId) . '/ag/' . base64_encode($AgencySysId)));
// echo $result; exit;
Zend_Controller_Action_HelperBroker::getStaticHelper("DownloadPdf")->downloadpdf($result);
header('Content-type: application/pdf');
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=invoice-" . $post['InvoiceNumber'] . ".pdf");
header("Pragma: no-cache");
header("Expires: 0");
exit();
}
public function downloadpdfAction() {
$this->_helper->layout->disableLayout();
$MasterMiscSysId = base64_decode($this->getRequest()->getParam('id'));
$AgencySysId = base64_decode($this->getRequest()->getParam('ag'));
$obj = new Travel_Model_TblMiscellaneous();
$objAgency = new Travel_Model_TblAgency();
$post = $obj->AgencyMiscellaneousRow($MasterMiscSysId, $AgencySysId);
$postD = $obj->AgencyMisDetailList($MasterMiscSysId, $AgencySysId);
$AgencyData = $objAgency->getUserDataByAgency($AgencySysId);
$AddressAgency = $objAgency->getAddressByAgency($AgencySysId);
$BankDetailsAgency = $objAgency->getBankDetailsByAgency($AgencySysId);
$this->view->AgencySysId = $AgencySysId;
$this->view->post = $post;
$this->view->postD = $postD;
$this->view->AgencyData = $AgencyData;
$this->view->AddressAgency = $AddressAgency;
$this->view->BankDetailsAgency = $BankDetailsAgency;
}
public function downloadpdfsubAction() {
$this->_helper->layout->disableLayout();
$Id = (int) base64_decode($this->getRequest()->getParam('data'));
$Subscription = new Subscription_Model_Subscription();
$AgencySysId = base64_decode($this->getRequest()->getParam('ag'));
$objAgency = new Travel_Model_TblAgency();
$finalresultLog = $Subscription->printInvoicePlanByPlan("TB_Master_Subscription_TopUps_Log", $AgencySysId, $Id);
if (!empty($finalresultLog)) {
$finalresult = $Subscription->getDetailsByUniqueId("TB_Master_Subscription_Invoice", '*', 'SubsTopUpsSysId', $finalresultLog['SubsTopUpsSysId']);
$this->view->finalresult = $finalresult;
$this->view->finalresultLog = $finalresultLog;
$AgencyData = $objAgency->getUserDataByAgency($AgencySysId);
$AddressAgency = $objAgency->getAddressByAgency($AgencySysId);
$this->view->AgencyData = $AgencyData;
$this->view->AddressAgency = $AddressAgency;
} else {
die('error');
}
}
public function addMisPaymentAction() {
$this->_helper->layout->disableLayout();
$MasterMiscSysId = base64_decode($this->getRequest()->getParam('id'));
$AgencySysId = base64_decode($this->getRequest()->getParam('ag'));
$CreateDate = date('Y-m-d H:i:s');
$request = Zend_Controller_Front::getInstance()->getRequest();
if ($request->isPost()) {
$post = $request->getPost();
$obj = new Travel_Model_TblMiscellaneous();
$objAgency = new Travel_Model_TblAgency();
$postD = $obj->AgencyMiscellaneousRow($MasterMiscSysId, $AgencySysId);
$AgencyData = $objAgency->getUserDataByAgency($AgencySysId);
$AgentSysId = $postD['AgentSysId'];
$amount = $post['amount'];
$PaymentType = isset($post['PaymentType']) ? $post['PaymentType'] : '';
$TotalDueAmount = $postD['TotalDueAmount'];
if ($amount == '' || $amount < 0) {
$response = array('success' => false, 'message' => 'Please enter amount!');
echo json_encode($response);
exit;
}
if ($TotalDueAmount >= $amount) {
$totalpayable = ($TotalDueAmount - $amount);
} else {
$response = array('success' => false, 'message' => 'Oops invalid amount. please try again.');
echo json_encode($response);
exit;
}
if ($totalpayable == '0') {
$InvoiceStatus = 1;
} elseif ($amount < $postD['TotalDueAmount']) {
$InvoiceStatus = 2;
} else {
$InvoiceStatus = 5;
}
$paymentDate = isset($post['paymentDate']) && !empty($post['paymentDate']) ? $post['paymentDate'] : '';
$PaymentDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($paymentDate, 'd/m/y');
$insertUpdateLog = array(
'MasterMiscSysId' => $MasterMiscSysId,
'AgentSysId' => $AgentSysId,
'ICSourceSysId' => $AgencySysId,
'Amount' => $amount,
'InvoiceStatus' => $InvoiceStatus,
'PaymentType' => $PaymentType,
'PaymentDate' => $PaymentDate,
'PaymentNote' => '',
'CreateDate' => $CreateDate,
'UpdateDate' => $CreateDate,
'IsActive' => 1,
'IsMarkForDel' => 0
);
$this->db->insert('TB_Agency_MiscellaneousPaymentLog', $insertUpdateLog);
$insertId = $this->db->lastInsertId("TB_Agency_MiscellaneousPaymentLog");
$guid = $this->GUID();
$secureCode = $this->walletCode($AgencySysId, $guid, $amount, $AgentSysId, $insertId, ($postD['TotalCGST'] + $postD['TotalCGST']), $amount);
$fullBaseUrl = $this->view->baseUrl();
$paymentData = array(
'subscription_id' => $insertId,
'txnid' => $guid,
'finalAmount' => $amount,
'CustomerSysId' => $postD['BilledTo'],
'productInfo' => 'MisInvoice',
'Firstname' => trim($postD['FullName']),
'email' => trim($postD['EmailId']),
'phone' => trim($postD['Contacts']),
'amount' => $amount,
'udf2' => $AgencySysId,
'securecode' => $secureCode,
'udf3' => $AgentSysId,
'otherCharge' => ($postD['TotalCGST'] + $postD['TotalCGST']),
'udf5' => $fullBaseUrl . "/publicmiscellaneous/confirmation-payment", // Return url
'PlanType' => 18,
'TrxType' => 'M'
);
$UpdateLogs = array(
'PaymentStatus' => 0,
'PaymentData' => json_encode($paymentData),
'SecureCode' => $secureCode,
'GUID_ID' => $guid,
'PaymentType' => $PaymentType,
);
$whereLog = array('MasterMiscPaySysId =?' => $insertId);
$result = $this->db->update('TB_Agency_MiscellaneousPaymentLog', $UpdateLogs, $whereLog);
if (!empty($result) && $insertId > 0) {
$checkPaymentSetting = $this->paymentMdl->checkPaymentgatewaySetting($AgencySysId);
$razor = 'ATOM';
$razordata = [];
if (trim($checkPaymentSetting['Title']) == 'Razorpay') {
$razor = 'Razorpay';
$ATOMPASS = trim($checkPaymentSetting['PaymentSecretPwd']);
$keyId = trim($checkPaymentSetting['PaymentMerchantId']);
$amount = $amount * 100;
$txncurr = 'INR';
$api = new Api($keyId, $ATOMPASS);
$orderData = [
'receipt' => time(),
'amount' => $amount, // 39900 rupees in paise
'currency' => $txncurr,
];
$razorpayOrder = $api->order->create($orderData);
$razorpayOrderId = $razorpayOrder->id;
$razordata = [
"key" => $keyId,
"amount" => $amount,
"name" => trim($AgencyData["Title"]),
"description" => trim($AgencyData["Title"]),
"image" => $fullBaseUrl . "/public/upload/media/agency/" . $AgencySysId . "/" . trim($AgencyData["Logo"]),
"prefill" =>
[
"name" => $paymentData['Firstname'],
"email" => $paymentData['email'],
"contact" => $paymentData['phone']
],
"notes" =>
[
"address" => "India",
"merchant_order_id" => $guid,
],
"theme" =>
[
"color" => "#FC9F84"
],
"order_id" => $razorpayOrderId,
];
$encodeUdfNineValue = array(
"key" => $keyId,
"amount" => $amount,
"paymentData" => $paymentData
);
$cashFeeData = array(
'AgencySysId' => $AgencySysId,
'TPSysId' => 0,
'OrderId' => $razorpayOrderId,
'Udf' => json_encode($encodeUdfNineValue)
);
$this->paymentMdl->insertTable("TB_Master_CashFee_Payment_Data", $cashFeeData);
} else if (trim($checkPaymentSetting['Title']) == 'Stripe') {
$razor = trim($checkPaymentSetting['Title']);
$razordata['PaymentMerchantId'] = trim($checkPaymentSetting['PaymentMerchantId']);
$razordata['Firstname'] = trim($postD['FullName']);
$razordata['email'] = trim($postD['EmailId']);
$razordata['phone'] = trim($postD['Contacts']);
$razordata['amount'] = $amount;
$razordata['Symbol'] = trim($postD['Symbol']);
$razordata['CountryName'] = trim($postD['CountryName']);
$razordata['AgencySysId'] = trim($AgencySysId);
$razordata['Address'] = trim($postD['Address']);
$razordata['PinCode'] = trim($postD['PinCode']);
$razordata['CityName'] = trim($postD['CityName']);
$razordata['insertId'] = $insertId;
}
$response = array('success' => true, 'PaymentGatewayType' => $razor, 'razorData' => $razordata, 'message' => 'Add payment successfully', 'paymentData' => $paymentData);
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'message' => 'Unable to add payment. try again', 'paymentData' => '');
echo json_encode($response);
exit;
}
}
}
public function stripPaymentAction() {
$paymentMdl = new Payment_Model_Payment();
$request = Zend_Controller_Front::getInstance()->getRequest();
if ($request->isPost()) {
$post = $request->getPost();
//$order_id = $this->Gu;
$token = isset($post['tokenId']) ? trim($post['tokenId']) : '';
$AgencySysId = (int) $post['AgencySysId'];
$FullName = isset($post['FullName']) ? trim($post['FullName']) : '';
$amount = isset($post['FullName']) ? (float) ($post['amount'] * 100) : '';
$invCurrency = isset($post['invCurrency']) ? trim($post['invCurrency']) : '';
$Email = isset($post['Email']) ? trim($post['Email']) : '';
$Address = isset($post['Address']) ? trim($post['Address']) : '';
$City = isset($post['City']) ? trim($post['City']) : '';
$Country = isset($post['Country']) ? trim($post['Country']) : '';
$Pincode = isset($post['Pincode']) ? trim($post['Pincode']) : '';
$insertId = isset($post['insertId']) ? trim($post['insertId']) : '';
$checkPaymentSetting = $paymentMdl->checkPaymentgatewaySetting($AgencySysId);
if ($token != '' && !empty($checkPaymentSetting)) {
$secretKey = trim($checkPaymentSetting['PaymentSecretPwd']);
try {
$stripe = new \Stripe\StripeClient($secretKey);
$customer = $stripe->customers->create(
[
'name' => $FullName,
'email' => $Email,
'address' => [
'line1' => $Address,
'postal_code' => $Pincode,
'city' => $City,
'state' => '',
'country' => $Country,
],
]
);
$charge = $stripe->paymentIntents->create([
"amount" => $amount,
"currency" => $invCurrency,
'payment_method_types' => ['card'],
'payment_method_data' => [
'type' => 'card',
'card' => [
'token' => $token
]
],
'description' => 'Travel Agency',
'shipping' => [
'name' => $FullName,
'address' => [
'line1' => $Address,
'postal_code' => $Pincode,
'city' => $City,
'state' => '',
'country' => $Country,
],
],
'customer' => $customer->id,
"metadata" => ["order_id" => $insertId],
'capture_method' => 'automatic',
'return_url' => Catabatic_Helper::getSiteUrl() . 'publicmiscellaneous/strip-confirmation-payment/AgencySysId/' . $AgencySysId,
'confirm' => true,
'confirmation_method' => 'automatic'
]);
$next_action = $charge->next_action->redirect_to_url->url;
$data = array('success' => true, 'data' => $charge, 'customer' => $customer, 'redirect_url' => $next_action);
echo json_encode($data);
exit;
} catch (Zend_Exception $e) {
echo $e->getMessage();
exit;
}
} else {
echo "asdsa";
exit;
}
} else {
echo "asdsa0000000000000";
exit;
}
}
public function stripConfirmationPaymentAction() {
$request = Zend_Controller_Front::getInstance()->getRequest();
$resultSet = $request->getParams();
$paymentMdl = new Payment_Model_Payment();
if (!empty($resultSet)) {
$token = isset($resultSet['payment_intent']) ? $resultSet['payment_intent'] : '';
$AgencySysId = $resultSet['AgencySysId'];
$checkPaymentSetting = $paymentMdl->checkPaymentgatewaySetting($AgencySysId);
$stripe = new \Stripe\StripeClient($checkPaymentSetting['PaymentSecretPwd']);
$return = $stripe->paymentIntents->retrieve(
$token
);
$status = isset($return->status) ? trim($return->status) : '';
if ($status == 'succeeded') {
// $amount_received = isset($return->amount_received) ? $return->amount_received : '';
// $currency = isset($return->charges->data[0]->currency) ? $return->charges->data[0]->currency : '';
$balance_transaction = isset($return->charges->data[0]->balance_transaction) ? $return->charges->data[0]->balance_transaction : '';
// $receipt_url = isset($return->charges->data[0]->receipt_url) ? $return->charges->data[0]->receipt_url : '';
$order_id = isset($return->metadata->order_id) ? $return->metadata->order_id : '';
$obj = new Travel_Model_TblMiscellaneous();
$PayentRow = $obj->AgencyMiscellaneousPayentRowPub($order_id);
$AgencySysId = $PayentRow['ICSourceSysId'];
$postD = $obj->AgencyMiscellaneousRow($PayentRow['MasterMiscSysId'], $AgencySysId);
$amount = $PayentRow['Amount'];
$TotalDueAmount = $postD['TotalDueAmount'];
$totalpayable = ($TotalDueAmount - $amount);
if ($totalpayable == '0') {
$InvoiceStatus = 1;
} elseif ($amount < $postD['TotalDueAmount']) {
$InvoiceStatus = 2;
} else {
$InvoiceStatus = 5;
}
$PaymentDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($PayentRow['PaymentDate']->format("d/m/Y"), 'd/m/y');
$insertUpdate = array(
'TotalAdvance' => ($amount + $postD['TotalAdvance']),
'TotalDueAmount' => $totalpayable,
'InvoiceStatus' => $InvoiceStatus,
'PaymentType' => $PayentRow['PaymentType'],
'PaymentDate' => $PaymentDate,
'PaymentNote' => $PayentRow['PaymentNote']
);
$where = array('MasterMiscSysId =?' => $PayentRow['MasterMiscSysId']);
$this->db->update('TB_Agency_Miscellaneous', $insertUpdate, $where);
$updatePaymentLog = array(
'IsApproved' => TRUE,
'PaymentStatus' => TRUE,
'TrxId' => $balance_transaction,
'error_Message' => $status,
);
$whereCon = array("MasterMiscPaySysId =?" => $order_id, "ICSourceSysId =?" => $AgencySysId);
$this->db->update('TB_Agency_MiscellaneousPaymentLog', $updatePaymentLog, $whereCon);
$udf5 = Catabatic_Helper::getSiteUrl() . "publicmiscellaneous/thankyou/";
$contactForm = new Payment_Form_Websitereturn();
$contactForm->setMethod('post');
$contactForm->setName('PAYMENTFORM');
$contactForm->setAction($udf5);
$pstatus = 'Ok';
$paymentInfo["status"] = $pstatus;
$paymentInfo["mmp_txn"] = $balance_transaction;
$paymentInfo["isra"] = 0;
$paymentInfo["amt"] = $amount;
$contactForm->populate($paymentInfo);
$this->view->paymentInfo = $contactForm;
}
}
}
public function confirmationPaymentAction() {
$request = Zend_Controller_Front::getInstance()->getRequest();
//echo "<pre>";print_r($_POST);exit;
$this->_helper->layout()->disableLayout();
$obj = new Travel_Model_TblMiscellaneous();
if ($request->isPost()) {
$postRequest = $request->getPost();
$returnw = false;
if (isset($postRequest['TpSysId'])) {
$PayentRow = $obj->AgencyMiscellaneousPayentRowPub($postRequest['TpSysId']);
$returnw = true;
}
if ($this->getRequest()->isPost() && $postRequest['status'] == 'success') {
$PayentRow = $obj->AgencyMiscellaneousPayentRowPub($postRequest['TpSysId']);
$AgencySysId = $PayentRow['ICSourceSysId'];
$postD = $obj->AgencyMiscellaneousRow($PayentRow['MasterMiscSysId'], $AgencySysId);
$amount = $PayentRow['Amount'];
$TotalDueAmount = $postD['TotalDueAmount'];
$totalpayable = ($TotalDueAmount - $amount);
if ($totalpayable == '0') {
$InvoiceStatus = 1;
} elseif ($amount < $postD['TotalDueAmount']) {
$InvoiceStatus = 2;
} else {
$InvoiceStatus = 5;
}
$PaymentDate = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->cal2Db($PayentRow['PaymentDate']->format("d/m/Y"), 'd/m/y');
$insertUpdate = array(
'TotalAdvance' => ($amount + $postD['TotalAdvance']),
'TotalDueAmount' => $totalpayable,
'InvoiceStatus' => $InvoiceStatus,
'PaymentType' => $PayentRow['PaymentType'],
'PaymentDate' => $PaymentDate,
'PaymentNote' => $PayentRow['PaymentNote']
);
$where = array('MasterMiscSysId =?' => $PayentRow['MasterMiscSysId']);
$this->db->update('TB_Agency_Miscellaneous', $insertUpdate, $where);
$updatePaymentLog = array(
'IsApproved' => TRUE,
'PaymentStatus' => TRUE,
'TrxId' => $postRequest['TrxId'],
'error_Message' => $postRequest['status'] . '@@' . $postRequest['error_Message'],
);
$whereCon = array("MasterMiscPaySysId =?" => $postRequest['TpSysId'], "ICSourceSysId =?" => $AgencySysId);
$status = $this->db->update('TB_Agency_MiscellaneousPaymentLog', $updatePaymentLog, $whereCon);
} else {
$updatePaymentLog = array(
'IsApproved' => FALSE,
'PaymentStatus' => 2,
'TrxId' => $postRequest['TrxId'],
'error_Message' => $postRequest['status'] . '@@' . $postRequest['error_Message'],
);
$whereCon = array("MasterMiscPaySysId =?" => $postRequest['TpSysId'], "ICSourceSysId =?" => $AgencySysId);
$this->db->update('TB_Agency_MiscellaneousPaymentLog', $updatePaymentLog, $whereCon);
}
$udf5 = Catabatic_Helper::getSiteUrl() . "publicmiscellaneous/thankyou/";
if (($returnw = true) && (isset($PayentRow['ICSourceSysId']) && ($PayentRow['ICSourceSysId'] == 14413))) {
$udf5 = "https://www.themusafirs.in/payment/index/thank-you";
}
$contactForm = new Payment_Form_Websitereturn();
$contactForm->setMethod('post');
$contactForm->setName('PAYMENTFORM');
$contactForm->setAction($udf5);
$pstatus = 'f';
if (isset($postRequest['status']) && $postRequest['status'] == 'success') {
$pstatus = 'Ok';
} else {
$pstatus = 'f';
}
$paymentInfo["status"] = $pstatus;
$paymentInfo["mmp_txn"] = isset($postRequest['TrxId']) ? $postRequest['TrxId'] : 0;
$paymentInfo["isra"] = 0;
$paymentInfo["amt"] = isset($PayentRow['Amount']) ? $PayentRow['Amount'] : 0;
$contactForm->populate($paymentInfo);
$this->view->paymentInfo = $contactForm;
} else {
echo "Please contact to administrator";
exit;
}
}
public function thankyouAction() {
$this->_helper->layout->disableLayout();
$request = Zend_Controller_Front::getInstance()->getRequest();
if ($request->isPost()) {
$postRequest = $request->getPost();
if (isset($postRequest['status']) && $postRequest['status'] == 'Ok') {
echo 'Thank you, your payment has been received. transaction Id:- ' . $postRequest['mmp_txn'];
exit;
} else {
echo 'Oops! unable complete payments! please try again. transaction Id:- ' . $postRequest['mmp_txn'];
exit;
}
} else {
echo "Please contact to administrator";
exit;
}
}
}