コード例 #1
1
 public function process()
 {
     // Prepare "Response page signature"
     $response_sig = $this->ipay88->iPay88_signature(Configuration::get('MKEY') . Configuration::get('MCODE') . $_REQUEST['PaymentId'] . $_REQUEST['RefNo'] . number_format(str_replace(".", "", $_REQUEST['Amount']), 2, '', '') . $this->context->currency->iso_code . $_REQUEST['Status']);
     $this->_logToFile(_LOG_DIR_ . '/backendpost-' . date("Y-m-d") . '.log', $response_sig);
     $this->_logToFile(_LOG_DIR_ . '/backendpost-' . date("Y-m-d") . '.log', $_REQUEST['Signature']);
     // If Response page signature match
     if ($response_sig == $_REQUEST['Signature']) {
         // Check if the order is successful
         if ($_REQUEST['Status'] == "1") {
             $cart = $this->context->cart;
             if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
                 Tools::redirect('index.php?controller=order&step=1');
             }
             // Check this payment option is still available in case the customer changed his address just before the end of the checkout process
             $authorized = false;
             foreach (Module::getPaymentModules() as $module) {
                 if ($module['name'] == 'ipay88') {
                     $authorized = true;
                     break;
                 }
             }
             if (!$authorized) {
                 die($this->module->l('This payment method is not available.', 'validation'));
             }
             $customer = new Customer($cart->id_customer);
             if (!Validate::isLoadedObject($customer)) {
                 Tools::redirect('index.php?controller=order&step=1');
             }
             $currency = $this->context->currency;
             $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
             $this->module->validateOrder($cart->id, Configuration::get('PS_OS_PAYMENT'), $total, $this->module->displayName, NULL, null, (int) $currency->id, false, $customer->secure_key);
         } else {
             $this->_logToFile(_LOG_DIR_ . '/backendpost.log', 'Sorry, processing your order is unsuccessful due to an error. Please contact our support team.');
         }
         echo "RECEIVEOK";
         $this->_logToFile(_LOG_DIR_ . '/backendpost.log', 'RECEIVEOK');
         die;
     } else {
         echo "RECEIVEOK";
         $this->_logToFile(_LOG_DIR_ . '/backendpost.log', 'Generated signature and Requested signature mismatch.');
         die('Generated signature and Requested signature mismatch.');
     }
 }
コード例 #2
0
 public function postProcess()
 {
     if ($this->context->cart->id_customer == 0 || $this->context->cart->id_address_delivery == 0 || $this->context->cart->id_address_invoice == 0 || !$this->module->active) {
         Tools::redirectLink(__PS_BASE_URI__ . 'order.php?step=1');
     }
     // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'cashondelivery') {
             $authorized = true;
             break;
         }
     }
     //		if (!$authorized)
     //			die(Tools::displayError('This payment method is not available.'));
     $customer = new Customer($this->context->cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirectLink(__PS_BASE_URI__ . 'order.php?step=1');
     }
     if (Tools::getValue('confirm')) {
         $customer = new Customer((int) $this->context->cart->id_customer);
         $total = $this->context->cart->getOrderTotal(true, Cart::BOTH);
         $this->module->validateOrder((int) $this->context->cart->id, Configuration::get('PS_OS_PREPARATION'), $total, $this->module->displayName, null, array(), null, false, $customer->secure_key);
         Tools::redirectLink(__PS_BASE_URI__ . 'order-confirmation.php?key=' . $customer->secure_key . '&id_cart=' . (int) $this->context->cart->id . '&id_module=' . (int) $this->module->id . '&id_order=' . (int) $this->module->currentOrder);
     }
 }
コード例 #3
0
 /**
  * @see FrontController::postProcess()
  */
 public function postProcess()
 {
     if ($this->context->cart->id_customer == 0 || $this->context->cart->id_address_delivery == 0 || $this->context->cart->id_address_invoice == 0 || !$this->module->active) {
         Tools::redirectLink(__PS_BASE_URI__ . 'order.php?step=1');
     }
     // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'seurcashondelivery') {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         die(Tools::displayError('This payment method is not available.'));
     }
     $customer = new Customer((int) $this->context->cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirectLink(__PS_BASE_URI__ . 'order.php?step=1');
     }
     if (Tools::getValue('confirm')) {
         $customer = new Customer((int) $this->context->cart->id_customer);
         $coste = (double) abs($this->context->cart->getOrderTotal(true, Cart::BOTH));
         $cargo = number_format($this->module->getCargo($this->context->cart, false), 2, '.', '');
         $vales = (double) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS));
         $total = $coste - $vales + $cargo;
         if (version_compare(_PS_VERSION_, "1.5", "<")) {
             $this->module->validateOrderFORWEBS_v4((int) $this->context->cart->id, Configuration::get('REEMBOLSO_OS_CARGO'), $total, $this->module->displayName, null, array(), null, false, $customer->secure_key);
         } else {
             $this->module->validateOrderFORWEBS_v5((int) $this->context->cart->id, Configuration::get('REEMBOLSO_OS_CARGO'), $total, $this->module->displayName, null, array(), null, false, $customer->secure_key);
         }
         Tools::redirectLink(__PS_BASE_URI__ . 'order-confirmation.php?key=' . urlencode($customer->secure_key) . '&id_cart=' . (int) $this->context->cart->id . '&id_module=' . (int) $this->module->id . '&id_order=' . (int) $this->module->currentOrder);
     }
 }
コード例 #4
0
 /**
  * @see FrontController::postProcess()
  */
 public function postProcess()
 {
     // if status == "success"
     $cart = $this->context->cart;
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'tinklit') {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         die($this->module->l('This payment method is not available.', 'validation'));
     }
     $customer = new Customer($cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     $currency = $this->context->currency;
     $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
     $mailVars = array();
     Tools::redirect('index.php?controller=order-confirmation&id_cart=' . (int) $cart->id . '&id_module=' . (int) $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key);
 }
コード例 #5
0
ファイル: validation.php プロジェクト: dev-lav/htdocs
 public function postProcess()
 {
     $cart = $this->context->cart;
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'cheque') {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         die($this->module->l('This payment method is not available.', 'validation'));
     }
     $customer = new Customer($cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     $currency = $this->context->currency;
     $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
     $mailVars = array('{cheque_name}' => Configuration::get('CHEQUE_NAME'), '{cheque_address}' => Configuration::get('CHEQUE_ADDRESS'), '{cheque_address_html}' => str_replace("\n", '<br />', Configuration::get('CHEQUE_ADDRESS')));
     $this->module->validateOrder((int) $cart->id, Configuration::get('PS_OS_CHEQUE'), $total, $this->module->displayName, NULL, $mailVars, (int) $currency->id, false, $customer->secure_key);
     Tools::redirect('index.php?controller=order-confirmation&id_cart=' . (int) $cart->id . '&id_module=' . (int) $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key);
 }
コード例 #6
0
 /**
  * @see FrontController::postProcess()
  */
 public function postProcess()
 {
     $cart = $this->context->cart;
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'bankpermata') {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         die($this->module->getTranslator()->trans('This payment method is not available.', array(), 'Modules.BankPermata.Shop'));
     }
     $customer = new Customer($cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     $currency = $this->context->currency;
     $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
     $mailVars = array('{bankpermata_owner}' => Configuration::get('BANK_PERMATA_OWNER'), '{bankpermata_details}' => nl2br(Configuration::get('BANK_PERMATA_DETAILS')), '{bankpermata_address}' => nl2br(Configuration::get('BANK_PERMATA_ADDRESS')));
     $this->module->validateOrder($cart->id, Configuration::get('PS_OS_BANKPERMATA'), $total, $this->module->displayName, NULL, $mailVars, (int) $currency->id, false, $customer->secure_key);
     Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $cart->id . '&id_module=' . $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key);
 }
コード例 #7
0
 /**
  * @see FrontController::postProcess()
  */
 public function postProcess()
 {
     $cart = $this->context->cart;
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'paymentexample') {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         die($this->module->l('This payment method is not available.', 'validation'));
     }
     $this->context->smarty->assign(['params' => $_REQUEST]);
     $this->setTemplate('payment_return.tpl');
     // $customer = new Customer($cart->id_customer);
     // if (!Validate::isLoadedObject($customer))
     //     Tools::redirect('index.php?controller=order&step=1');
     // $currency = $this->context->currency;
     // $total = (float)$cart->getOrderTotal(true, Cart::BOTH);
     // $mailVars = array(
     //     '{bankwire_owner}' => Configuration::get('BANK_WIRE_OWNER'),
     //     '{bankwire_details}' => nl2br(Configuration::get('BANK_WIRE_DETAILS')),
     //     '{bankwire_address}' => nl2br(Configuration::get('BANK_WIRE_ADDRESS'))
     // );
     // $this->module->validateOrder($cart->id, Configuration::get('PS_OS_BANKWIRE'), $total, $this->module->displayName, NULL, $mailVars, (int)$currency->id, false, $customer->secure_key);
     // Tools::redirect('index.php?controller=order-confirmation&id_cart='.$cart->id.'&id_module='.$this->module->id.'&id_order='.$this->module->currentOrder.'&key='.$customer->secure_key);
 }
