Exemplo n.º 1
0
 public function displayPaysiteButton(GWF_Module $module, GWF_Order $order, GWF_Orderable $gdo, GWF_User $user)
 {
     $lang_iso = GWF_Language::getCurrentISO();
     $action = self::RECEIVE_MONEY_URL;
     $hidden = GWF_Form::hidden('ap_purchasetype', 'item') . GWF_Form::hidden('ap_merchant', $this->cfgSeller()) . GWF_Form::hidden('ap_itemname', $gdo->getOrderItemName($module, $lang_iso)) . GWF_Form::hidden('ap_currency', $order->getOrderCurrency()) . GWF_Form::hidden('ap_returnurl', Common::getAbsoluteURL($gdo->getOrderSuccessURL($user), false)) . GWF_Form::hidden('ap_itemcode', $order->getOrderToken()) . GWF_Form::hidden('ap_quantity', $order->getOrderAmount()) . GWF_Form::hidden('ap_description', $gdo->getOrderDescr($module, $lang_iso)) . GWF_Form::hidden('ap_amount', $order->getOrderPriceTotal()) . GWF_Form::hidden('ap_cancelurl', Common::getAbsoluteURL($gdo->getOrderCancelURL($user), false));
     //		echo GWF_HTML::display($hidden);
     return Module_Payment::tinyform('pay_ap', 'img/' . GWF_ICON_SET . 'buy_ap.png', $action, $hidden);
 }
Exemplo n.º 2
0
 private function onExecute(GWF_Order $order)
 {
     $form_exec = $this->getFormExec($order);
     if (false !== ($errors = $form_exec->validate($this->module))) {
         return $errors;
     }
     $module2 = $order->getOrderModule();
     $module2->onInclude();
     $module2->onLoadLanguage();
     return Module_Payment::onExecuteOrderS($module2, $order);
 }
Exemplo n.º 3
0
 private function templatePay(Module_PaymentBank $module, GWF_Order $order)
 {
     $module2 = $order->getOrderModule();
     $module2->onLoadLanguage();
     $gdo = $order->getOrderData();
     $user = $order->getUser();
     $sitename = $module->getSiteName();
     $action = GWF_WEB_ROOT . 'index.php?mo=PaymentBank&me=Pay2';
     $hidden = GWF_Form::hidden('gwf_token', $order->getOrderToken());
     $buttons = Module_Payment::tinyform('Bank Transfer', 'img/' . GWF_ICON_SET . 'buy_bank.png', $action, $hidden);
     $lang = $module->loadLangGWF();
     $tVars = array('lang' => $lang, 'user' => $user, 'order_c' => $order, 'order' => Module_Payment::displayOrder3S($module2, $order, $gdo, $user, $sitename, $buttons));
     return $module->templatePHP('pay.php', $tVars);
 }
Exemplo n.º 4
0
 /**
  * Returns error message or false.
  * @param GWF_Order $order
  * @param GWF_User $user
  * @return string | false
  */
 public function canAffordB(GWF_Order $order, $user)
 {
     if ($user === false) {
         return false;
     }
     if ($user->isAdmin()) {
         return false;
     }
     $money = $user->getMoney();
     $price = $order->getOrderPriceTotal();
     $left = $money - $price;
     if ($left >= 0) {
         return false;
     }
     $lang = $this->loadLangGWF();
     return GWF_HTML::error('Buy with GWF', $lang->lang('err_funds', array(Module_Payment::displayPrice($money), Module_Payment::displayPrice($price), Module_Payment::displayPrice(-$left))));
 }
Exemplo n.º 5
0
 private function templatePay(Module_PaymentFree $module, GWF_Order $order)
 {
     $module2 = $order->getOrderModule();
     $module2->onLoadLanguage();
     $gdo = $order->getOrderData();
     $user = $order->getUser();
     $sitename = $module->getSiteName();
     $action = GWF_WEB_ROOT . 'index.php?mo=PaymentFree&me=Pay';
     $hidden = GWF_Form::hidden('gwf_token', $order->getOrderToken());
     $form = $this->tinyCaptchaForm($module, $order);
     $buttons = $form->templateY('Free', $action);
     //		$buttons = Module_Payment::tinyform('Free', 'img/'.GWF_ICON_SET.'buy_free.png', $action, $hidden);
     //		$lang = $module->loadLangGWF();
     //		if (false !== ($error = $module->canAffordB($order, $user))) {
     //			return $error;
     //		}
     //
     $tVars = array('user' => $user, 'order' => Module_Payment::displayOrder3S($module2, $order, $gdo, $user, $sitename, $buttons));
     return $module->templatePHP('pay.php', $tVars);
 }
