public function execute() { if (false === ($order = GWF_Order::getByToken(Common::getPostString('gwf_token')))) { return $this->module->error('err_order'); } if (!$order->isCreated()) { return $this->module->error('err_order'); } $gdo = $order->getOrderData(); $user = $order->getOrderUser(); # GWF_User::getStaticOrGuest(); /* The servername and serverport tells PayPal where the buyer should be directed back to after authorizing payment. In this case, its the local webserver that is running this script Using the servername and serverport, the return URL is the first portion of the URL that buyers will return to after authorizing payment */ /* The returnURL is the location where buyers return when a payment has been succesfully authorized. The cancelURL is the location buyers are sent to when they hit the cancel button during authorization of payment during the PayPal flow */ $successURL = urlencode($this->get2ndStepURL($order, $gdo)); $cancelURL = urlencode(Common::getAbsoluteURL($gdo->getOrderCancelURL($user), false)); $shipping = $gdo->needsShipping($user) ? '0' : '1'; /* Construct the parameter string that describes the PayPal payment the varialbes were set in the web form, and the resulting string is stored in $nvpstr */ $paymentAmount = $order->getOrderPriceTotal(2); $paymentType = "Sale"; $currencyCodeType = $order->getOrderCurrency(); $nvpstr = "&Amt={$paymentAmount}" . "&PAYMENTACTION={$paymentType}" . "&ReturnUrl={$successURL}" . "&CANCELURL={$cancelURL}" . "&CURRENCYCODE={$currencyCodeType}" . "&no_shipping={$shipping}" . "&LOCALECODE=" . strtoupper(GWF_Language::getCurrentISO()); // var_dump($nvpstr); /* Make the call to PayPal to set the Express Checkout token If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment. If an error occured, show the resulting errors */ $resArray = Paypal_Util::hash_call('SetExpressCheckout', $nvpstr); // var_dump($resArray); $ack = strtoupper($resArray["ACK"]); if ($ack == "SUCCESS") { // Redirect to paypal.com here $token = urldecode($resArray["TOKEN"]); if (false === $order->saveVar('order_xtoken', $token)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } $payPalURL = PAYPAL_URL . $token; header("Location: " . $payPalURL); echo 'The browser should redirect you to: ' . $payPalURL . PHP_EOL; die; } else { return Paypal_Util::paypalError($resArray); } }
public function execute(GWF_Module $module) { if (false === ($order = GWF_Order::getByToken(Common::getPost('gwf_token')))) { return $module->error('err_order'); } if (!$order->isCreated()) { return $module->error('err_order'); } return $this->onPay($module, $order); }
public function execute(GWF_Module $module) { if (false === ($order = GWF_Order::getByToken(Common::getPost('gwf_token')))) { return $module->error('err_order'); } if (!$order->isCreated()) { return $module->error('err_order'); } if ($order->getOrderPriceTotal() > 0) { return GWF_HTML::err('ERR_NO_PERMISSION'); } if (false !== Common::getPost('pay_x')) { return $this->onPay($module, $order); } return $this->templatePay($module, $order); }
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); }
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); } }
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); } }