コード例 #8
0
 /**
  * @see FrontController::postProcess()
  */
 public function postProcess()
 {
     $cart = $this->context->cart;
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'swipp') {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         die($this->module->l('This payment method is not available.', 'validation'));
     }
     $customer = new Customer($cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     $currency = $this->context->currency;
     $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
     $mailVars = array('{swipp_phone}' => Configuration::get('SWIPP_PHONE'), '{swipp_owner}' => Configuration::get('SWIPP_OWNER'), '{swipp_payment_dkk}' => Tools::displayPrice($this->module->__getPriceDkk($cart), (int) Currency::getIdByIsoCode('DKK')));
     $this->module->validateOrder($cart->id, Configuration::get('SWIPP_PAYMENT_STATE'), $total, $this->module->displayName, NULL, $mailVars, (int) $currency->id, false, $customer->secure_key);
     Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $cart->id . '&id_module=' . $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key);
 }
コード例 #9
0
 public function postProcess()
 {
     // Check if cart exists and all fields are set
     $cart = $this->context->cart;
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // Check if module is enabled
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == $this->module->name) {
             $authorized = true;
         }
     }
     if (!$authorized) {
         die('This payment method is not available.');
     }
     // Check if customer exists
     $customer = new Customer($cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // Set datas
     $currency = $this->context->currency;
     $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
     $extra_vars = array('{total_to_pay}' => Tools::displayPrice($total), '{cheque_order}' => Configuration::get('MYMOD_CH_ORDER'), '{cheque_address}' => Configuration::get('MYMOD_CH_ADDRESS'), '{bankwire_details}' => Configuration::get('MYMOD_BA_DETAILS'), '{bankwire_owner}' => Configuration::get('MYMOD_BA_OWNER'));
     // Validate order
     $this->module->validateOrder($cart->id, Configuration::get('PS_OS_MYMOD_PAYMENT'), $total, $this->module->displayName, NULL, $extra_vars, (int) $currency->id, false, $customer->secure_key);
     // Redirect on order confirmation page
     Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $cart->id . '&id_module=' . $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key);
 }
コード例 #10
0
 private function verifyPaymentOptionAvailability()
 {
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'pagseguro') {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         die($this->module->l('Este método de pagamento não está disponível', 'validation'));
     }
 }
コード例 #11
0
 public function postProcess()
 {
     $cart = $this->context->cart;
     $invoice = new Address((int) $cart->id_address_invoice);
     $customer = new Customer($cart->id_customer);
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'debitnote') {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         die($this->module->l('This payment method is not available.', 'validation'));
     }
     $accountholder_name = $_POST['accountholder_name'];
     $account_number = $_POST['account_number'];
     $bank_code = $_POST['bank_code'];
     $bank_name = $_POST['bank_name'];
     $bank_bic = $_POST['bank_bic'];
     $bank_iban = $_POST['bank_iban'];
     $ip_address = $_POST['ip_address'];
     // Getting differents vars
     $context = Context::getContext();
     $id_lang = (int) $context->language->id;
     $id_shop = (int) $context->shop->id;
     if (!$context) {
         $context = Context::getContext();
     }
     $order = new Order($this->id_order);
     //$order = $params['order'];
     //$configuration = Configuration::getMultiple(array('PS_SHOP_EMAIL', 'PS_MAIL_METHOD', 'PS_MAIL_SERVER', 'PS_MAIL_USER', 'PS_MAIL_PASSWD', 'PS_SHOP_NAME', 'PS_MAIL_COLOR'), $id_lang, null, $id_shop);
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     if (!Validate::isLoadedObject($invoice)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     $currency = $this->context->currency;
     $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
     $message = 'Kontoinhaber:' . $accountholder_name . '<br>' . '  Kto:' . $account_number . '  BLZ:' . $bank_code . '  Bank:' . $bank_name . '  BIC:' . $bank_bic . '  IBAN:' . $bank_iban;
     //Mail Vars für Kunden Mail debitnote.html
     $mailVars = array('{bankwire_owner}' => Configuration::get('BANK_WIRE_OWNER'), '{bankwire_details}' => nl2br(Configuration::get('BANK_WIRE_DETAILS')), '{bankwire_address}' => nl2br(Configuration::get('BANK_WIRE_ADDRESS')), '{email}' => $this->context->customer->email, '{date}' => Tools::displayDate(date('Y-m-d H:i:s'), null, 0), '{invoice_company}' => $invoice->company, '{invoice_firstname}' => $invoice->firstname, '{invoice_lastname}' => $invoice->lastname, '{invoice_address2}' => $invoice->address1, '{invoice_address1}' => $invoice->address2, '{invoice_city}' => $invoice->city, '{invoice_postal_code}' => $invoice->postcode, '{invoice_country}' => $invoice->country, '{BankBIC}' => $bank_bic, '{BankIBAN}' => $bank_iban, '{Debit_identifier}' => Configuration::get('DEBITNOTE_CREDITOR_IDENTIFIER'), '{shop_name}' => Configuration::get('PS_SHOP_NAME'), '{shop_address1}' => Configuration::get('PS_SHOP_ADDR1'), '{shop_address2}' => Configuration::get('PS_SHOP_ADDR2'), '{shop_plz}' => Configuration::get('PS_SHOP_CODE'), '{shop_city}' => Configuration::get('PS_SHOP_CITY'));
     $this->module->validateOrder((int) $cart->id, Configuration::get('PS_OS_DEBITNOTE'), $total, $this->module->displayName, $message, $mailVars, (int) $currency->id, false, $customer->secure_key);
     $this->module->writeDebitNoteDetails($this->module->currentOrder, $accountholder_name, $account_number, $bank_code, $bank_name, $bank_bic, $bank_iban, '123');
     Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $cart->id . '&id_module=' . $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key);
 }
コード例 #12
0
ファイル: validation.php プロジェクト: Edamaru/universalpay
 public function postProcess()
 {
     $cart = $this->context->cart;
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'universalpay') {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         die($this->module->l('This payment method is not available.', 'validation'));
     }
     $customer = new Customer($cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     $currency = $this->context->currency;
     $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
     require_once dirname(__FILE__) . '/../../classes/UniPaySystem.php';
     $paysistem = new UniPaySystem((int) Tools::getValue('id_universalpay_system'), $this->context->cookie->id_lang);
     if (!Validate::isLoadedObject($paysistem)) {
         return;
     }
     $up_fields = array();
     foreach ($_POST as $key => $val) {
         $key_parts = explode('_', $key);
         if ($key_parts[0] == 'up') {
             $up_fields[$key_parts[1]] = $val;
         }
     }
     $mail_vars = array('{paysistem_name}' => $paysistem->name);
     foreach ($up_fields as $key => $val) {
         $mail_vars['{up_' . $key . '}'] = $val;
     }
     $this->module->validateOrder((int) $cart->id, $paysistem->id_order_state, $total, $paysistem->name, null, $mail_vars, (int) $currency->id, false, $customer->secure_key);
     require_once dirname(__FILE__) . '/../../classes/UpOrder.php';
     $order = new UpOrder($this->module->currentOrder);
     if (count($up_fields)) {
         $order->setUpFields($up_fields);
         $order->save();
     }
     Tools::redirect('index.php?controller=order-confirmation&id_cart=' . (int) $cart->id . '&id_module=' . (int) $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key . '&id_universalpay_system=' . $paysistem->id);
 }
コード例 #13
0
 public function initContent()
 {
     $this->display_column_left = false;
     parent::initContent();
     $this->ipay88 = new iPay88();
     if (isset($_REQUEST['Status'])) {
         // Prepare "Response page signature"
         $response_sig = $this->ipay88->iPay88_signature(Configuration::get('MKEY') . Configuration::get('MCODE') . $_REQUEST['PaymentId'] . $this->context->cart->id . number_format(str_replace(".", "", $this->context->cart->getOrderTotal(true, Cart::BOTH)), 2, '', '') . $this->context->currency->iso_code . $_REQUEST['Status']);
         // If Response page signature match
         if ($response_sig == $_REQUEST['Signature']) {
             // Check if the order is successful
             if ($_REQUEST['Status'] == "1") {
                 $cart = $this->context->cart;
                 if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
                     Tools::redirect('index.php?controller=order&step=1');
                 }
                 // Check this payment option is still available in case the customer changed his address just before the end of the checkout process
                 $authorized = false;
                 foreach (Module::getPaymentModules() as $module) {
                     if ($module['name'] == 'ipay88') {
                         $authorized = true;
                         break;
                     }
                 }
                 if (!$authorized) {
                     die($this->module->l('This payment method is not available.', 'validation'));
                 }
                 $customer = new Customer($cart->id_customer);
                 if (!Validate::isLoadedObject($customer)) {
                     Tools::redirect('index.php?controller=order&step=1');
                 }
                 $currency = $this->context->currency;
                 $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
                 $this->module->validateOrder($cart->id, Configuration::get('PS_OS_PAYMENT'), $total, $this->module->displayName, NULL, null, (int) $currency->id, false, $customer->secure_key);
                 Tools::redirect('index.php?controller=history');
             } else {
                 $this->context->smarty->assign(array('unsuccessful' => 'Sorry, processing your order is unsuccessful due to an error. Please contact our support team.'));
             }
         } else {
             $this->context->smarty->assign(array('mismatched' => 'Sorry, response signature mismatched.'));
         }
         $this->context->smarty->assign(array('status' => $_REQUEST['ErrDesc']));
     }
     $this->setTemplate('receive.tpl');
 }