Exemplo n.º 6
0
 private function onPay(Module_PaymentGWF $module, GWF_Order $order)
 {
     $module2 = $order->getOrderModule();
     $module2->onLoadLanguage();
     $gdo = $order->getOrderData();
     $user = $order->getUser();
     $sitename = $module->getSiteName();
     $action = GWF_WEB_ROOT . 'index.php?mo=PaymentGWF&me=Pay2';
     $hidden = GWF_Form::hidden('gwf_token', $order->getOrderToken());
     $buttons = Module_Payment::tinyform('BUYGWF', 'img/' . GWF_ICON_SET . 'buy_gwf.png', $action, $hidden);
     $lang = $module->loadLangGWF();
     if (false !== ($error = $module->canAffordB($order, $user))) {
         return $error;
     }
     if (!$user->isAdmin()) {
         if (false === $user->increase('user_credits', -$order->getOrderPriceTotal())) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
     }
     return Module_Payment::onExecuteOrderS($module2, $order);
 }
Exemplo n.º 7
0
 private function ipn(Module_PaymentAlertpay $module)
 {
     if (Common::getPost("ap_securitycode") !== $module->cfgSecCode()) {
         GWF_Log::log('alertpay', 'Invalid alertpay security code');
         return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
     }
     if (false === ($email = Common::getPost("ap_custemailaddress"))) {
         GWF_Log::log('alertpay', 'Missing ap_custemailaddress');
         return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
     }
     if (Common::getPost("ap_status") !== "Success") {
         GWF_Log::log('alertpay', 'Alertpay post was not success');
         return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
     }
     if (false === ($token = Common::getPost("ap_itemcode"))) {
         GWF_Log::log('alertpay', 'Missing ap_itemcode');
         return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
     }
     if (false === ($order = GWF_Order::getByToken($token))) {
         GWF_Log::log('alertpay', 'Order not found or token invalid: ' . $token);
         return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
     }
     if (!$order->isCreated()) {
         return $module->error('err_order');
     }
     if (false === ($price = (double) Common::getPost('ap_amount'))) {
         GWF_Log::log('alertpay', 'MISSING ap_amount for ' . $token);
         return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
     }
     if ($price !== (double) $order->getOrderPriceTotal()) {
         GWF_Log::log('alertpay', 'The price for the orders is not the same: ' . $token);
         return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
     }
     $order->saveVar('order_email', $email);
     $module2 = $order->getOrderModule();
     $module2->onLoadLanguage();
     return Module_Payment::onExecuteOrderS($module2, $order);
 }
Exemplo n.º 8
0
 public function execute()
 {
     $gwf_token = Common::getGet('gwf_token');
     if (false === ($order = GWF_Order::getByToken($gwf_token))) {
         return $this->module->error('err_token');
     }
     if (!$order->isCreated()) {
         return $this->module->error('err_order');
     }
     if (false === ($paypaltoken = Common::getGet("token"))) {
         return Module_Payment::instance()->error("err_xtoken", array(GWF_HTML::display($this->module->getSiteName())));
     }
     if ($order->getOrderXToken() !== $paypaltoken) {
         return Module_Payment::instance()->error("err_xtoken", array(GWF_HTML::display($this->module->getSiteName())));
     }
     /* Build a second API request to PayPal, using the token as the
     			ID to get the details on the payment authorization
     		*/
     $nvpstr = "&TOKEN=" . urlencode($paypaltoken);
     /* Make the API call and store the results in an array.  If the
     			call was a success, show the authorization details, and provide
     			an action to complete the payment.  If failed, show the error
     		*/
     $resArray = Paypal_Util::hash_call('GetExpressCheckoutDetails', $nvpstr);
     $ack = strtoupper($resArray["ACK"]);
     if ($ack == "SUCCESS") {
         $order->saveVar('order_xtoken', serialize($resArray));
         $module2 = $order->getOrderModule();
         $module2->onLoadLanguage();
         $gdo = $order->getOrderData();
         $user = $order->getOrderUser();
         $button = $this->module->displayPaysiteButton3($module2, $order, $gdo, $user);
         return Module_Payment::displayOrder3S($module2, $order, $gdo, $user, $order->getOrderPaySite(), $button);
     } else {
         return Paypal_Util::paypalError($resArray);
     }
 }
Exemplo n.º 9
0
 public function displayPrice()
 {
     return Module_Payment::displayPrice($this->getVar('dl_price'));
 }
