本文整理汇总了PHP中Module::getPaymentModules方法的典型用法代码示例。如果您正苦于以下问题:PHP Module::getPaymentModules方法的具体用法?PHP Module::getPaymentModules怎么用?PHP Module::getPaymentModules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Module
的用法示例。
在下文中一共展示了Module::getPaymentModules方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
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: 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'] == '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: postProcess
/**
* @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: postProcess
/**
* @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: 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'] == '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: postProcess
/**
* @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: postProcess
/**
* @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: postProcess
/**
* @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: postProcess
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: verifyPaymentOptionAvailability
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: postProcess
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: 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'] == '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: initContent
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: 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'] == '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: 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');
}
$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');
}
}