Beispiel #1
0
 private function templatePay(Module_PaymentBank $module, GWF_Order $order)
 {
     if (false === $order->saveVar('order_status', GWF_Order::ORDERED)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $tVars = array('lang' => $module->loadLangGWF(), 'order_c' => $order);
     return $module->templatePHP('pay2.php', $tVars);
     //
     //		$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);
 }
 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);
 }
Beispiel #3
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))));
 }
Beispiel #4
0
 public function execute()
 {
     if (false === ($order = GWF_Order::getByID(Common::getGet('oid')))) {
         return $this->module->error('err_order');
     }
     if (false !== Common::getGet('mark_paid')) {
         return $this->onMarkPaid($order) . $this->templateOrder($order);
         #FIXME: {gizmore} method does not exists
     }
     if (false !== Common::getPost('exec')) {
         return $this->onExecute($order) . $this->templateOrder($order);
     }
     if (false !== Common::getPost('edit')) {
         return $this->onEdit($order) . $this->templateOrder($order);
     }
     return $this->templateOrder($order);
 }
Beispiel #5
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);
 }
Beispiel #6
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);
 }
Beispiel #7
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);
     }
 }
Beispiel #8
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);
 }
Beispiel #9
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);
 }
Beispiel #10
0
 private function get2ndStepURL(GWF_Order $order, GWF_Orderable $gdo)
 {
     return Common::getAbsoluteURL('index.php?mo=PaymentPaypal&me=ConfirmCheckout&gwf_token=' . $order->getOrderToken());
     //		return 'i_paid_with_paypal_for/'.$order->escape('order_title').'/'.$order->getOrderToken();
 }
Beispiel #11
0
 private function getHiddenData(GWF_Module $module, GWF_Order $order, GWF_Orderable $gdo, GWF_User $user)
 {
     return GWF_Form::hidden('gwf_token', $order->getOrderToken());
 }
Beispiel #12
0
 private function logCriticalError(GWF_Module $module, GWF_Order $order)
 {
     $message = $this->error('err_crit', $order->getOrderToken());
     GWF_Log::logCritical($message);
     GWF_Website::addDefaultOutput($message);
     return '';
 }
Beispiel #13
0
 private function tinyCaptchaForm(Module_PaymentFree $module, GWF_Order $order)
 {
     $data = array('captcha' => array(GWF_Form::CAPTCHA), 'gwf_token' => array(GWF_Form::HIDDEN, $order->getOrderToken()), 'pay' => array(GWF_Form::SUBMIT_IMG, 'free_pay'));
     return new GWF_Form($this, $data);
 }
Beispiel #14
-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);
     }
 }