Exemplo n.º 10
0
echo sprintf('<td>%s</td>', $tLang->lang('th_order_date_ordered'));
echo sprintf('<td class="gwf_date">%s</td>', GWF_Time::displayDate($order->getVar('order_date_ordered')));
echo GWF_Table::rowEnd();
echo GWF_Table::rowStart();
echo sprintf('<td>%s</td>', $tLang->lang('th_order_date_paid'));
echo sprintf('<td class="gwf_date">%s</td>', GWF_Time::displayDate($order->getVar('order_date_paid')));
echo GWF_Table::rowEnd();
echo GWF_Table::rowStart();
echo sprintf('<td>%s</td>', $tLang->lang('th_order_site'));
echo sprintf('<td>%s</td>', $order->getPaymentModule()->getSiteName());
echo GWF_Table::rowEnd();
echo GWF_Table::rowStart();
echo sprintf('<td>%s</td>', $tLang->lang('th_order_status'));
echo sprintf('<td>%s</td>', $status_link);
echo GWF_Table::rowEnd();
echo GWF_Table::rowStart();
echo sprintf('<td>%s</td>', $tLang->lang('th_order_price_total'));
echo sprintf('<td>%s</td>', Module_Payment::displayPrice($order->getOrderPriceTotal()));
echo GWF_Table::rowEnd();
echo GWF_Table::end();
echo $tVars['form_exec'];
echo '<div>' . PHP_EOL;
echo $tVars['display'];
echo '</div>' . PHP_EOL;
//echo $tVars['form_edit'];
//echo sprintf('<div class="gwf_buttons">').PHP_EOL;
//if ($order->isCreated())
//{
//	echo GWF_Button::generic($tLang->lang('btn_mark_paid'), $tVars['href_paid']);
//}
//echo '</div>'.PHP_EOL;
Exemplo n.º 11
0
 private function onOrder()
 {
     // Check for Payment, as it`s not a required dependency.
     //		var_dump(GWF_Session::getSessData());
     if (false === ($order = Module_Payment::getTempOrder())) {
         return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__)) . $this->templatePurchase();
     }
     Module_Payment::dropTempOrder();
     $user = GWF_User::getStaticOrGuest();
     $paysite = Common::getPost('paysite', 'xx');
     return Module_Payment::displayOrder2S($this->module, $order, $user, $paysite);
 }
Exemplo n.º 12
0
    echo sprintf('<td>%s</td>', GWF_Form::checkbox(sprintf('mod[%s]', $module->getName()), $checked));
    echo sprintf('<td>%s</td>', $module->display('module_name'));
    echo sprintf('<td>%s</td>', Module_Payment::displayPrice($price));
    echo sprintf('<td>%s</td>', implode(', ', array_keys($module->getDependencies())));
    echo sprintf('<td>%s</td>', $strMethods);
    echo GWF_Table::rowEnd();
}
echo GWF_Table::end();
// Design table
$headers = array(array(), array($tLang->Lang('th_design_name')), array($tLang->Lang('th_design_price')));
echo GWF_Table::start();
echo GWF_Table::displayHeaders2($headers);
foreach ($tVars['designs'] as $design => $price) {
    if ($client !== false) {
        $checked = $client->ownsDesign($design);
    } else {
        $checked = isset($_POST['purchase']) ? isset($_POST['design'][$design]) : $price == 0;
    }
    echo GWF_Table::rowStart();
    echo sprintf('<td>%s</td>', GWF_Form::checkbox(sprintf('design[%s]', $design), $checked));
    echo sprintf('<td>%s</td>', $design);
    echo sprintf('<td>%s</td>', Module_Payment::displayPrice($price));
    echo GWF_Table::rowEnd();
}
echo GWF_Table::end();
echo '<div class="gwf_buttons_outer">' . PHP_EOL;
echo '<div class="gwf_buttons">' . PHP_EOL;
echo GWF_Form::submit('purchase', $tLang->lang('btn_purchase')) . PHP_EOL;
echo '</div>' . PHP_EOL;
echo '</div>' . PHP_EOL;
echo GWF_Form::end();
Exemplo n.º 13
0
 public static function onExecuteOrderS(GWF_Module $module, GWF_Order $order)
 {
     $mod_pay = Module_Payment::instance();
     if (false === self::instance()->onExecuteOrder($module, $order)) {
         return $mod_pay->error('err_crit', $order->getOrderToken());
     }
     return $mod_pay->message('msg_paid');
 }
Exemplo n.º 14
0
 private function onOrder(GWF_Download $dl)
 {
     // Check for Payment, as it`s not a required dependency.
     if (false === ($mod_pay = GWF_Module::getModule('Payment'))) {
         return GWF_HTML::err('ERR_MODULE_MISSING', array('Payment'));
     }
     $user = GWF_User::getStaticOrGuest();
     $paysite = Common::getPost('paysite', 'xx');
     $dl->setVar('your_token', GWF_DownloadToken::generateToken());
     return Module_Payment::displayOrder2S($this->module, $dl, $user, $paysite);
 }
