Exemplo n.º 1
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.º 2
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.º 3
-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);
     }
 }