Beispiel #1
0
 /**
  * Displays a page with saved credit cards
  */
 public function initContent()
 {
     $this->display_column_left = false;
     parent::initContent();
     $this->context->smarty->assign(array('cards' => DotpayCreditCard::getAllCardsForCustomer($this->context->customer->id), 'onRemoveMessage' => $this->module->l('Do you want to deregister a saved card'), 'onDoneMessage' => $this->module->l('The card was deregistered'), 'onFailureMessage' => $this->module->l('An error occurred while deregistering the card'), 'removeUrl' => $this->context->link->getModuleLink($this->module->name, 'ocremove')));
     $this->setTemplate("ocmanage.tpl");
 }
Beispiel #2
0
 /**
  * Display payment instruction for cash or transfer payments
  */
 public function initContent()
 {
     $this->display_column_left = false;
     parent::initContent();
     $errorMessage = NULL;
     if (Tools::getValue('order_id')) {
         $this->context->cart = Cart::getCartByOrderId(Tools::getValue('order_id'));
         $this->initPersonalData();
     }
     $channel = $this->context->cookie->dotpay_channel;
     unset($this->context->cookie->dotpay_channel);
     DotpayRegisterOrder::init($this);
     $payment = DotpayRegisterOrder::create($channel);
     if ($payment === NULL) {
         $instruction = DotpayInstruction::getByOrderId(Tools::getValue('order_id'));
         if (!empty($instruction) && $instruction->id == NULL) {
             $this->context->smarty->assign(array('isOk' => false));
         }
     } else {
         if (isset($payment['instruction']) && isset($payment['operation'])) {
             if ($this->api->isChannelInGroup($payment['operation']['payment_method']['channel_id'], array(DotpayApi::cashGroup))) {
                 $isCash = true;
             } else {
                 $isCash = false;
             }
             $instruction = new DotpayInstruction();
             $instruction->amount = $payment['instruction']['amount'];
             $instruction->currency = $payment['instruction']['currency'];
             $instruction->number = $payment['operation']['number'];
             $instruction->hash = DotpayInstruction::gethashFromPayment($payment);
             $instruction->is_cash = $isCash;
             $instruction->order_id = Tools::getValue('order_id');
             $instruction->channel = $payment['operation']['payment_method']['channel_id'];
             if (isset($payment['instruction']['recipient'])) {
                 $instruction->bank_account = $payment['instruction']['recipient']['bank_account_number'];
             }
             try {
                 $instruction->save();
             } catch (Exception $e) {
                 $this->context->smarty->assign(array('errorMessage' => $this->module->l("Unable to save instructions." . $e->getMessage())));
             }
         }
     }
     if (!empty($instruction) && $instruction->id != NULL) {
         if ($instruction->is_cash) {
             $template = 'cash.tpl';
             $address = $instruction->getPdfUrl($this->config->getDotpayTargetUrl());
             $bankImage = '';
         } else {
             $template = 'transfer.tpl';
             $address = $instruction->getBankPage($this->config->getDotpayTargetUrl());
         }
         $chData = $this->api->getChannelData($instruction->channel);
         $channelImage = $chData['logo'];
         $this->context->smarty->assign(array('meta_title' => $this->module->l('Complete payment'), 'isOk' => true, 'amount' => $instruction->amount, 'currency' => $instruction->currency, 'title' => $instruction->number, 'address' => $address, 'bankAccount' => $instruction->bank_account, 'recipient' => DotpayInstruction::DOTPAY_NAME, 'street' => DotpayInstruction::DOTPAY_STREET, 'city' => DotpayInstruction::DOTPAY_CITY, 'template' => './confirm/' . $template, 'channelImage' => $channelImage));
     }
     $this->setTemplate("confirm.tpl");
 }
Beispiel #3
0
 /**
  * Removes saved credit card
  */
 public function initContent()
 {
     $this->display_column_left = false;
     parent::initContent();
     $cc = new DotpayCreditCard(Tools::getValue('card_id'));
     if ($cc->id != NULL) {
         $cc->delete();
         die('OK');
     } else {
         die('Card not found');
     }
 }
