Exemplo n.º 1
0
 public function hookDisplayPayment($params)
 {
     include_once _PS_MODULE_DIR_ . '/bluepay/bluepay_customers.php';
     $cart = new Cart($this->context->cart->id);
     $cart_contents = '';
     foreach ($cart->getProducts() as $product) {
         foreach ($product as $key => $value) {
             if ($key == 'cart_quantity') {
                 $cart_contents .= $value . ' ';
             }
             if ($key == 'name') {
                 $cart_contents .= $value . '|';
             }
         }
     }
     $address = new Address((int) $cart->id_address_invoice);
     $state = new State($address->id_state);
     $cards = array();
     $cards['visa'] = Configuration::get('BP_CARD_TYPES_VISA') == 'on';
     $cards['mastercard'] = Configuration::get('BP_CARD_TYPES_MC') == 'on';
     $cards['discover'] = Configuration::get('BP_CARD_TYPES_DISC') == 'on';
     $cards['amex'] = Configuration::get('BP_CARD_TYPES_AMEX') == 'on';
     $expiration_month = array();
     for ($i = 1; $i < 13; $i++) {
         $expiration_month[$i] = str_pad($i, 2, '0', STR_PAD_LEFT);
     }
     $expiration_year = array();
     for ($i = 13; $i < 25; $i++) {
         $expiration_year[$i] = $i;
     }
     $this->context->smarty->assign(array('payment_type' => Configuration::get('BP_PAYMENT_TYPE'), 'display_logo' => Configuration::get('BP_DISPLAY_LOGO'), 'secret_key' => Configuration::get('BP_SECRET_KEY'), 'account_id' => Configuration::get('BP_ACCOUNT_ID'), 'transaction_type' => Configuration::get('BP_TRANSACTION_TYPE'), 'payment_type' => Configuration::get('BP_PAYMENT_TYPE'), 'mode' => Configuration::get('BP_TRANSACTION_MODE'), 'customer' => $params['cookie']->customer_firstname . ' ' . $params['cookie']->customer_lastname, 'customer_address' => Tools::safeOutput($address->address1 . ' ' . $address->address2), 'customer_city' => Tools::safeOutput($address->city), 'customer_state' => $state->name, 'customer_zip' => Tools::safeOutput($address->postcode), 'customer_email' => $this->context->cookie->email, 'customer_country' => $address->country, 'invoice_id' => (int) $params['cart']->id, 'cards' => $cards, 'this_path' => $this->_path, 'cart' => $cart_contents, 'require_cvv2' => Configuration::get('BP_REQUIRE_CVV2'), 'allow_stored_payments' => Configuration::get('BP_ALLOW_STORED_PAYMENTS'), 'use_iframe' => Configuration::get('BP_CHECKOUT_IFRAME'), 'has_saved_payment_information' => BluePayCustomer::customerHasStoredPayment($params['cookie']->id_customer), 'has_saved_cc_payment_information' => BluePayCustomer::customerHasStoredCCPayment($params['cookie']->id_customer), 'saved_payment_information' => BluePayCustomer::getCustomerById($params['cookie']->id_customer), 'card_expiration_mm' => $expiration_month, 'card_expiration_yy' => $expiration_year, 'ach_account_types' => array('C' => 'Checking', 'S' => 'Savings')));
     if (Configuration::get('BP_CHECKOUT_IFRAME') == 'No') {
         return $this->display(__FILE__, 'views/templates/hook/payment.tpl');
     }
     return $this->display(__FILE__, 'views/templates/hook/payment_iframe.tpl');
 }
Exemplo n.º 2
0
         /**
          * Check if amount processed through BluePay matches the cart total.
          * If amounts do not match, send the customer back
          * to the payment page.
          */
         if ($bluepay->validate($transaction['transaction_id'], $transaction['invoice_id']) != $transaction['total_paid']) {
             $message = 'Amounts do not match. The order was not created successfully; please try again.';
             $url = 'index.php?controller=order&step=3&error=' . $message;
             Tools::redirect($url);
             exit;
         }
         $bluepay->validateOrder((int) $cart->id, $transaction['transaction_type'], $transaction['total_paid'], $bluepay->displayName, $message, $transaction, null, false, $customer->secure_key);
         $order_id = Order::getOrderByCartId((int) $cart->id);
         BluePayOrder::saveOrder((int) $order_id, $transaction);
         if (Tools::getValue('save_payment_information') == 'Yes') {
             BluePayCustomer::saveCustomer($transaction);
         }
         break;
     } else {
         $url = 'index.php?controller=order&step=3&error=Duplicate Transaction';
         Tools::redirect($url);
         break;
     }
     /**
      * Transaction declined
      */
 /**
  * Transaction declined
  */
 case '0':
     $url = 'index.php?controller=order&step=3&error=Declined';