コード例 #14
0
 public function postProcess()
 {
     $cart = $this->context->cart;
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // Check that this payment option is still available
     // in case the customer changed his address
     // just before the end of the checkout process
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'cashway') {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         die($this->module->l('This payment method is not available.', 'validation'));
     }
     $customer = new Customer($cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     $currency = $this->context->currency;
     $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
     $cw_currency = $this->module->getCurrency((int) $this->context->cart->id_currency);
     $cashway = CashWay::getCashWayAPI();
     $cashway->setOrder('prestashop', null, $this->context->cart, $this->context->customer, $this->context->language->iso_code, $cw_currency[0]['iso_code']);
     $cw_res = $cashway->openTransaction();
     $available = array(true, '');
     if (array_key_exists('errors', $cw_res)) {
         $available = array(false, $cw_res['errors'][0]['code']);
         $cw_barcode = '-failed-';
     } else {
         $cw_barcode = $cw_res['barcode'];
     }
     $mail_vars = array('{barcode}' => $cw_barcode);
     if ($cw_barcode != '-failed-') {
         $this->module->validateOrder((int) $cart->id, Configuration::get('PS_OS_CASHWAY'), $total, $this->module->displayName, null, $mail_vars, (int) $currency->id, false, $customer->secure_key);
     }
     Tools::redirect('index.php?controller=order-confirmation&id_cart=' . (int) $cart->id . '&id_module=' . (int) $this->module->id . '&id_order=' . $this->module->currentOrder . '&cw_barcode=' . $cw_barcode . '&key=' . $customer->secure_key);
 }
コード例 #15
0
 public function postProcess()
 {
     $cart = $this->context->cart;
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'invipaypaygate') {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         die($this->module->l('This payment method is not available.', 'validation'));
     }
     $validationErrors = $this->helper->validateCart($cart);
     if (count($validationErrors) > 0) {
         Tools::redirect('index.php?controller=order');
     }
     $virtual_product_id = $this->helper->addPaymentMethodCostVirtualItemToCart($cart);
     $customer = new Customer($cart->id_customer);
     $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
     // Saves order to database
     $config = $this->helper->loadConfiguration();
     $title = $config['PAYMENT_METHOD_TITLE'];
     if ($this->module->validateOrder($cart->id, Configuration::get(InvipaypaygateHelper::ORDER_STATUS_PAYMENT_STARTED), $total, $title, NULL, NULL, $cart->id_currency, false, $customer->secure_key)) {
         $this->helper->removePaymentMethodCostVirtualItem($virtual_product_id);
         try {
             $order = new Order(Order::getOrderByCartId($cart->id));
             $redirectUrl = $this->helper->startPaymentRequest($cart, $order);
             Tools::redirect($redirectUrl);
         } catch (Exception $ex) {
             Tools::redirect($this->context->link->getModuleLink('invipaypaygate', 'error') . '?msg=' . base64_encode($ex->getMessage()));
             return;
         }
     } else {
         Tools::redirect('index.php?controller=order');
     }
 }
コード例 #16
0
 /**
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $cart = $this->context->cart;
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'paynetz') {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         die($this->module->l('This payment method is not available.', 'validation'));
     }
     $customer = new Customer($cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     $currency = $this->context->currency;
     $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
     $mailVars = array();
     if ($_POST['f_code'] == "Ok") {
         $this->module->validateOrder($cart->id, Configuration::get('PS_OS_PAYMENT'), $total, $this->module->displayName, NULL, $mailVars, (int) $currency->id, false, $customer->secure_key);
         Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $cart->id . '&id_module=' . $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key);
     } else {
         $error_message = "Transaction is failed, Try again";
         $checkout_type = Configuration::get('PS_ORDER_PROCESS_TYPE') ? 'order-opc' : 'order';
         $url = _PS_VERSION_ >= '1.5' ? 'index.php?controller=' . $checkout_type . '&' : $checkout_type . '.php?';
         $url .= 'step=3&cgv=1&paynetzerror=1&message=' . $error_message;
         Tools::redirect($url);
         exit;
     }
 }
コード例 #17
0
ファイル: return.php プロジェクト: yiuked/tmcart
 public function postProcess()
 {
     $cart = new Cart(Tools::getValue('id_cart'));
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'weixinpay') {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         die($this->module->l('This payment method is not available.', 'validation'));
     }
     $customer = new Customer($cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     $id_order = Order::getOrderByCartId($cart->id);
     Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $cart->id . '&id_module=' . $this->module->id . '&id_order=' . $id_order . '&key=' . $customer->secure_key);
 }
コード例 #18
0
 /**
  * returns payment means of the shop in an array which have module ID in indice with module's name and FIA-NET payment type. 
  * 
  * @return array
  */
 private function loadPaymentMethods()
 {
     if (_PS_VERSION_ >= '1.5') {
         $payments = Module::getPaymentModules();
     } else {
         $payments = $this->getInstalledPaymentModules();
     }
     $payment_modules = array();
     foreach ($payments as $payment) {
         $module = Module::getInstanceById($payment['id_module']);
         $payment_modules[$payment['id_module']] = array('name' => $module->displayName, 'fianetsceau_type' => Configuration::get('FIANETSCEAU_' . $payment['id_module'] . '_PAYMENT_TYPE'));
     }
     return $payment_modules;
 }