Exemplo n.º 15
0
 public static function insertOrder(GWF_Module $module, GWF_Orderable $gdo, GWF_PaymentModule $paysite, GWF_User $user, $price_total, $cartid = 0)
 {
     $token = self::generateToken();
     $order = new self(array('order_cartid' => $cartid, 'order_uid' => $user->getID(), 'order_token' => $token, 'order_xtoken' => '', 'order_date_paid' => '00000000000000', 'order_date_ordered' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'order_price' => $gdo->getOrderPrice($user), 'order_price_total' => $price_total, 'order_currency' => Module_Payment::getShopCurrencyS(), 'order_amount' => 1, 'order_email' => '', 'order_site' => $paysite->getSiteNameToken(), 'order_title' => $gdo->getOrderItemName($module, GWF_Language::getCurrentISO()), 'order_title_admin' => $gdo->getOrderItemName($module, GWF_LANG_ADMIN), 'order_descr' => $gdo->getOrderDescr($module, GWF_Language::getCurrentISO()), 'order_descr_admin' => $gdo->getOrderDescr($module, GWF_LANG_ADMIN), 'order_status' => self::CREATED, 'order_data' => serialize($gdo), 'order_module' => $gdo->getOrderModuleName()));
     if (false === $order->insert()) {
         return false;
     }
     return $order;
 }
Exemplo n.º 16
0
 public function displayPaysiteButton(GWF_Module $module, GWF_Order $order, GWF_Orderable $gdo, GWF_User $user)
 {
     $action = GWF_WEB_ROOT . 'index.php?mo=PaymentFree&me=Pay';
     $hidden = GWF_Form::hidden('gwf_token', $order->getOrderToken());
     return Module_Payment::tinyform('Free', 'img/' . GWF_ICON_SET . 'buy_free.png', $action, $hidden);
 }
Exemplo n.º 17
-6
 public function execute()
 {
     $mp = Module_Payment::instance();
     if (false === ($gwf_token = Common::getPost('gwf_token'))) {
         return $mp->error('err_token');
     }
     if (false === ($order = GWF_Order::getByToken($gwf_token))) {
         return $mp->error('err_order');
     }
     if ($order->isProcessed()) {
         return $mp->message('err_already_done');
     }
     if (!$order->isCreated()) {
         return $mp->error('err_order');
     }
     /* Gather the information to make the final call to
     		finalize the PayPal payment.  The variable nvpstr
     		holds the name value pairs
     		*/
     if (false === ($resArray = @unserialize($order->getOrderXToken()))) {
         return $mp->error('err_xtoken', $this->module->getSiteName());
     }
     $token = $resArray["TOKEN"];
     $paymentAmount = $order->getOrderPriceTotal();
     $paymentType = "Sale";
     $currCodeType = $order->getOrderCurrency();
     $payerID = urlencode($resArray["PAYERID"]);
     $serverName = urlencode($_SERVER['SERVER_NAME']);
     $order->saveVar('order_email', $resArray["EMAIL"]);
     $nvpstr = '&TOKEN=' . $token . '&PAYERID=' . $payerID . '&PAYMENTACTION=' . $paymentType . '&AMT=' . $paymentAmount . '&CURRENCYCODE=' . $currCodeType . '&IPADDRESS=' . $serverName;
     $nvpstr .= "&ITEMAMT=" . $paymentAmount . "&L_QTY0=1" . "&L_NAME0=" . urlencode($order->getOrderDescrAdmin()) . "&L_AMT0=" . $paymentAmount;
     /* Make the call to PayPal to finalize payment
        	If an error occured, show the resulting errors
        */
     $resArray = Paypal_Util::hash_call('DoExpressCheckoutPayment', $nvpstr);
     /* Display the API response back to the browser.
        If the response from PayPal was a success, display the response parameters'
        If the response was an error, display the errors received using APIError.php.
        */
     $ack = strtoupper($resArray["ACK"]);
     if ($ack != "SUCCESS") {
         return Paypal_Util::paypalError($resArray);
     }
     // Get Payment module;
     $mp = Module_Payment::instance();
     $module2 = $order->getOrderModule();
     $module2->onLoadLanguage();
     Paypal_Util::logResArray($resArray);
     $status = strtoupper($resArray['PAYMENTSTATUS']);
     if ($status === 'COMPLETED') {
         return $mp->onExecuteOrder($module2, $order);
     } else {
         return $mp->onPendingOrder($module2, $order);
     }
 }