function process_button()
 {
     global $order;
     $last_order_id = tep_db_query("select orders_id from " . TABLE_ORDERS . " order by orders_id desc limit 1");
     $result = tep_db_fetch_array($last_order_id);
     $this->orderID = $result['orders_id'] + 1;
     $acceptURL = tep_href_link(FILENAME_CHECKOUT_PROCESS, 'referer=mokejimai', 'SSL');
     $cancelURL = tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL');
     $callbackURL = tep_href_link('mokejimai_validation.php', '', 'SSL', false, false, true);
     $acceptURL = str_replace('&', '&', $acceptURL);
     $cancelURL = str_replace('&', '&', $cancelURL);
     $callbackURL = str_replace('&', '&', $callbackURL);
     try {
         $request = WebToPay::buildRequest(array('projectid' => $this->projectID, 'sign_password' => $this->projectPass, 'orderid' => $this->orderID, 'amount' => intval(number_format($order->info['total'], 2, '', '')), 'currency' => $order->info['currency'], 'lang' => substr($_SESSION['language'], 0, 2) !== 'lt' ? 'ENG' : 'LTU', 'accepturl' => $acceptURL, 'cancelurl' => $cancelURL, 'callbackurl' => $callbackURL, 'country' => 'LT', 'logo' => '', 'p_firstname' => $order->customer['firstname'], 'p_lastname' => $order->customer['lastname'], 'p_email' => $order->customer['email_address'], 'p_street' => $order->customer['street_address'], 'p_city' => $order->customer['city'], 'p_state' => $order->customer['state'], 'p_zip' => $order->customer['postcode'], 'p_countrycode' => $order->customer['country']['iso_code_2'], 'test' => $this->testMode));
     } catch (WebToPayException $e) {
         echo get_class($e) . ': ' . $e->getMessage();
     }
     $html = '';
     if ($request) {
         foreach ($request as $key => $value) {
             $html .= tep_draw_hidden_field($key, $value);
         }
     }
     return $html;
 }
예제 #2
0
 /**
  * Init single payment call to webservice
  * Invoice id is passed via notify_url
  *
  * @return string
  */
 public function singlePayment(Payment_Invoice $invoice)
 {
     $buyer = $invoice->getBuyer();
     return WebToPay::buildRequest(array('projectid' => $this->getParam('projectid'), 'sign_password' => $this->getParam('sign_password'), 'orderid' => $invoice->getNumber(), 'amount' => $this->moneyFormat($invoice->getTotalWithTax()), 'currency' => $invoice->getCurrency(), 'accepturl' => $this->getParam('return_url'), 'cancelurl' => $this->getParam('cancel_url'), 'callbackurl' => $this->getParam('notify_url'), 'paytext' => $invoice->getTitle(), 'p_firstname' => $buyer->getFirstName(), 'p_lastname' => $buyer->getLastName(), 'p_email' => $buyer->getEmail(), 'p_street' => $buyer->getAddress(), 'p_city' => $buyer->getCity(), 'p_state' => $buyer->getState(), 'p_zip' => $buyer->getZip(), 'p_countrycode' => $buyer->getCountry(), 'lang' => 'ENG', 'test' => $this->testMode));
 }
 /**
  * Exception should be thrown if project id is not given
  *
  * @expectedException WebToPayException
  */
 public function testBuildRequestWithoutProjectId()
 {
     WebToPay::buildRequest(array('orderid' => '123', 'accepturl' => 'http://local.test/accept', 'cancelurl' => 'http://local.test/cancel', 'callbackurl' => 'http://local.test/callback', 'sign_password' => 'asdfghjkl'));
 }
