protected function _getWirecardButton() { $order = Kwf_Model_Abstract::getInstance(Kwc_Abstract::getSetting($this->getData()->getParentByClass('Kwc_Shop_Cart_Component')->componentClass, 'childModel'))->getReferencedModel('Order')->getCartOrder(); $total = $this->getData()->getParentByClass('Kwc_Shop_Cart_Checkout_Component')->getComponent()->getTotal($order); $payment = $this->getData()->getParentByClass('Kwc_Shop_Cart_Checkout_Payment_Wirecard_Component'); $custom = Kwc_Shop_Cart_Checkout_Payment_Wirecard_LogModel::getEncodedCallback($payment->componentId, array('orderId' => $order->id)); $params = array('amount' => round($total, 2), 'currency' => 'EUR', 'paymentType' => Kwc_Abstract::getSetting($payment->componentClass, 'paymentType'), 'custom' => $custom); return self::buildWirecardButtonHtml($params, $payment, $order); }
public function processInput($data) { $custom = isset($data['custom']) ? rawurldecode($data['custom']) : null; $data = Kwc_Shop_Cart_Checkout_Payment_Wirecard_LogModel::decodeCallback($custom); if ($data) { $db = Kwf_Registry::get('db'); $date = date('Y-m-d H:i:s'); $sql = "UPDATE `kwc_shop_orders` SET\n `payment_component_id` = {$db->quote($this->getData()->parent->componentId)},\n `checkout_component_id` = {$db->quote($this->getData()->parent->parent->componentId)},\n `cart_component_class` = {$db->quote($this->getData()->parent->parent->parent->componentClass)},\n `date` = {$db->quote($date)},\n `status` = 'ordered'\n WHERE `id` = {$db->quote($data['data']['orderId'])} AND (`status` = 'processing' OR `status` = 'cart')"; $db->query($sql); Kwc_Shop_Cart_Orders::setOverriddenCartOrderId($data['data']['orderId']); if (Kwc_Shop_Cart_Orders::getCartOrderId() == $data['data']['orderId']) { Kwc_Shop_Cart_Orders::resetCartOrderId(); } } }
public function update() { $db = Kwf_Registry::get('db'); $db->query('ALTER TABLE `kwc_wirecard_log` ADD `custom` varchar(255) NOT NULL'); $db->query('ALTER TABLE `kwc_wirecard_log` ADD `callback_success` tinyint(1) NOT NULL'); $ordersModel = Kwf_Model_Abstract::getInstance('Kwc_Shop_Cart_Orders'); $logModel = Kwf_Model_Abstract::getInstance('Kwc_Shop_Cart_Checkout_Payment_Wirecard_LogModel'); foreach ($logModel->getRows() as $row) { if (!$row->custom_order_id) { continue; } $order = $ordersModel->getRow($row->custom_order_id); $custom = Kwc_Shop_Cart_Checkout_Payment_Wirecard_LogModel::getEncodedCallback($order->payment_component_id, array('orderId' => $order->id)); $row->custom = $custom; $row->callback_success = true; $row->save(); } $db->query('ALTER TABLE `kwc_wirecard_log` DROP `custom_order_id`'); }
public function processInput($data) { $custom = isset($data['custom']) ? rawurldecode($data['custom']) : null; $data = Kwc_Shop_Cart_Checkout_Payment_Wirecard_LogModel::decodeCallback($custom); if ($data) { $order = Kwf_Model_Abstract::getInstance(Kwc_Abstract::getSetting($this->getData()->getParentByClass('Kwc_Shop_Cart_Component')->componentClass, 'childModel'))->getReferencedModel('Order')->getRow($data['data']['orderId']); if ($order->status == 'processing' || $order->status == 'cart') { $order->payment_component_id = $this->getData()->parent->componentId; $order->checkout_component_id = $this->getData()->parent->parent->componentId; $order->cart_component_class = $this->getData()->parent->parent->parent->componentClass; $order->status = 'ordered'; $order->date = date('Y-m-d H:i:s'); $order->save(); } Kwc_Shop_Cart_Orders::setOverriddenCartOrderId($order->id); if (Kwc_Shop_Cart_Orders::getCartOrderId() == $order->id) { Kwc_Shop_Cart_Orders::resetCartOrderId(); } } }
protected function _afterInsert() { parent::_afterInsert(); $c = Kwc_Shop_Cart_Checkout_Payment_Wirecard_LogModel::decodeCallback($this->custom); if ($c && $c['cb']) { $ret = false; if (Kwf_Loader::isValidClass($c['cb'])) { $ret = call_user_func(array($c['cb'], 'processIpn'), $this, $c['data']); } else { if (Kwf_Component_Data_Root::getComponentClass()) { $component = Kwf_Component_Data_Root::getInstance()->getComponentById($c['cb']); if ($component) { $ret = $component->getComponent()->processIpn($this, $c['data']); } } } $this->callback_success = $ret; $this->save(); } }
protected function _getWirecardButton() { $order = Kwf_Model_Abstract::getInstance(Kwc_Abstract::getSetting($this->getData()->getParentByClass('Kwc_Shop_Cart_Component')->componentClass, 'childModel'))->getReferencedModel('Order')->getCartOrder(); $total = $this->getData()->getParentByClass('Kwc_Shop_Cart_Checkout_Component')->getComponent()->getTotal($order); $wirecardCustomerId = $this->getData()->getBaseProperty('wirecard.customerId'); $wirecardSecret = $this->getData()->getBaseProperty('wirecard.secret'); if (!$wirecardCustomerId || !$wirecardSecret) { throw new Kwf_Exception('Set wirecard settings (customerId & secret) in config!'); } $custom = Kwc_Shop_Cart_Checkout_Payment_Wirecard_LogModel::getEncodedCallback($this->getData()->parent->componentId, array('orderId' => $order->id)); $payment = $this->getData()->getParentByClass('Kwc_Shop_Cart_Checkout_Payment_Wirecard_Component'); $orderDescription = $order->firstname . ' ' . $order->lastname . ' (' . $order->zip . '), Bestellung: ' . $order->id; $params = array('secret' => $wirecardSecret, 'customerId' => $wirecardCustomerId, 'amount' => round($total, 2), 'currency' => 'EUR', 'language' => $this->getData()->getLanguage(), 'orderDescription' => $orderDescription, 'displayText' => $this->getData()->trlKwf('Thank you very much for your order.'), 'successURL' => $payment->getChildComponent('_success')->getAbsoluteUrl(), 'confirmURL' => $payment->getChildComponent('_ipn')->getAbsoluteUrl(), 'serviceURL' => $this->getData()->getSubroot()->getAbsoluteUrl(), 'failureURL' => $payment->getChildComponent('_failure')->getAbsoluteUrl(), 'cancelURL' => $payment->getChildComponent('_cancel')->getAbsoluteUrl(), 'requestFingerprintOrder' => '', 'paymentType' => Kwc_Abstract::getSetting($payment->componentClass, 'paymentType'), 'custom' => $custom); if ($shopId = $this->getData()->getBaseProperty('wirecard.shopId')) { $params['shopId'] = $shopId; } $requestFingerprintSeed = ""; $exclude = array('requestFingerprintOrder'); foreach ($params as $key => $value) { if (in_array($key, $exclude)) { continue; } $params['requestFingerprintOrder'] .= "{$key},"; $requestFingerprintSeed .= $value; } $params['requestFingerprintOrder'] .= "requestFingerprintOrder"; $requestFingerprintSeed .= $params['requestFingerprintOrder']; $params['requestFingerprint'] = md5($requestFingerprintSeed); $initURL = "https://checkout.wirecard.com/page/init.php"; $ret = "<form action=\"{$initURL}\" method=\"post\" name=\"form\">\n"; foreach ($params as $k => $i) { if ($k == 'secret') { continue; } $ret .= "<input type=\"hidden\" name=\"{$k}\" value=\"" . htmlspecialchars($i) . "\">\n"; } $ret .= "<input type=\"button\" value=\"{$this->getData()->trlKwf('Buy now')}\" class=\"submit\">\n"; $ret .= "</form>\n"; return $ret; }