コード例 #19
0
 public function execValidation($cart)
 {
     global $cookie;
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'veritranspay') {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         die($this->module->l('This payment method is not available.', 'validation'));
     }
     $customer = new Customer($cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     $usd = Configuration::get('VT_KURS');
     $cf = Configuration::get('VT_CONVENIENCE_FEE') * 0.01;
     $list_enable_payments = array();
     if (Configuration::get('ENABLED_CREDIT_CARD')) {
         $list_enable_payments[] = "credit_card";
     }
     if (Configuration::get('ENABLED_CIMB')) {
         $list_enable_payments[] = "cimb_clicks";
     }
     if (Configuration::get('ENABLED_MANDIRI')) {
         $list_enable_payments[] = "mandiri_clickpay";
     }
     if (Configuration::get('ENABLED_PERMATAVA')) {
         $list_enable_payments[] = "bank_transfer";
     }
     if (Configuration::get('ENABLED_BRIEPAY')) {
         $list_enable_payments[] = "bri_epay";
     }
     if (Configuration::get('ENABLED_TELKOMSEL_CASH')) {
         $list_enable_payments[] = "telkomsel_cash";
     }
     if (Configuration::get('ENABLED_XL_TUNAI')) {
         $list_enable_payments[] = "xl_tunai";
     }
     if (Configuration::get('ENABLED_MANDIRI_BILL')) {
         $list_enable_payments[] = "echannel";
     }
     if (Configuration::get('ENABLED_BBM_MONEY')) {
         $list_enable_payments[] = "bbm_money";
     }
     if (Configuration::get('ENABLED_INDOMARET')) {
         $list_enable_payments[] = "cstore";
     }
     if (Configuration::get('ENABLED_INDOSAT_DOMPETKU')) {
         $list_enable_payments[] = "indosat_dompetku";
     }
     if (Configuration::get('ENABLED_MANDIRI_ECASH')) {
         $list_enable_payments[] = "mandiri_ecash";
     }
     //error_log(print_r($list_enable_payments,TRUE));
     $veritrans = new Veritrans_Config();
     //SETUP
     Veritrans_Config::$serverKey = Configuration::get('VT_SERVER_KEY');
     Veritrans_Config::$isProduction = Configuration::get('VT_ENVIRONMENT') == 'production' ? true : false;
     $url = Veritrans_Config::getBaseUrl();
     if (version_compare(Configuration::get('PS_VERSION_DB'), '1.5') == -1) {
         $shipping_cost = $cart->getOrderShippingCost();
     } else {
         $shipping_cost = $cart->getTotalShippingCost();
     }
     $currency = new Currency($cookie->id_currency);
     $total = $cart->getOrderTotal(true, Cart::BOTH);
     $mailVars = array();
     $billing_address = new Address($cart->id_address_invoice);
     $delivery_address = new Address($cart->id_address_delivery);
     if (Configuration::get('VT_3D_SECURE') == 'on' || Configuration::get('VT_3D_SECURE') == 1) {
         Veritrans_Config::$is3ds = true;
     }
     if (Configuration::get('VT_SANITIZED') == 'on' || Configuration::get('VT_SANITIZED') == 1) {
         Veritrans_Config::$isSanitized = true;
     }
     //error_log('sanitized '.Configuration::get('VT_SANITIZED'));
     // Billing Address
     $params_billing_address = array('first_name' => $billing_address->firstname, 'last_name' => $billing_address->lastname, 'address' => $billing_address->address1, 'city' => $billing_address->city, 'postal_code' => $billing_address->postcode, 'phone' => $this->determineValidPhone($billing_address->phone, $billing_address->phone_mobile), 'country_code' => 'IDN');
     if ($cart->isVirtualCart()) {
     } else {
         if ($cart->id_address_delivery != $cart->id_address_invoice) {
             $params_shipping_address = array('first_name' => $delivery_address->firstname, 'last_name' => $delivery_address->lastname, 'address' => $delivery_address->address1, 'city' => $delivery_address->city, 'postal_code' => $delivery_address->postcode, 'phone' => $this->determineValidPhone($delivery_address->phone, $delivery_address->phone_mobile), 'country_code' => 'IDN');
         } else {
             $params_shipping_address = $params_billing_address;
         }
     }
     $params_customer_details = array('first_name' => $billing_address->firstname, 'last_name' => $billing_address->lastname, 'email' => $customer->email, 'phone' => $this->determineValidPhone($billing_address->phone, $billing_address->phone_mobile), 'billing_address' => $params_billing_address, 'shipping_address' => $params_shipping_address);
     $items = $this->addCommodities($cart, $shipping_cost, $usd);
     // convert the currency
     $cart_currency = new Currency($cart->id_currency);
     if ($cart_currency->iso_code != 'IDR') {
         // check whether if the IDR is installed or not
         if (Currency::exists('IDR', null)) {
             // use default rate
             if (version_compare(Configuration::get('PS_VERSION_DB'), '1.5') == -1) {
                 $conversion_func = function ($input) use($cart_currency) {
                     return Tools::convertPrice($input, new Currency(Currency::getIdByIsoCode('IDR')), true);
                 };
             } else {
                 $conversion_func = function ($input) use($cart_currency) {
                     return Tools::convertPriceFull($input, $cart_currency, new Currency(Currency::getIdByIsoCode('IDR')));
                 };
             }
         } else {
             // use rate
             $conversion_func = function ($input) {
                 return $input * intval(Configuration::get('VT_KURS'));
             };
         }
         foreach ($items as &$item) {
             $item['price'] = intval(round(call_user_func($conversion_func, $item['price'])));
         }
     } else {
         if ($cart_currency->iso_code == 'IDR') {
             foreach ($items as &$item) {
                 $item['price'] = intval(round($item['price']));
             }
         }
     }
     $this->validateOrder($cart->id, Configuration::get('VT_ORDER_STATE_ID'), $cart->getOrderTotal(true, Cart::BOTH), $this->displayName, NULL, $mailVars, (int) $currency->id, false, $customer->secure_key);
     $gross_amount = 0;
     unset($item);
     foreach ($items as $item) {
         $gross_amount += $item['price'] * $item['quantity'];
     }
     $isBniInstallment = Configuration::get('ENABLED_BNI_INSTALLMENT') == 1;
     $isMandiriInstallment = Configuration::get('ENABLED_MANDIRI_INSTALLMENT') == 1;
     $warning_redirect = false;
     $fullPayment = true;
     $installment_type_val = Configuration::get('VT_ENABLE_INSTALLMENT');
     $param_required;
     switch ($installment_type_val) {
         case 'all_product':
             if ($isBniInstallment) {
                 //$bni_term2 = $this->getTermInstallment('BNI');
                 $a = Configuration::get('VT_INSTALLMENTS_BNI');
                 $term = explode(',', $a);
                 $bni_term = $term;
                 //error_log(print_r($bni_term,true));
                 //error_log($bni_term,true);
             }
             if ($isMandiriInstallment) {
                 $mandiri_term = $this->getTermInstallment('MANDIRI');
                 $a = Configuration::get('VT_INSTALLMENTS_MANDIRI');
                 $term = explode(',', $a);
                 $mandiri_term = $term;
                 //error_log($mandiri_term,true);
                 //error_log(print_r($mandiri_term,true));
             }
             $param_installment = array();
             if ($isBniInstallment) {
                 $param_installment['bni'] = $bni_term;
             }
             if ($isMandiriInstallment) {
                 $param_installment['mandiri'] = $mandiri_term;
             }
             $param_required = "false";
             $fullPayment = false;
             break;
         case 'certain_product':
             $param_installment = null;
             $products_cart = $cart->getProducts();
             $num_product = count($products_cart);
             if ($num_product == 1) {
                 $attr_product = explode(',', $products_cart[0]['attributes_small']);
                 foreach ($attr_product as $att) {
                     $att_trim = ltrim($att);
                     $att_arr = explode(' ', $att_trim);
                     //error_log(print_r($att_arr,true));
                     if (strtolower($att_arr[0]) == 'installment') {
                         $fullPayment = false;
                         $param_installment = array();
                         $param_installment[strtolower($att_arr[1])] = array($att_arr[2]);
                     }
                 }
             } else {
                 $warning_redirect = true;
                 $keys['message'] = 1;
             }
             $param_required = "true";
             break;
         case 'off':
             $param_installment = null;
             break;
     }
     //error_log($param_installment,true);
     // $param_payment_option = array(
     // 	'installment' => array(
     // 						'required' => $param_required,
     // 						'installment_terms' => $param_installment
     // 					)
     // 	);
     $params_all = array('payment_type' => Configuration::get('VT_PAYMENT_TYPE'), 'vtweb' => array('enabled_payments' => $list_enable_payments), 'transaction_details' => array('order_id' => $this->currentOrder, 'gross_amount' => $gross_amount), 'item_details' => $items, 'customer_details' => $params_customer_details);
     if ($gross_amount < 500000) {
         $warning_redirect = true;
         $keys['message'] = 2;
     }
     if (!$warning_redirect && ($isBniInstallment || $isMandiriInstallment) && !$fullPayment) {
         $params_all['vtweb']['payment_options'] = $param_payment_option;
     }
     if (Configuration::get('VT_API_VERSION') == 2 && Configuration::get('VT_PAYMENT_TYPE') != 'vtdirect') {
         try {
             // Redirect to Veritrans VTWeb page
             if ($this->isInstallmentCart($cart->getProducts()) || $installment_type_val == 'all_product') {
                 $keys['isWarning'] = $warning_redirect;
             } else {
                 $keys['isWarning'] = false;
             }
             $keys['redirect_url'] = Veritrans_Vtweb::getRedirectionUrl($params_all);
         } catch (Exception $e) {
             $keys['errors'] = $e->getMessage();
             echo $e->getMessage();
         }
         return $keys;
     } else {
         if (Configuration::get('VT_API_VERSION') == 2 && Configuration::get('VT_PAYMENT_TYPE') == 'vtdirect') {
             echo 'not yet implementation.';
             exit;
         } else {
             echo 'The Veritrans API versions and the payment type is not valid.';
             exit;
         }
     }
 }
