public function load() { $AppConfig = $GLOBALS['AppConfig']; if ($this->isPost()) { $usedPackage = NULL; foreach ($AppConfig['plus']['packages'] as $package) { if ($package['cost'] == $_POST['amount']) { $usedPackage = $package; } } $merchant_id = $AppConfig['plus']['payments']['cashu']['merchant_id']; $usedPayment = NULL; foreach ($AppConfig['plus']['payments'] as $payment) { if ($payment['merchant_id'] == $merchant_id) { $usedPayment = $payment; } } if (!isset($_GET[$usedPayment['returnKey']])) { return; } if ($usedPackage != NULL && $usedPayment != NULL && $_POST['token'] == md5(sprintf("%s:%s:%s:%s", $merchant_id, $_POST['amount'], strtolower($_POST['currency']), $_POST['test_mode'] ? $usedPayment['testKey'] : $usedPayment['key']))) { $playerId = base64_decode($_POST['session_id']); $goldNumber = $usedPackage['gold']; $m = new PaymentModel(); $m->incrementPlayerGold($playerId, $goldNumber); $m->dispose(); echo "<h2 style=\"color:#00ff00;\">success</h2>"; } else { echo "<h2 style=\"color:#ff0000;\">failed</h2>"; } } }
public static function totalRevenueByMonthInYear($year) { $paymentModel = new PaymentModel(); $totalRevenue = $paymentModel->getMontlyRevenueByYear($year); // vardump formateado super cheto //echo '<pre>'; print_r($feeModel->getToBePayedFeesOfStudentInYear($studentID,$year)); echo '</pre>'; die; (new ServiceView())->showAsJSON($totalRevenue); }
function load() { $AppConfig = $GLOBALS['AppConfig']; if ($this->isPost()) { $usedPackage = NULL; foreach ($AppConfig['plus']['packages'] as $package) { if ($package['cost'] == $_POST['amount']) { $usedPackage = $package; continue; } } if (isset($_POST['merchant_id'])) { $merchant_id = $AppConfig['plus']['payments']['cashu']['merchant_id']; } else { $merchant_id = $AppConfig['plus']['payments']['onecard']['merchant_id']; $key = $merchant_id . $_POST['OneCard_TransID'] . $_POST['OneCard_Amount'] . $_POST['OneCard_Currency'] . $_POST['OneCard_RTime'] . $payment['plus']['payments']['cashu']['testKey'] . $_POST['OneCard_Code']; $token = md5($key); if ($usedPackage != NULL && $_POST['OneCard_Code'] == '00' && $_POST['OneCard_RHashKey'] == $token) { $playerId = base64_decode($_POST['OneCard_Field1']); $goldNumber = $usedPackage['gold']; $m = new PaymentModel(); $m->incrementPlayerGold($playerId, $goldNumber); $m->dispose(); echo '<h2 style="color:#00ff00;">success</h2>'; } else { echo '<h2 style="color:#ff0000;">failed</h2>'; } $p = new GPage(); $p->run(); return null; } $usedPayment = NULL; foreach ($AppConfig['plus']['payments'] as $payment) { if ($payment['merchant_id'] == $merchant_id) { $usedPayment = $payment; continue; } } if (!isset($_GET[$usedPayment['returnKey']])) { return null; } if ($usedPackage != NULL && $usedPayment != NULL && $_POST['token'] == md5(sprintf('%s:%s:%s:%s', $merchant_id, $_POST['amount'], strtolower($_POST['currency']), $_POST['test_mode'] ? $usedPayment['testKey'] : $usedPayment['key']))) { $playerId = base64_decode($_POST['session_id']); $goldNumber = $usedPackage['gold']; $m = new PaymentModel(); $m->incrementPlayerGold($playerId, $goldNumber); $m->dispose(); echo '<h2 style="color:#00ff00;">success</h2>'; return null; } echo '<h2 style="color:#ff0000;">failed</h2>'; } }
public function load() { $AppConfig = $GLOBALS['AppConfig']; $p = new paypal_class(); $m = new PaymentModel(); if (!isset($_GET['action']) || empty($_GET['action'])) { $GLOBALS['_GET']['action'] = "process"; } switch ($_GET['action']) { case "process": return; case "success": if ($this->isPost()) { echo "<html><head><title>Success</title></head><body><h3>Thank you for your order.</h3>"; $m->dispose(); echo "</body></html>"; } break; case "cancel": echo "<html><head><title>Canceled</title></head><body><h3>The order was canceled.</h3>"; echo "</body></html>"; break; case "ipn": if ($p->validate_ipn()) { break; } $subject = "Instant Payment Notification - Recieved Payment"; $to = $AppConfig['system']['email']; $body = "An instant payment notification was successfully recieved\n"; $body .= "from " . $p->ipn_data['payer_email'] . " on " . date("m/d/Y"); $body .= " at " . date("g:i A") . "\n\nDetails:\n"; foreach ($p->ipn_data as $key => $value) { $body .= "\n{$key}: {$value}"; } @mail($to, $subject, $body); $usedPackage = NULL; foreach ($AppConfig['plus']['packages'] as $package) { if ($package['cost'] == $p->ipn_data['payment_gross']) { $usedPackage = $package; } } $Player = base64_decode($p->ipn_data['custom']); $m = new PaymentModel(); $m->incrementPlayerGold($Player, $usedPackage); $m->dispose(); } }
public function actionResult() { $result = $_POST; $packet = PaymentModel::model()->where(" id = '" . $result['ik_x_package_id'] . "'")->findRow(); $Date = date('Y-m-d'); //echo 'date = '.$Date.'<br/>'; $new_date = date('Y-m-d', strtotime($Date . ' + ' . $packet->day_count . ' month')); //echo 'new_date = '.$new_date.'<br/>'; //echo date('Y-m-d', strtotime($Date. ' + 2 days')); $users = UsersModel::model()->where("`id`='" . $result['ik_x_user_id'] . "'")->findRow(); //$users->id = $result['ik_x_user_id']; $users->package_id = $result['ik_x_package_id']; $users->package_expire = $new_date; $users->promo_code = 'Куплено через интеркассу'; $users->save(); $this->view("Robokassa/result", array("result" => $_POST), false); }
/** * Managing authorize.net silent post * @author Dmitry Semenov <*****@*****.**> */ public function run() { $postData = $_POST; Yii::log(CJSON::encode($postData), 'trace'); if (empty($postData) || empty($postData['x_trans_id']) || empty($postData['x_amount']) || empty($postData['x_response_code']) || empty($postData['x_response_reason_text'])) { Yii::log("Incorrect POST provided", 'error'); exit; } try { if (Yii::app()->params['payment']['testMode'] == true) { $hash = md5(Yii::app()->params['payment']['testData']['md5Word'] . $postData['x_trans_id'] . $postData['x_amount']); } else { $hash = md5(Yii::app()->params['payment']['liveData']['md5Word'] . $postData['x_trans_id'] . $postData['x_amount']); } } catch (Exception $e) { Yii::log($e->getMessage(), 'error'); Yii::app()->end(); } try { if (strtolower($hash) == strtolower($postData['x_MD5_Hash'])) { $payment = PaymentModel::model()->findByAttributes(array('subscriptionID' => $postData['x_subscription_id'])); if (empty($payment)) { Yii::log("No subscription #" . $postData["x_subscription_id"] . " in DB\n", 'error'); Yii::app()->end(); } else { $valid = true; } } else { Yii::log("Incorrect hash provided.", 'error'); Yii::app()->end(); } } catch (Exception $e) { Yii::log($e->getMessage(), 'error'); exit; } // If it is an ARB transaction, do something with it if ($valid) { try { if ($postData['x_response_code'] == 1) { // --- Approved transactions management --- // if ($postData['x_subscription_paynum'] == 1) { Yii::log("Subscription OK", 'trace'); Yii::app()->end(); } $membershipPlan = MembershipPlanModel::model()->findByPk($payment->relatedUser->membership->membershipPlanID); $paymentData = array('status' => PaymentModel::STATUS_COMPLETED, 'message' => $postData['x_response_reason_text'], 'initID' => $payment->id); PaymentModel::createPayment($payment->relatedUser, PaymentModel::TYPE_OEM_RECURRING, $membershipPlan, $payment->relatedUser->membership, null, $paymentData); UserMembershipModel::extendMembership($payment->userMembershipID); Yii::app()->membership->prolong($plan->id, $plan->intervalLength, $plan->intervalUnit, $userId); } else { // Denied transactions //--- oem_recurring (failed) ---// $membershipPlan = MembershipPlanModel::model()->findByPk($payment->relatedUser->membership->membershipPlanID); $paymentData = array('status' => PaymentModel::STATUS_REFUSED, 'message' => $postData['x_response_reason_text'], 'initID' => $payment->id); PaymentModel::createPayment($payment->relatedUser, PaymentModel::TYPE_OEM_RECURRING, $membershipPlan, $payment->relatedUser->membership, null, $paymentData); Yii::app()->membership->prolong($plan->id, $plan->intervalLength, $plan->intervalUnit, $userId); } } catch (Exception $e) { Yii::log($e->getMessage(), 'error'); Yii::app()->end(); } } Yii::app()->end(); }
function startup() { parent::startup(); $this->model = PaymentModel::init(); }
public function addPaymentModelRelatedByParent(PaymentModel $l) { $this->collPaymentModelsRelatedByParent[] = $l; $l->setPaymentModelRelatedByParent($this); }
public function actionPayment() { $packets = PaymentModel::model()->findAll(); $currency = CurrencyModel::model()->findRow(); $this->view("payment", array("packets" => $packets, "currency" => $currency), false); }
function load() { $AppConfig = $GLOBALS['AppConfig']; if ($this->isPost()) { $usedPackage = NULL; foreach ($AppConfig['plus']['packages'] as $package) { if ($package['name'] == $_POST['PayPal']) { $usedPackage = $package; } } // now this is just only for cashu $merchant_id = $AppConfig['plus']['payments']['paypal']['merchant_id']; $usedPayment = NULL; foreach ($AppConfig['plus']['payments'] as $payment) { if ($payment['merchant_id'] == $merchant_id) { $usedPayment = $payment; } } $sub_dom = 'sandbox'; // www or sandbox $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&{$key}={$value}"; } //end for // post back to PayPal system to validate $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen('ssl://www.paypal.com', 443, $errno, $errstr, 30); // assign posted variables to local variables $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; if (!$fp) { } else { fputs($fp, $header . $req); while (!feof($fp)) { $res = fgets($fp, 1024); if (strcmp($res, "VERIFIED") == 0) { // check the payment_status is Completed if (strtoupper($payment_status) == 'COMPLETED') { //payment is completed if ($usedPackage != NULL && $usedPayment != NULL) { $OID = base64_decode($_POST['option_selection1']); $goldNumber = $usedPackage['gold']; $m = new PaymentModel(); $m->incrementPlayerGold($playerId, $goldNumber); $m->dispose(); } } //end if payment completed } //end if verified } //end while fclose($fp); } //end if fp /////////////////////////////////////////////////////////////// } }
public static function listTotalRevenueView() { $paymentModel = new PaymentModel(); $totalRevenue = $paymentModel->getTotalRevenue(); (new ListTotalRevenue())->show($totalRevenue); }
public function actionGenerateCode() { if (isset($_POST['sub_code_generate'])) { if ($_POST['code_type'] == 1) { $date = date('Y-m-d'); switch ($_POST['can_activate']) { case 1: $can_activate = date('Y-m-d H-i-s', strtotime("+12 hours")); break; case 2: $can_activate = date('Y-m-d', strtotime($date . ' + 1 days')); break; case 3: $can_activate = date('Y-m-d', strtotime($date . ' + 3 days')); break; case 4: $can_activate = date('Y-m-d', strtotime($date . ' + 7 days')); break; case 5: $can_activate = date('Y-m-d', strtotime($date . ' + 14 days')); break; case 6: $can_activate = date('Y-m-d', strtotime($date . ' + 1 month')); break; case 7: $can_activate = date('Y-m-d', strtotime($date . ' + 2 month')); break; case 8: $can_activate = date('Y-m-d', strtotime($date . ' + 3 month')); break; } switch ($_POST['active_to']) { case 1: $active_to = '+ 3 days'; break; case 2: $active_to = '+ 7 days'; break; case 3: $active_to = '+ 14 days'; break; case 4: $active_to = '+ 3 month'; break; case 5: $active_to = '+ 6 month'; break; case 6: $active_to = '+ 1 year'; break; } //echo 'can activate = '.$can_activate.'<br/>'; //echo 'active_to = '.$active_to.'<br/>'; $model = new ReferalCodeModel(); $model->code_type = $_POST['code_type']; $model->activate_count = $_POST['activate_count']; $model->can_activate = $can_activate; $model->active_to = $active_to; $model->code = $_POST['code']; $model->active_to_use = "1"; $model->save(); $this->redirect("/admin/generate_code"); } else { switch ($_POST['active_to']) { case 1: $active_to = '+ 3 days'; break; case 2: $active_to = '+ 7 days'; break; case 3: $active_to = '+ 14 days'; break; case 4: $active_to = '+ 3 month'; break; case 5: $active_to = '+ 6 month'; break; case 6: $active_to = '+ 1 year'; break; } $model = new ReferalCodeModel(); $model->code_type = $_POST['code_type']; $model->active_to = $active_to; $model->code = $_POST['code']; $model->active_to_use = "1"; $model->save(); $this->redirect("/admin/generate_code"); } } else { $packages = PaymentModel::model()->findAll(); $codes = ReferalCodeModel::model()->findAll(); $this->view("/admin/code_generate", array("packages" => $packages, "codes" => $codes), false); } }