예제 #4
0
 function process_payment($order_id)
 {
     global $woocommerce;
     $order = new WC_Order($order_id);
     if ($this->log) {
         $this->log->add('paysera', 'Generating payment form for order #' . $order_id . '. Notify URL: ' . trailingslashit(home_url()) . '?payseraListener=paysera_callback');
     }
     $request = WebToPay::buildRequest(array('projectid' => $this->projectid, 'sign_password' => $this->password, 'orderid' => $order->id, 'amount' => intval(number_format($order->get_total(), 2, '', '')), 'currency' => get_woocommerce_currency(), 'country' => $order->billing_country, 'accepturl' => esc_url(add_query_arg('utm_nooverride', '1', $this->get_return_url($order))), 'cancelurl' => $order->get_cancel_order_url(), 'callbackurl' => trailingslashit(get_bloginfo('wpurl')) . '?wc-api=wc_gateway_paysera', 'p_firstname' => $order->billing_first_name, 'p_lastname' => $order->billing_last_name, 'p_email' => $order->billing_email, 'p_street' => $order->billing_address_1, 'p_city' => $order->billing_city, 'p_state' => $order->billing_state, 'p_zip' => $order->billing_postcode, 'p_countrycode' => $order->billing_country, 'test' => $this->test == "yes"));
     $url = WebToPay::PAY_URL . '?' . http_build_query($request);
     $url = preg_replace('/[\\r\\n]+/is', '', $url);
     return array('result' => 'success', 'redirect' => $url);
 }
 /**
  * Prepares and returns necessary data, passed to the payment gateway.
  *
  * @ not all data is defined
  */
 function getConfirmationData($orderId)
 {
     global $application;
     loadCoreFile('aal.class.php');
     $request = new Request();
     $request->setView(CURRENT_REQUEST_URL);
     $request->setAction("UpdatePaymentStatus");
     $request->setKey("asc_oid", $orderId);
     $self_link = $request->getURL("", true);
     $currency_id = modApiFunc("Localization", "whichCurrencySendOrderToPaymentShippingGatewayIn", $orderId, $this->getUid());
     $currency = modApiFunc("Localization", "getCurrencyCodeById", $currency_id);
     $ocntr = modApiFunc("Location", "getCountryCode", modApiFunc("Configuration", "getValue", SYSCONFIG_STORE_OWNER_COUNTRY));
     $bn_code = "PentasoftCorp_Cart_WPS_" . $ocntr;
     $orderInfo = modApiFunc("Checkout", "getOrderInfo", $orderId, $currency_id);
     $discount = $this->export_PRICE_N_A(modApiFunc("Checkout", "getOrderPrice", "DiscountsSum", $currency_id));
     $amount = $this->export_PRICE_N_A(modApiFunc("Checkout", "getOrderPrice", "Subtotal", $currency_id) - $discount);
     $moduleData = $this->getSettings();
     require_once 'libwebtopay/WebToPay.php';
     try {
         $buildRequest = WebToPay::buildRequest(array('projectid' => $moduleData['MODULE_METHOD_ID'], 'sign_password' => $moduleData['MODULE_METHOD_PASS'], 'orderid' => $orderInfo['ID'], 'amount' => intval(number_format($orderInfo['Total'], 2, '', '')), 'currency' => $currency, 'accepturl' => $self_link . "&status=return", 'cancelurl' => $self_link . "&status=cancel", 'callbackurl' => $self_link . "&status=notify", 'payment' => '', 'country' => 'LT', 'logo' => '', 'p_firstname' => $orderInfo['Billing']['attr']['Firstname']['value'], 'p_lastname' => $orderInfo['Billing']['attr']['Lastname']['value'], 'p_email' => $orderInfo['Billing']['attr']['Email']['value'], 'p_street' => $orderInfo['Billing']['attr']['Streetline1']['value'] . ' ' . $orderInfo['Billing']['attr']['Streetline2']['value'], 'p_city' => $orderInfo['Billing']['attr']['City']['value'], 'p_zip' => $orderInfo['Billing']['attr']['Postcode']['value'], 'test' => $moduleData['MODULE_MODE']));
     } catch (WebToPayException $e) {
         echo get_class($e) . ': ' . $e->getMessage();
     }
     $acceptURL = str_replace('&', '&', $buildRequest['accepturl']);
     $cancelURL = str_replace('&', '&', $buildRequest['cancelurl']);
     $callbackURL = str_replace('&', '&', $buildRequest['callbackurl']);
     $confirmationData = array("FormAction" => WebToPay::PAY_URL, "FormMethod" => "POST", "DataFields" => array('projectid' => $buildRequest['projectid'], 'orderid' => $buildRequest['orderid'], 'amount' => $buildRequest['amount'], 'currency' => $buildRequest['currency'], 'lang' => $buildRequest['lang'], 'accepturl' => $buildRequest['accepturl'], 'cancelurl' => $buildRequest['cancelurl'], 'callbackurl' => $buildRequest['callbackurl'], 'payment' => $buildRequest['payment'], 'country' => $buildRequest['country'], 'p_firstname' => $buildRequest['p_firstname'], 'p_lastname' => $buildRequest['p_lastname'], 'p_email' => $buildRequest['p_email'], 'p_street' => $buildRequest['p_street'], 'p_city' => $buildRequest['p_city'], 'p_zip' => $buildRequest['p_zip'], 'test' => $buildRequest['test'], 'version' => $buildRequest['version'], 'sign' => $buildRequest['sign']));
     //=========================== logging request ========================
     $msgObj = $application->getInstance("MessageResources", "payment-module-paypal-messages", "AdminZone");
     $title = $msgObj->getMessage("MODULE_PAYMENT_TIMELINE_HEADER_CONFIRMATION_DATA");
     $title = str_replace('{ORDER_ID}', $orderId, $title);
     $this->addRequestLog("LOG_PM_INPUT", "Payment Module Logs", $title, prepareArrayDisplay($confirmationData));
     //=========================== logging request ========================
     return $confirmationData;
 }