Jump to content

Kamil Szmit

Members
  • Posts

    6
  • Joined

  • Last visited

About Kamil Szmit

  • Birthday 03/19/1989

Contact Methods

Profile Information

  • Location
    Chotomów; Warszawa
  • First Name
    Kamil
  • Last Name
    Szmit

Recent Profile Visitors

359 profile views

Kamil Szmit's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. What is the proper way to create 'button' of choice of payment method in the payment module for PrestaShop 1.6? I have created template "/views/templates/hook/payment.tpl": <div class="row"> <div class="col-xs-12"> <p class="payment_module"> <a class="billon" href="{$link->getModuleLink('billon', 'payment')|escape:'html'}" title="{l s='Pay by Billon' mod='billon'}"> {l s='Pay by Billon' mod='billon'} <span>{l s='(one-click blockchain payment)' mod='billon'}</span> </a> </p> </div> </div> I hooked it rewriting method "hookPayment": public function hookPayment() { $this->smarty->assign(array('module_dir' => $this->_path)); if ($this->active && Configuration::get('BILLON_CONFIGURATION_OK')) return $this->display(__FILE__, 'payment.tpl'); } The problem is that a class 'col-md-6' is conferred (given, set) on elements 'div' with a class "col-xs-12" in 'buttons' of other payments methods in some shops. Such a class is not conferred (not set) on the element in 'button' of my payment method. After removing the elements 'div' from the template „payment.tpl”, they are not created on a page of choice of the payment method, even if I create another template "/views/templates/hook/payment16.tpl" with these elements and I return $this->display(__FILE__, '/views/templates/hook/payment16.tpl') or $this->display(__FILE__, 'payment16.tpl') in the method "hookPayment". Is it possible that PrestaShop does not set (not confer, not give) class 'col-md-6' in "button" of last payment method? What is recommended and checked way to hook "button" of the payment method in the module for PrestaShop 1.6? Could you help me?
  2. Jaki jest właściwy sposób tworzenia „przycisku” wybory metody płatności w module płatności dla PrestaShop 1.6? Zrobiłem szablon "/views/templates/hook/payment.tpl": <div class="row"> <div class="col-xs-12"> <p class="payment_module"> <a class="billon" href="{$link->getModuleLink('billon', 'payment')|escape:'html'}" title="{l s='Pay by Billon' mod='billon'}"> {l s='Pay by Billon' mod='billon'} <span>{l s='(one-click blockchain payment)' mod='billon'}</span> </a> </p> </div> </div> Podpiąłem go nadpisując metodę "hookPayment": public function hookPayment() { $this->smarty->assign(array('module_dir' => $this->_path)); if ($this->active && Configuration::get('BILLON_CONFIGURATION_OK')) return $this->display(__FILE__, 'payment.tpl'); } Problem w tym, że w niektórych sklepach elementowi „div” klasy "col-xs-12" w "przyciskach" innych metod płatności nadawana jest klasa „col-md-6”. Elementowi w „przycisku” mojej metody płatności taka klasa nie jest nadawana. Po usunięciu z szablonu „payment.tpl” elementów „div” nie są one tworzone na stronie wyboru metody płatności, nawet, jeśli utworzę inny szablon "/views/templates/hook/payment16.tpl" z tymi elementami i zwracam $this->display(__FILE__, '/views/templates/hook/payment16.tpl') lub $this->display(__FILE__, 'payment16.tpl') w metodzie "hookPayment". Czy jest to możliwe, że PrestaShop nie nadaje klas „col-md-6” w "przycisku" ostatniej metody płatności? Jaki jest zalecany i sprawdzony sposób na podpięcie "przycisku" metody płatności w module dla PrestaShop 1.6? Proszę o pomoc.
  3. I am creating PrestaShop payment module, on whose payment page there is JavaScript script, which sends payment request via AJAX to the PHP script inside the module. PHP script change the cart into the order after successful payment. Changing cart into order looks as follows: if ($cart->OrderExists() == false) { $module->validateOrder($cart->id, $actual_state, $total, 'billon', NULL, array(), (int)$cart->id_currency, false, $customer->secure_key); } else { $history = new OrderHistory(); $history->id_order = Order::getOrderByCartId((int)Tools::getValue('control')); $lastOrderState = OrderHistory::getLastOrderState($history->id_order); $history->changeIdOrderState($actual_state, $history->id_order); $history->addWithemail(true); } How is the best way to lock the cart before the payment and unlock it if payment failed? Should I create order from the cart with another status: if ($cart->OrderExists() == false) { $module->validateOrder($cart->id, 1, $total, 'billon', NULL, array(), (int)$cart->id_currency, false, $customer->secure_key); } Which status should I set? How to get identifier of status created by module method "addNewOrderState"? How to restore the cart (from order) then? Should I try to clone the object of cart, call the method "delete" of cart, and call the method of payment "save" of the cloned object in case of a failure of the payment: $cart = new Cart((int) 0); $tempCart = $cart; $myShop->paymentStatus($taskId ? $taskId : $_GET['taskId'], function($response) use (&$cart, &$tempCart) { $responseString = json_encode($response); if (is_string($response['status'])) { $status = explode('_', $response['status']); if (count($status) > 1 && $status[0] == 'FINISHED') { if ($status[1] != 'OK') { if (isset($tempCart)) { $tempCart->save(); } } } else { if (isset($cart)) { $tempCart = clone $cart; $cart->delete(); } } } echo $responseString; Is it better is to create your own ObjectModel class and table to store the user and order idetifiers? Is there another way? Could you help me?
  4. Robię moduł płatności PrestaShop, gdzie na stronie płatności umieszczany jest skrypt JavaScript wysyłający poprzez AJAX żądanie płatności do skryptu PHP wewnątrz modułu, gdzie znajduje się przenoszenie koszyka do zamówień po poprawnej płatności. Przenoszenie zamówienia do koszyka wygląda w następujący sposób: if ($cart->OrderExists() == false) { $module->validateOrder($cart->id, $actual_state, $total, 'billon', NULL, array(), (int)$cart->id_currency, false, $customer->secure_key); } else { $history = new OrderHistory(); $history->id_order = Order::getOrderByCartId((int)Tools::getValue('control')); $lastOrderState = OrderHistory::getLastOrderState($history->id_order); $history->changeIdOrderState($actual_state, $history->id_order); $history->addWithemail(true); } Jak najlepiej zablokować koszyk przed wykonaniem płatności i najlepiej odblokować go, jeśli płatność się nie udała? Czy próbować sklonować obiekt koszyka, wywołać metodę "delete" koszyka, a przy nieudanej płatności wykonać metodę "save" sklonowanego obiektu: $cart = new Cart((int) 0); $tempCart = $cart; $myShop->paymentStatus($taskId ? $taskId : $_GET['taskId'], function($response) use (&$cart, &$tempCart) { $responseString = json_encode($response); if (is_string($response['status'])) { $status = explode('_', $response['status']); if (count($status) > 1 && $status[0] == 'FINISHED') { if ($status[1] != 'OK') { if (isset($tempCart)) { $tempCart->save(); } } } else { if (isset($cart)) { $tempCart = clone $cart; $cart->delete(); } } } echo $responseString; Czy lepiej utworzyć zamówienie z koszyka z innym statusem? Jak wtedy przywrócić koszyk? Czy jedyna możliwość to stworzenie własnej klasy i tabeli ObjectModel przechowującej identyfikator użytkownika i zamówienia? Czy jest jeszcze inny sposób? Proszę o pomoc.
  5. I am creating payment module for PrestaShop. I have a class in "controllers/front/payment.php": class paymentModuleFrontController extends ModuleFrontController { public function initContent() { $this->display_column_left = false; parent::initContent(); $control=(int)Tools::getValue('control'); $cart = $this->context->cart; if (!empty($control)) $cart = new Cart($control); 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'); $customer = new Customer($cart->id_customer); if (!Validate::isLoadedObject($customer)) Tools::redirect('index.php?controller=order&step=1'); $address = new Address($cart->id_address_invoice); $params = null; $template = "payment_return"; if ($cart->OrderExists() == true) Tools::redirect('index.php?controller=order-confirmation&id_cart='.$cart->id.'&id_module='.$this->module->id.'&id_order='.Order::getOrderByCartId($cart->id).'&key='.$customer->secure_key); elseif (Tools::getValue("status") == "OK") // (...) { // (...) $template = "payment"; $form_url = ""; $currency = Currency::getCurrency($cart->id_currency); if (Configuration::get('DP_TEST')==1) $form_url.="test_payment/"; $params = array( 'id' => Configuration::get('DP_ID'), 'amount' => (float)$cart->getOrderTotal(true, Cart::BOTH), 'currency' => $currency["iso_code"], 'description' => Configuration::get('PS_SHOP_NAME'), //(...) 'type' => 0, // (...) 'control' => $cart->id, 'firstname' => $customer->firstname, 'lastname' => $customer->lastname, 'email' => $customer->email, 'street' => $address->address1, 'city' => $address->city, 'postcode'=> $address->postcode, 'api_version' => 'legacy' ); $chk = $params['id'].$params['amount'].$params['currency'].$params['description'].$params['control'].Configuration::get('DP_PIN'); $chk = rawurlencode($chk); if(Configuration::get('DP_CHK')) $params['chk']=hash('md5', $chk); } $this->context->smarty->assign(array( 'params' => $params, 'module_dir' => $this->module->getPathUri(), 'form_url' => $form_url, )); $this->setTemplate($template.".tpl"); } } I have created JavaScript script, which send AJAX request with "{$cart_id}", in template 'views/templates/front/payment.tpl''. The module creates a type of payment and runs JavaScript script after choosing this type of payment during making an order. I would like to create PHP script that process AJAX request, loads information about the order and executes it. I created script "payment.php": require_once(dirname(__FILE__).'../../../config/config.inc.php'); //require_once(dirname(__FILE__).'../../../init.php'); // I have problem with flushing output when I am including this script require "processing.inc.php"; $myShop->paymentInitiation(); and "processing.inc.php": //require ... //$myShop = new ... $myShop->user(function ($requestData, $cb) { $cb($requestData->user); } )->products(function ($requestData, $cb) { $cb(array(18, 30)); } )->product(function ($requestData, $itemId, $cb) { if ($itemId == 18) { $cb(array( "item_id"=> "18", // (...) )); } else if ($itemId == 30) { $cb(array( "item_id"=> "30", // (...) )); } } // (...) )->productDelivery(function ($requestData, $items, $cb) { $cb(array( "delivery_id"=> "", // (...) )); })->currency(function ($requestData, $cb) { $cb('PLN'); } )->paymentTitle(function ($requestData, $items, $delivery, $cb) { $cb('Tytuł płatności'); } // (...) )->merchant(function ($requestData, $items, $delivery, $cb) { $cb(array("company" => array("name" => "Default", "NIP" => "", "REGON" => "", "KRS" => ""), "person" => array("first_name" => "Default", "last_name" => "", "PESEL" => ""), "address" => array("street" => "Default", "city" => "Default", "zip" => "00-000", "country" => ""), "fax" => "", "www" => "", "email" => "")); } )->documentParse(function ($requestData, $document, $cb) { $cb(false); } )->onFinishedPayment(function ($items, $delivery_option, $document, $requestData) { } ); How to load order data in PHP script "processing.inc.php", which is run by AJAX, having "cart_id"? How to set order as paid in functions that is argument of my method "onFinishedPayment"? Could you help me?
  6. Chciałbym zrobić skrypty PHP „.../payment” lub „.../payment.php” i „.../status” lub „.../status.php” w module do PrestaShop, do których można wysyłać żądania AJAX POST. Skrypty powinny mieć możliwość użycia skryptu, w którym można by było pobrać informację ze sklepu, głównie o zamówieniu, i zrealizować zamówienie. Skrypty JavaScript konstruujące żądania AJAX są już zrobione w szablonie "views/templates/front/payment.tpl". Moduł tworzy nowy rodzaj płatności, a skrypty działają po jego wybraniu przy składaniu zamówienia. Czy powinienem zrobić kontroler dziedziczący po klasie "OrderController"? Próbuję robić w ten sposób w skrypcie "controllers/payment/index.php": <?php //require ... class PaymentController extends OrderController { /** * @var Module */ public $module; private $shop; public function __construct() { $this->controller_type = 'payment'; $this->module = Module::getInstanceByName(Tools::getValue('module')); // $this->shop = new ... // (...) parent::__construct(); } public function initiatePayment() { $this->shop->paymentInitiation(); } public function checkStatus($taskId, $cb) { $this->shop->paymentStatus($taskId, $cb); } } Jak powinienem zrobić „akcje” typu „.../payment” lub „.../payment.php”, która wywoła "initiatePayment", i „.../status” lub „.../status.php” wywołującą metodę "checkStatus"? Po jakich pełnych adresach powinienem komunikować się z takimi „akcjami” poprzez AJAX? Moduł będzie korzystał z możliwości PHP 5.3. Proszę o pomoc (rozwiązanie najlepiej jakby było zgodne z PHP 5.3 i starszymi wersjami PrestaShop, ale może wymagać nowszych wersji, jeśli jest to konieczne).
×
×
  • Create New...