Beispiel #4
0
 /**
  * Preparing hidden form with payment data before sending it to Dotpay
  */
 public function initContent()
 {
     parent::initContent();
     $this->display_column_left = false;
     $this->display_header = false;
     $this->display_footer = false;
     $cartId = 0;
     if (Tools::getValue('order_id') == false) {
         $cartId = $this->context->cart->id;
         $exAmount = $this->api->getExtrachargeAmount(true);
         if ($exAmount > 0 && !$this->isExVPinCart()) {
             $productId = $this->config->getDotpayExchVPid();
             if ($productId != 0) {
                 $product = new Product($productId, true);
                 $product->price = $exAmount;
                 $product->save();
                 $product->flushPriceCache();
                 $this->context->cart->updateQty(1, $product->id);
                 $this->context->cart->update();
                 $this->context->cart->getPackageList(true);
             }
         }
         $discAmount = $this->api->getDiscountAmount();
         if ($discAmount > 0) {
             $discount = new CartRule($this->config->getDotpayDiscountId());
             $discount->reduction_amount = $this->api->getDiscountAmount();
             $discount->reduction_currency = $this->context->cart->id_currency;
             $discount->reduction_tax = 1;
             $discount->update();
             $this->context->cart->addCartRule($discount->id);
             $this->context->cart->update();
             $this->context->cart->getPackageList(true);
         }
         $result = $this->module->validateOrder($this->context->cart->id, (int) $this->config->getDotpayNewStatusId(), $this->getDotAmount(), $this->module->displayName, NULL, array(), NULL, false, $this->customer->secure_key);
     } else {
         $this->context->cart = Cart::getCartByOrderId(Tools::getValue('order_id'));
         $this->initPersonalData();
         $cartId = $this->context->cart->id;
     }
     $this->api->onPrepareAction(Tools::getValue('dotpay_type'), array('order' => Order::getOrderByCartId($cartId), 'customer' => $this->context->customer->id));
     $sa = new DotpaySellerApi($this->config->getDotpaySellerApiUrl());
     if ($this->config->isDotpayDispInstruction() && $this->config->isApiConfigOk() && $this->api->isChannelInGroup(Tools::getValue('channel'), array(DotpayApi::cashGroup, DotpayApi::transfersGroup)) && $sa->isAccountRight($this->config->getDotpayApiUsername(), $this->config->getDotpayApiPassword(), $this->config->getDotpayApiVersion())) {
         $this->context->cookie->dotpay_channel = Tools::getValue('channel');
         Tools::redirect($this->context->link->getModuleLink($this->module->name, 'confirm', array('order_id' => Order::getOrderByCartId($cartId))));
         die;
     }
     $this->context->smarty->assign(array('hiddenForm' => $this->api->getHiddenForm()));
     $cookie = new Cookie('lastOrder');
     $cookie->orderId = Order::getOrderByCartId($cartId);
     $cookie->write();
     $this->setTemplate("preparing.tpl");
 }
Beispiel #5
0
 /**
  * Proces coming back from a Dotpay server
  */
 public function initContent()
 {
     $this->display_column_left = false;
     parent::initContent();
     $message = NULL;
     if ((bool) Context::getContext()->customer->is_guest) {
         $url = $this->context->link->getPageLink('guest-tracking', true);
     } else {
         $url = $this->context->link->getPageLink('history', true);
     }
     $cookie = new Cookie('lastOrder');
     $order = new Order($cookie->orderId);
     if (Tools::getValue('error_code') !== false) {
         $this->removeCookieWithOrderId();
         switch (Tools::getValue('error_code')) {
             case 'PAYMENT_EXPIRED':
                 $message = $this->module->l('Exceeded expiration date of the generated payment link.');
                 break;
             case 'UNKNOWN_CHANNEL':
                 $message = $this->module->l('Selected payment channel is unknown.');
                 break;
             case 'DISABLED_CHANNEL':
                 $message = $this->module->l('Selected channel payment is desabled.');
                 break;
             case 'BLOCKED_ACCOUNT':
                 $message = $this->module->l('Account is disabled.');
                 break;
             case 'INACTIVE_SELLER':
                 $message = $this->module->l('Seller account is inactive.');
                 break;
             case 'AMOUNT_TOO_LOW':
                 $message = $this->module->l('Amount is too low.');
                 break;
             case 'AMOUNT_TOO_HIGH':
                 $message = $this->module->l('Amount is too high.');
                 break;
             case 'BAD_DATA_FORMAT':
                 $message = $this->module->l('Data format is bad.');
                 break;
             case 'HASH_NOT_EQUAL_CHK':
                 $message = $this->module->l('Request has been modified during transmission.');
                 break;
             default:
                 $message = $this->module->l('There was an unidentified error. Please contact to your seller and give him the order number.');
         }
     }
     $this->context->smarty->assign(array('message' => $message, 'redirectUrl' => $url, 'orderReference' => $order->reference, 'checkStatusUrl' => $this->context->link->getModuleLink($this->module->name, 'status', array()), 'waitingMessage' => $this->module->l('Waiting for confirm your payment...') . '<br>' . $this->module->l('It make take up to 2 minutes.'), 'successMessage' => $this->module->l('Thank you! The process of payment completed correctly. In a moment you will be able to check the status of your order.'), 'errorMessage' => $this->module->l('Payment was rejected.'), 'timeoutMessage' => $this->module->l('Time intended for waiting for payment confirmation has elapsed. When transaction will be confirmed we will notify you on email. If payment will not be confirmed, please contact with shop owner and give him the order number:') . ' ' . $order->reference));
     $this->setTemplate("back.tpl");
 }
Beispiel #6
0
 /**
  * Displays template with Dotpay payment channels
  */
 public function initContent()
 {
     $this->display_column_left = false;
     parent::initContent();
     if (Tools::getValue('order_id')) {
         $cart = Cart::getCartByOrderId(Tools::getValue('order_id'));
         if (empty($cart)) {
             $cart = new Cart();
         }
         $this->context->cart = $cart;
         $this->context->cart->update();
     }
     $this->context->smarty->assign($this->getArrayForSmarty(true));
     $this->setTemplate("payment.tpl");
 }