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>"; } } }
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(); } }
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 /////////////////////////////////////////////////////////////// } }