コード例 #20
0
 public function postProcess()
 {
     $cart = $this->context->cart;
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'pagofacil') {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         die($this->module->l('Este m&eacute;todo de pago no est&acute; disponible.', 'validation'));
     }
     $customer = new Customer($cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // validacion
     $arreglo_errores = array();
     $arreglo_validacion = array('nombre' => array('message' => 'Debe capturar el nombre'), 'apellidos' => array('message' => 'Debe capturar los apellidos'), 'numeroTarjeta' => array('message' => 'Debe capturar el n&uacute;mero de tarjeta'), 'cvt' => array('message' => 'Debe capturar el cvt'), 'cp' => array('message' => 'Debe capturar el cp'), 'mesExpiracion' => array('message' => 'Debe seleccionar el mes de expiraci&oacute;n'), 'anyoExpiracion' => array('message' => 'Debe seleccionar el a&ntilde;o de expiraci&oacute;n'), 'email' => array('message' => 'Debe capturar el email'), 'telefono' => array('message' => 'Debe capturar el tel&eacute;fono'), 'celular' => array('message' => 'Debe capturar el celular'), 'calleyNumero' => array('message' => 'Debe capturar la calle y n&uacute;mero'), 'municipio' => array('message' => 'Debe capturar el municipio'), 'estado' => array('message' => 'Debe capturar el estado'), 'pais' => array('message' => 'Debe capturar el pais'));
     foreach ($arreglo_validacion as $key => $item) {
         if (trim(Tools::getValue($key)) == '') {
             array_push($arreglo_errores, $item['message']);
         }
     }
     if (count($arreglo_errores) > 0) {
         session_start();
         $_SESSION['errores'] = $arreglo_errores;
         Tools::redirect($this->context->link->getModuleLink('pagofacil', 'payment'));
     }
     $currency = $this->context->currency;
     $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
     //Realizar el pago con pagofacil
     $data = array('idServicio' => urlencode('3'), 'idSucursal' => urlencode(Configuration::get('PF_API_BRANCH')), 'idUsuario' => urlencode(Configuration::get('PF_API_USER')), 'nombre' => urlencode(Tools::getValue('nombre')), 'apellidos' => urlencode(Tools::getValue('apellidos')), 'numeroTarjeta' => urlencode(Tools::getValue('numeroTarjeta')), 'cvt' => urlencode(Tools::getValue('cvt')), 'cp' => urlencode(Tools::getValue('cp')), 'mesExpiracion' => urlencode(Tools::getValue('mesExpiracion')), 'anyoExpiracion' => urlencode(Tools::getValue('anyoExpiracion')), 'monto' => urlencode($total), 'email' => urlencode(Tools::getValue('email')), 'telefono' => urlencode(Tools::getValue('telefono')), 'celular' => urlencode(Tools::getValue('celular')), 'calleyNumero' => urlencode(Tools::getValue('calleyNumero')), 'colonia' => urlencode(trim(Tools::getValue('colonia')) == '' ? 'S/D' : trim(Tools::getValue('colonia'))), 'municipio' => urlencode(Tools::getValue('municipio')), 'estado' => urlencode(Tools::getValue('estado')), 'pais' => urlencode(Tools::getValue('pais')), 'idPedido' => urlencode($cart->id), 'ip' => urlencode(Tools::getRemoteAddr()), 'httpUserAgent' => urlencode($_SERVER['HTTP_USER_AGENT']));
     if (Configuration::get('PF_NO_MAIL') == '1') {
         $data = array_merge($data, array('noMail' => 1));
     }
     if (Configuration::get('PF_EXCHANGE') != 'MXN') {
         $data = array_merge($data, array('divisa' => Configuration::get('PF_EXCHANGE')));
     }
     if (Configuration::get('PF_INSTALLMENTS') == '1') {
         if (Tools::getValue('msi') != '' && Tools::getValue('msi') != '00') {
             $data = array_merge($data, array('plan' => 'MSI', 'mensualidades' => Tools::getValue('msi')));
         }
     }
     // construccion de la peticion
     $url = 'https://www.pagofacil.net/st/public/Wsrtransaccion/index/format/json';
     if (Configuration::get('PF_ENVIRONMENT') == '2') {
         $url = 'https://www.pagofacil.net/ws/public/Wsrtransaccion/index/format/json';
     }
     $url .= '/?method=transaccion';
     foreach ($data as $key => $valor) {
         $url .= "&data[{$key}]={$valor}";
     }
     //die($this->module->l($url, 'validation'));
     // consumo del servicio
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     // Blindly accept the certificate
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     $response = curl_exec($ch);
     curl_close($ch);
     // tratamiento de la respuesta del servicio
     if (($json = json_decode($response, true)) === NULL) {
         session_start();
         $_SESSION['errores'] = array($response == NULL ? 'Sin respuesta del servicio' : 'Respuesta del servicio: ' . $response);
         Tools::redirect($this->context->link->getModuleLink('pagofacil', 'payment'));
     }
     if (!isset($json['WebServices_Transacciones']['transaccion'])) {
         session_start();
         $_SESSION['errores'] = array('No existe WebServices_Transacciones - transaccion', 'Respuesta del servicio: ' . $response);
         Tools::redirect($this->context->link->getModuleLink('pagofacil', 'payment'));
     }
     $transaction = $json['WebServices_Transacciones']['transaccion'];
     if (isset($transaction['autorizado']) && $transaction['autorizado'] == '1') {
         try {
             $this->module->validateOrder((int) $cart->id, 2, $total, $this->module->displayName, NULL, array(), (int) $currency->id, false, $customer->secure_key);
             Tools::redirect('index.php?controller=order-confirmation&id_cart=' . (int) $cart->id . '&id_module=' . (int) $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key);
         } catch (Exception $error) {
             session_start();
             $_SESSION['errores'] = array($error->getMessage());
             Tools::redirect($this->context->link->getModuleLink('pagofacil', 'payment'));
         }
     } else {
         $arreglo_errores = array();
         if (is_array($transaction['error'])) {
             foreach ($transaction['error'] as $key => $value) {
                 $arreglo_errores[$key] = $value;
             }
         } else {
             $arreglo_errores[] = $transaction['texto'];
         }
         session_start();
         $_SESSION['errores'] = $arreglo_errores;
         Tools::redirect($this->context->link->getModuleLink('pagofacil', 'payment'));
     }
 }
コード例 #21
0
 public function getPaymentMethodDictionaries($order)
 {
     $paymentMethodDictionaries = array();
     $result = Module::getPaymentModules();
     if (!$result) {
         return $paymentMethodDictionaries;
     }
     foreach ($result as $module) {
         // check if we have a cart api module for this payment module
         $moduleInstance = $this->getPaymentModuleInstance($module['name']);
         if ($moduleInstance !== false) {
             $paymentMethodDictionary = $moduleInstance->{'Handle_GetPaymentMethod'}($order);
             if (is_array($paymentMethodDictionary)) {
                 $paymentMethodDictionary['Id'] = $module['name'];
                 $paymentMethodDictionaries[] = $paymentMethodDictionary;
             }
         } else {
             // we don't have a specific cart api module for this one..
             // for now we do nothing, but in the future we need some sort of backup method to try and do something even though this module isn't supported
         }
     }
     return $paymentMethodDictionaries;
 }
コード例 #22
0
ファイル: validation.php プロジェクト: aaron1102/ecbank
 public function postProcess()
 {
     $cart = $this->context->cart;
     $this->display_column_left = true;
     $this->display_column_right = false;
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'greenworld_paypal') {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         die($this->module->l('This payment method is not available.', 'validation'));
     }
     $customer = new Customer($cart->id_customer);
     $currency = $this->context->currency;
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
     $inttotal = round($total);
     $return_url = rawurlencode(Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->module->name . '/doFictitiousDetonate.php');
     $this->module->validateOrder((int) $cart->id, 1, $inttotal, $this->module->displayName, null, array(), null, (int) $currency->id, $customer->secure_key);
     if ($total != (double) $inttotal) {
         Db::getInstance()->execute('
                     UPDATE `' . _DB_PREFIX_ . 'orders`
                     SET `total_paid` = ' . $inttotal . ', total_paid_tax_incl=' . $inttotal . '
                     WHERE `id_order` = ' . $this->module->currentOrder);
     }
     /*  $mer_id=Configuration::get('gw_webatm_mer_id');
                     $encryption_code=Configuration::get('gw_webatm_encryption');
                     $PostData="";
                     $PostData.="mer_id=$mer_id";
                     $PostData.="&enc_key=$encryption_code";
                     $PostData.="&setbank=ESUN";
                     $PostData.="&payment_type=webatm"; 
                     $PostData.="&amt=".$inttotal;
                     $PostData.="&od_sob=".$this->module->currentOrder;
     
                     $PostData.="&return_url=".rawurlencode(Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->module->name.'/doFictitiousDetonate.php');
                  
                     //$PostData.="&ok_url=".rawurlencode("http://".$_SERVER["HTTP_HOST"].$CheckPay->path."doFictitiousDetonate.php");
                    
                     // 建立CURL連線
                     $ch = curl_init();
                     // 設定擷取的URL網址
                     curl_setopt($ch, CURLOPT_URL, "https://ecbank.com.tw/gateway.php?");
                     curl_setopt($ch, CURLOPT_HEADER, false);
                     //將curl_exec()獲取的訊息以文件流的形式返回,而不是直接輸出。
                     curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
                     //設定CURLOPT_POST 為 1或true,表示要用POST方式傳遞
                     curl_setopt($ch, CURLOPT_POST, 0); 
                     //CURLOPT_POSTFIELDS 後面則是要傳接的POST資料。
                     curl_setopt($ch, CURLOPT_POSTFIELDS, $PostData);
                     // 執行
                     $strAuth=curl_exec($ch);
                     // 關閉CURL連線
                     curl_close($ch);
                     parse_str($strAuth, $res);*/
     /* if(!isset($res['error']) || $res['error'] != '0'){
     
                         $this->context->smarty->assign(array(
                                 'error_code' => $res['error'],
                         ));
             
                         die(Tools::displayError('This payment method is not available.'));
                         //echo Module::display('greenworld','payErrorPage.tpl');
                     }else {*/
     $finishURL = 'index.php?controller=order-confirmation&id_cart=' . (int) $cart->id . '&id_module=' . (int) $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key . '&amt=' . $inttotal . '&return_url=' . $return_url . '.php&mer_id=' . Configuration::get('gw_paypal_mer_id');
     //  $finishURL='index.php?controller=order-confirmation&id_cart='.(int)$cart->id.'&id_module='.(int)$this->module->id.'&id_order='.$this->module->currentOrder.'&amt='.$inttotal.'&return_url='.urlencode($return_url).'&mer_id='.Configuration::get('gw_webatm_mer_id');
     //Tools::redirect('index.php?controller=order-confirmation&id_cart='.(int)$cart->id.'&id_module='.(int)$this->module->id.'&id_order='.$this->module->currentOrder.'&key='.$customer->secure_key);
     Tools::redirectLink($finishURL);
     //echo Module::display('greenworld','thankyouPage.tpl');
     // }
     //echo 'index.php?controller=order-confirmation&id_cart='.(int)$cart->id.'&id_module='.(int)$this->module->id.'&id_order='.$this->module->currentOrder.'&key='.$customer->secure_key;
     Tools::redirect('index.php?controller=order-confirmation&id_cart=' . (int) $cart->id . '&id_module=' . (int) $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key);
 }
コード例 #23
0
 /**
  *
  * @see FrontController::postProcess()
  */
 public function postProcess()
 {
     $cart = $this->context->cart;
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'adyen') {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         die($this->module->l('This payment method is not available.', 'validation'));
     }
     $customer = new Customer($cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // get the selected currency
     $currency = $this->context->currency;
     $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
     // validate order
     // $payment_method name must be the same as module name otherwise successurl won't show
     $this->module->validateOrder($cart->id, Configuration::get('ADYEN_NEW_STATUS'), $total, 'Adyen', null, array(), (int) $currency->id, false, $customer->secure_key);
     Logger::addLog('Adyen module: order is validated for id_order ' . $cart->id);
     // go to form adyen post values (submitted automatically)
     $config = Configuration::getMultiple(array('ADYEN_MERCHANT_ACCOUNT', 'ADYEN_MODE', 'ADYEN_SKIN_CODE', 'ADYEN_HMAC_TEST', 'ADYEN_HMAC_LIVE', 'ADYEN_NOTI_USERNAME', 'ADYEN_NOTI_PASSWORD', 'ADYEN_DAYS_DELIVERY', 'PS_SSL_ENABLED', 'ADYEN_COUNTRY_CODE_ISO', 'ADYEN_LANGUAGE_LOCALE'));
     $customer = new Customer((int) $cart->id_customer);
     $address = new Address((int) $cart->id_address_invoice);
     $country = new Country((int) $address->id_country);
     $language = Language::getIsoById((int) $cart->id_lang);
     if (!Validate::isLoadedObject($address) || !Validate::isLoadedObject($customer) || !Validate::isLoadedObject($currency)) {
         Logger::addLog('Adyen module: invalid address, customer, or currency for id_order ' . $cart->id, 4);
         return $this->module->l('Adyen error: (invalid address, customer, or currency)');
     }
     $merchant_account = (string) $config['ADYEN_MERCHANT_ACCOUNT'];
     $skin_code = (string) $config['ADYEN_SKIN_CODE'];
     $currency_code = (string) $currency->iso_code;
     $shopper_email = (string) $customer->email;
     $merchant_reference = (int) $this->module->currentOrder;
     // set when order is validated
     $payment_amount = number_format($cart->getOrderTotal(true, 3), 2, '', '');
     $shopper_reference = (string) $customer->secure_key;
     if ($config['ADYEN_COUNTRY_CODE_ISO'] != '') {
         $country_code = (string) $config['ADYEN_COUNTRY_CODE_ISO'];
     } else {
         $country_code = (string) $country->iso_code;
     }
     // Locale (language) to present to shopper (e.g. en_US, nl, fr, fr_BE)
     if ($config['ADYEN_LANGUAGE_LOCALE'] != '') {
         $shopper_locale = (string) $config['ADYEN_LANGUAGE_LOCALE'];
     } else {
         $shopper_locale = (string) $language;
     }
     $recurring_contract = 'ONECLICK';
     $ship_before_date = date('Y-m-d', mktime(date('H'), date('i'), date('s'), date('m'), date('j') + (isset($config['ADYEN_DAYS_DELIVERY']) ? $config['ADYEN_DAYS_DELIVERY'] : 5), date('Y')));
     // example: ship in 5 days
     $session_validity = date(DATE_ATOM, mktime(date('H') + 1, date('i'), date('s'), date('m'), date('j'), date('Y')));
     // presentation of the shopping basket.
     $tax_calculation_method = Group::getPriceDisplayMethod((int) Group::getCurrent()->id);
     $use_tax = !($tax_calculation_method == PS_TAX_EXC);
     $shipping_cost = Tools::displayPrice($cart->getOrderTotal($use_tax, Cart::ONLY_SHIPPING), $currency);
     $prod_details = sprintf('Shipment cost: %s <br />', $shipping_cost);
     $prod_details .= 'Order rows: <br />';
     // get order items
     foreach ($cart->getProducts() as $product) {
         $name = $product['name'];
         $qty_ordered = (int) $product['cart_quantity'];
         $row_total = Tools::ps_round($product['total_wt'], 2);
         $prod_details .= sprintf('%s ( Qty: %s ) ( Price: %s %s ) <br />', $name, $qty_ordered, $row_total, $currency_code);
     }
     $order_data = base64_encode(gzencode($prod_details));
     // for elv and cc can be mutliple values seperate by comma(,)
     $blocked_methods = '';
     $hmac_data = $payment_amount . $currency_code . $ship_before_date . $merchant_reference . $skin_code . $merchant_account . $session_validity . $shopper_email . $shopper_reference . $recurring_contract . $blocked_methods;
     $merchant_sig = base64_encode(pack('H*', $this->module->getHmacsha1($this->module->getHmac(), $hmac_data)));
     $brand_code = '';
     $ideal_issuer_id = '';
     $skip_selection = '';
     if (Tools::getValue('payment_type') != '') {
         $brand_code = (string) Tools::getValue('payment_type');
     }
     if (Tools::getValue('ideal_type') != '') {
         $ideal_issuer_id = (int) Tools::getValue('ideal_type');
         $skip_selection = 'true';
     }
     $this->context->smarty->assign(array('merchantAccount' => $merchant_account, 'skinCode' => $skin_code, 'currencyCode' => $currency_code, 'shopperEmail' => $shopper_email, 'merchantReference' => $merchant_reference, 'paymentAmount' => $payment_amount, 'shopperReference' => $shopper_reference, 'shipBeforeDate' => $ship_before_date, 'sessionValidity' => $session_validity, 'shopperLocale' => $shopper_locale, 'countryCode' => $country_code, 'orderData' => $order_data, 'recurringContract' => $recurring_contract, 'merchantSig' => $merchant_sig, 'adyenUrl' => $this->getAdyenUrl($brand_code, $ideal_issuer_id), 'resURL' => ($config['PS_SSL_ENABLED'] ? 'https://' : 'http://') . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'index.php?controller=order-confirmation&key=' . $customer->secure_key . '&id_cart=' . (int) $cart->id . '&id_module=' . (int) $this->module->id . '&id_order=' . (int) $this->module->currentOrder, 'brandCode' => $brand_code, 'skipSelection' => $skip_selection, 'idealIssuerId' => $ideal_issuer_id));
 }
コード例 #24
0
 public static function addModuleRestrictions(array $shops = array(), array $countries = array(), array $modules = array())
 {
     if (!count($shops)) {
         $shops = Shop::getShops(true, null, true);
     }
     if (!count($countries)) {
         $countries = Country::getCountries((int) Context::getContext()->cookie->id_lang);
     }
     if (!count($modules)) {
         $modules = Module::getPaymentModules();
     }
     $sql = false;
     foreach ($shops as $id_shop) {
         foreach ($countries as $country) {
             foreach ($modules as $module) {
                 $sql .= '(' . (int) $module['id_module'] . ', ' . (int) $id_shop . ', ' . (int) $country['id_country'] . '),';
             }
         }
     }
     if ($sql) {
         $sql = 'INSERT IGNORE INTO `' . _DB_PREFIX_ . 'module_country` (`id_module`, `id_shop`, `id_country`) VALUES ' . rtrim($sql, ',');
         return Db::getInstance()->execute($sql);
     } else {
         return true;
     }
 }
コード例 #25
0
 /**
  * 结账页面, 验证购物车
  *
  * @param $context Context
  */
 public function performValidation($context)
 {
     $cart = $context->cart;
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // Check that this payment option is still available in case the customer changed his address
     // just before the end of the checkout process
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'pilipay') {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         die($this->l('This payment method is not available.', 'validation'));
     }
     $customer = new Customer($cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     $currency = $context->currency;
     $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
     // 修改订单状态为待从pilibaba支付 validateOrder method save an order to database.
     $this->validateOrder($cart->id, Configuration::get(self::OS_AWAITING), $total, $this->displayName, null, null, (int) $currency->id, false, $customer->secure_key);
     // 支付完成后的回调URL
     $paidCallbackUrl = $this->context->link->getModuleLink($this->name, 'result', [], true);
     $pageUrl = self::getHttpHost() . __PS_BASE_URI__ . 'index.php?controller=history';
     $order = new Order($this->currentOrder);
     $pilibabaWarehouseId = Tools::getValue(self::PILIPAY_WAREHOUSES, Configuration::get(self::PILIPAY_WAREHOUSES));
     if ($pilibabaWarehouseId != '999') {
         // not direct
         //以下几行代码用来修改订单地址到 pilibaba warehouse。
         $id_address = $this->newAddress($order);
         $sql = 'UPDATE `' . _DB_PREFIX_ . 'orders` 
                    SET `id_address_delivery` =' . (int) $id_address . ',`id_address_invoice` = ' . (int) $id_address . '
                    WHERE id_order=' . (int) $this->currentOrder;
         Db::getInstance()->execute($sql);
     }
     if (!Validate::isLoadedObject($order)) {
         die($this->l('This order is invalid.', 'pilipay'));
     }
     try {
         // create an order
         if ($this->testmode == '1') {
             PilipayConfig::setUseProductionEnv(false);
             $pilipayOrder = new PilipayOrder();
             $pilipayOrder->merchantNo = pSQL('0210000202');
             $pilipayOrder->appSecret = pSQL('cbkmqa1s');
         } else {
             $pilipayOrder = new PilipayOrder();
             $pilipayOrder->merchantNo = pSQL($this->merchantNo);
             $pilipayOrder->appSecret = pSQL($this->appSecret);
         }
         $pilipayOrder->currencyType = pSQL($this->getAbbrOfCurrency($currency));
         $pilipayOrder->orderNo = pSQL($order->id);
         $pilipayOrder->orderAmount = $total;
         $pilipayOrder->orderTime = date('Y-m-d H:i:s');
         $pilipayOrder->pageUrl = pSQL($pageUrl);
         //self::_getHttpHost() . '/index.php?controller=history';
         $pilipayOrder->serverUrl = pSQL($paidCallbackUrl);
         $pilipayOrder->redirectUrl = pSQL($pageUrl);
         $pilipayOrder->shipper = $order->total_shipping_tax_incl;
         $totalProductVatTax = 0;
         // create a good
         foreach ($order->getProducts() as $product) {
             $price = $product['product_price'];
             $price_wt = $product['product_price_wt'];
             $totalProductVatTax += $price_wt - $price;
             $productObj = new Product($product['product_id']);
             $productUrl = $context->link->getProductLink($productObj);
             $productPictureUrl = null;
             if (!empty($product['image'])) {
                 $img = $product['image'];
                 if ($img instanceof Image) {
                     $productPictureUrl = $context->link->getImageLink($img->id_image, $img->id_image);
                 }
             }
             $pilipayGood = new PilipayGood();
             $product['product_name'] = pSQL($product['product_name']);
             $pilipayGood->name = $product['product_name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : '');
             $pilipayGood->attr = '';
             $pilipayGood->category = '';
             $pilipayGood->pictureUrl = pSQL($productPictureUrl);
             $pilipayGood->price = $price_wt;
             $pilipayGood->productUrl = pSQL($productUrl);
             $pilipayGood->productId = pSQL($product['product_id']);
             $pilipayGood->quantity = $product['product_quantity'];
             $pilipayGood->weight = $product['product_weight'];
             $pilipayGood->weightUnit = 'kg';
             // default kg for presta shop.
             $pilipayGood->width = 0;
             // 10: cm -> mm
             $pilipayGood->height = 0;
             // 10: cm -> mm
             $pilipayGood->length = 0;
             // 10: cm -> mm
             // add the good to order
             $pilipayOrder->addGood($pilipayGood);
         }
         $pilipayOrder->tax = min(0, $cart->getOrderTotal(true) - $cart->getOrderTotal(false) - ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl) - $totalProductVatTax);
         echo $pilipayOrder->renderSubmitForm();
         die;
     } catch (PilipayError $e) {
         self::log("error", $e->getMessage() . PHP_EOL . $e->getTraceAsString());
         die($e->getMessage());
     } catch (Exception $e) {
         self::log("error", $e->getMessage() . PHP_EOL . $e->getTraceAsString());
         die($e->getMessage());
     }
 }
コード例 #26
0
ファイル: Hook.php プロジェクト: rrameshsat/Prestashop
 /**
  * Get list of modules we can execute per hook
  *
  * @since 1.5.0
  * @param string $hook_name Get list of modules for this hook if given
  * @return array
  */
 public static function getHookModuleExecList($hook_name = null)
 {
     $context = Context::getContext();
     $cache_id = 'hook_module_exec_list' . (isset($context->customer) ? '_' . $context->customer->id : '');
     if (!Cache::isStored($cache_id) || $hook_name == 'displayPayment') {
         $frontend = true;
         $groups = array();
         if (isset($context->employee)) {
             $shop_list = array((int) $context->shop->id);
             $frontend = false;
         } else {
             // Get shops and groups list
             $shop_list = Shop::getContextListShopID();
             if (isset($context->customer) && $context->customer->isLogged()) {
                 $groups = $context->customer->getGroups();
             } elseif (isset($context->customer) && $context->customer->isLogged(true)) {
                 $groups = array((int) Configuration::get('PS_GUEST_GROUP'));
             } else {
                 $groups = array((int) Configuration::get('PS_UNIDENTIFIED_GROUP'));
             }
         }
         // SQL Request
         $sql = new DbQuery();
         $sql->select('h.`name` as hook, m.`id_module`, h.`id_hook`, m.`name` as module, h.`live_edit`');
         $sql->from('module', 'm');
         $sql->innerJoin('hook_module', 'hm', 'hm.`id_module` = m.`id_module`');
         $sql->innerJoin('hook', 'h', 'hm.`id_hook` = h.`id_hook`');
         $sql->where('(SELECT COUNT(*) FROM ' . _DB_PREFIX_ . 'module_shop ms WHERE ms.id_module = m.id_module AND ms.id_shop IN (' . implode(', ', $shop_list) . ')) = ' . count($shop_list));
         if ($hook_name != 'displayPayment') {
             $sql->where('h.name != "displayPayment"');
         } elseif ($frontend) {
             if (Validate::isLoadedObject($context->country)) {
                 $sql->where('(h.name = "displayPayment" AND (SELECT id_country FROM ' . _DB_PREFIX_ . 'module_country mc WHERE mc.id_module = m.id_module AND id_country = ' . (int) $context->country->id . ' LIMIT 1) = ' . (int) $context->country->id . ')');
             }
             if (Validate::isLoadedObject($context->currency)) {
                 $sql->where('(h.name = "displayPayment" AND (SELECT id_currency FROM ' . _DB_PREFIX_ . 'module_currency mcr WHERE mcr.id_module = m.id_module AND id_currency IN (' . (int) $context->currency->id . ', -2) LIMIT 1) IN (' . (int) $context->currency->id . ', -2))');
             }
         }
         if (Validate::isLoadedObject($context->shop)) {
             $sql->where('hm.id_shop = ' . (int) $context->shop->id);
         }
         if ($frontend) {
             $sql->leftJoin('module_group', 'mg', 'mg.`id_module` = m.`id_module`');
             $sql->where('mg.`id_group` IN (' . implode(', ', $groups) . ')');
             $sql->groupBy('hm.id_hook, hm.id_module');
         }
         $sql->orderBy('hm.`position`');
         // Store results per hook name
         $results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
         $list = array();
         // Get all available payment module
         $payment_modules = array();
         if (isset($context->shop->id)) {
             foreach (Module::getPaymentModules() as $module) {
                 $payment_modules[] = $module['name'];
             }
         }
         if ($results) {
             foreach ($results as $row) {
                 if ($row['hook'] == 'displayPayment' && !in_array($row['module'], $payment_modules)) {
                     continue;
                 }
                 $row['hook'] = strtolower($row['hook']);
                 if (!isset($list[$row['hook']])) {
                     $list[$row['hook']] = array();
                 }
                 $list[$row['hook']][] = array('id_hook' => $row['id_hook'], 'module' => $row['module'], 'id_module' => $row['id_module'], 'live_edit' => $row['live_edit']);
             }
         }
         if ($hook_name != 'displayPayment') {
             Cache::store($cache_id, $list);
             // @todo remove this in 1.6, we keep it in 1.5 for retrocompatibility
             self::$_hook_modules_cache_exec = $list;
         }
     } else {
         $list = Cache::retrieve($cache_id);
     }
     // If hook_name is given, just get list of modules for this hook
     if ($hook_name) {
         $retro_hook_name = Hook::getRetroHookName($hook_name);
         $hook_name = strtolower($hook_name);
         $return = array();
         if (isset($list[$hook_name])) {
             $return = $list[$hook_name];
         }
         if (isset($list[$retro_hook_name])) {
             $return = array_merge($return, $list[$retro_hook_name]);
         }
         if (count($return) > 0) {
             return $return;
         }
         return false;
     } else {
         return $list;
     }
 }
コード例 #27
0
ファイル: validation.php プロジェクト: prestanesia/bankniaga
*/
/**
 * @deprecated 1.5.0 This file is deprecated, use moduleFrontController instead
 */
include dirname(__FILE__) . '/../../config/config.inc.php';
include dirname(__FILE__) . '/../../header.php';
include dirname(__FILE__) . '/../../init.php';
$context = Context::getContext();
$cart = $context->cart;
$bankniaga = Module::getInstanceByName('bankniaga');
if ($cart->id_customer == 0 or $cart->id_address_delivery == 0 or $cart->id_address_invoice == 0 or !$bankniaga->active) {
    Tools::redirect('index.php?controller=order&step=1');
}
// Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
$authorized = false;
foreach (Module::getPaymentModules() as $module) {
    if ($module['name'] == 'bankniaga') {
        $authorized = true;
        break;
    }
}
if (!$authorized) {
    die($bankniaga->getTranslator()->trans('This payment method is not available.', array(), 'Modules.BankNiaga.Shop'));
}
$customer = new Customer((int) $cart->id_customer);
if (!Validate::isLoadedObject($customer)) {
    Tools::redirect('index.php?controller=order&step=1');
}
$currency = $context->currency;
$total = (double) $cart->getOrderTotal(true, Cart::BOTH);
$bankniaga->validateOrder($cart->id, Configuration::get('PS_OS_BANKNIAGA'), $total, $bankniaga->displayName, null, array(), (int) $currency->id, false, $customer->secure_key);
コード例 #28
0
ファイル: validation.php プロジェクト: aaron1102/ecbank
 public function postProcess()
 {
     $cart = $this->context->cart;
     $this->display_column_left = true;
     $this->display_column_right = false;
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'greenworld_alipay') {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         die($this->module->l('This payment method is not available.', 'validation'));
     }
     $customer = new Customer($cart->id_customer);
     $currency = $this->context->currency;
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
     $inttotal = round($total);
     $return_url = rawurlencode(Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->module->name . '/doFictitiousDetonate.php');
     //商品上傳
     $type = 'upload_goods';
     $goods_href = 'http://';
     $ecbank_gateway = 'https://ecbank.com.tw/web_service/alipay_goods_upload.php';
     $mer_id = Configuration::get('gw_alipay_mer_id');
     $encryption_code = Configuration::get('gw_alipay_encryption');
     $product_name = array();
     $product_qty = array();
     foreach ($cart->getProducts() as $product => $value) {
         $product_name[] = $value['id_product'];
         $product_qty[] = $value['quantity'];
         $post_str = 'enc_key=' . $encryption_code . '&mer_id=' . $mer_id . '&type=' . $type . '&goods_id=' . $value['id_product'] . '&goods_title=' . $value['name'] . '&goods_price=' . intval($value['price']) . '&goods_href=' . urlencode($goods_href);
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $ecbank_gateway);
         curl_setopt($ch, CURLOPT_VERBOSE, 1);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $post_str);
         $strAuth = curl_exec($ch);
     }
     curl_close($ch);
     $_SESSION["name"] = $product_name;
     $_SESSION["quantity"] = $product_qty;
     $this->module->validateOrder((int) $cart->id, 1, $inttotal, $this->module->displayName, null, array(), null, (int) $currency->id, $customer->secure_key);
     if ($total != (double) $inttotal) {
         Db::getInstance()->execute('
                     UPDATE `' . _DB_PREFIX_ . 'orders`
                     SET `total_paid` = ' . $inttotal . ', total_paid_tax_incl=' . $inttotal . '
                     WHERE `id_order` = ' . $this->module->currentOrder);
     }
     $finishURL = 'index.php?controller=order-confirmation&id_cart=' . (int) $cart->id . '&id_module=' . (int) $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key . '&amt=' . $inttotal . '&return_url=' . $return_url . '.php&mer_id=' . Configuration::get('gw_paypal_mer_id');
     //  $finishURL='index.php?controller=order-confirmation&id_cart='.(int)$cart->id.'&id_module='.(int)$this->module->id.'&id_order='.$this->module->currentOrder.'&amt='.$inttotal.'&return_url='.urlencode($return_url).'&mer_id='.Configuration::get('gw_webatm_mer_id');
     //Tools::redirect('index.php?controller=order-confirmation&id_cart='.(int)$cart->id.'&id_module='.(int)$this->module->id.'&id_order='.$this->module->currentOrder.'&key='.$customer->secure_key);
     Tools::redirectLink($finishURL);
     //echo Module::display('greenworld','thankyouPage.tpl');
     // }
     //echo 'index.php?controller=order-confirmation&id_cart='.(int)$cart->id.'&id_module='.(int)$this->module->id.'&id_order='.$this->module->currentOrder.'&key='.$customer->secure_key;
     Tools::redirect('index.php?controller=order-confirmation&id_cart=' . (int) $cart->id . '&id_module=' . (int) $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key);
 }
コード例 #29
0
 /**
  * This function will redirect (if $this->redirectOnCheck is true)
  * to the order page if any shop-module
  * related issue is found ex. the module is disabled for the
  * current order, the customer or cart is empty etc. If the private
  *
  * @param boolean $checkCart
  * @return boolean (if not redirected)
  */
 private function _checkBeforeSend($checkCart = true)
 {
     global $smarty;
     global $cart;
     $errorfound = false;
     if (Tools::getValue('msg')) {
         $smarty->assign(array('EVERYPAY_MSG' => $this->_frontMessages(Tools::getValue('msg'))));
     }
     $redirectLocation = __PS_BASE_URI__ . 'order.php?step=3';
     if (!$this->online || !$this->active || $cart->id_customer == 0 || $checkCart && !$cart->getNbProducts($cart->id) || $checkCart && $cart->id_address_delivery == 0 || $checkCart && $cart->id_address_invoice == 0) {
         $errorfound = true;
     }
     // Check that this payment option is still available in case the
     // customer changed his address just before the end of the checkout process
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == $this->name) {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         $errorfound = true;
     }
     //customer
     $customer = new Customer($cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         $errorfound = true;
     }
     //currency
     $currency_order = new Currency((int) $cart->id_currency);
     $currencies_module = $this->getCurrency((int) $cart->id_currency);
     $allowed_currency = false;
     if (is_array($currencies_module)) {
         foreach ($currencies_module as $currency_module) {
             if ($currency_order->id == $currency_module['id_currency'] && in_array(strtoupper($currency_module['iso_code']), $this->configuration['EVERYPAY_ACCEPTED_CURRENCIES'])) {
                 $allowed_currency = true;
                 break;
             }
         }
     }
     if (!$allowed_currency) {
         $errorfound = true;
     }
     if ($errorfound && $this->redirectOnCheck) {
         Tools::redirect($redirectLocation);
     } elseif ($errorfound) {
         return false;
     }
     return true;
 }
コード例 #30
0
ファイル: dpdgroup.php プロジェクト: remixaz/dpdgroup
    public static function getPaymentModules()
    {
        if (version_compare(_PS_VERSION_, '1.5', '<')) {
            return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
				SELECT DISTINCT h.`id_hook`, m.`name`, hm.`position`
				FROM `' . _DB_PREFIX_ . 'module_country` mc
				LEFT JOIN `' . _DB_PREFIX_ . 'module` m ON m.`id_module` = mc.`id_module`
				INNER JOIN `' . _DB_PREFIX_ . 'module_group` mg ON (m.`id_module` = mg.`id_module`)
				LEFT JOIN `' . _DB_PREFIX_ . 'hook_module` hm ON hm.`id_module` = m.`id_module`
				LEFT JOIN `' . _DB_PREFIX_ . 'hook` h ON hm.`id_hook` = h.`id_hook`
				WHERE h.`name` = \'payment\'
				AND m.`active` = 1
				ORDER BY hm.`position`, m.`name` DESC
			');
        }
        return Module::getPaymentModules();
    }