-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from koala-framework/qenta-checkout
Replace wirecard payment page v2 with qenta checkout
- Loading branch information
Showing
20 changed files
with
246 additions
and
341 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
...out/Payment/Wirecard/Cancel/Component.php → ...eckout/Payment/Qenta/Cancel/Component.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
<?php | ||
class KwcShop_Kwc_Shop_Cart_Checkout_Payment_Wirecard_Cancel_Component extends Kwc_Abstract | ||
class KwcShop_Kwc_Shop_Cart_Checkout_Payment_Qenta_Cancel_Component extends Kwc_Abstract | ||
{ | ||
public static function getSettings($param = null) | ||
{ | ||
$ret = parent::getSettings($param); | ||
$ret['contentSender'] = 'KwcShop_Kwc_Shop_Cart_Checkout_Payment_Wirecard_Cancel_ContentSender'; | ||
$ret['contentSender'] = 'KwcShop_Kwc_Shop_Cart_Checkout_Payment_Qenta_Cancel_ContentSender'; | ||
return $ret; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
KwcShop/Kwc/Shop/Cart/Checkout/Payment/Qenta/Cancel/ContentSender.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
class KwcShop_Kwc_Shop_Cart_Checkout_Payment_Qenta_Cancel_ContentSender extends Kwf_Component_Abstract_ContentSender_Default | ||
{ | ||
public function sendContent($includeMaster) | ||
{ | ||
$session = new Kwf_Session_Namespace('kwcShopCart'); | ||
if (!$orderId = $session->qentaCartId && isset($_POST['babytuch_orderId'])) { | ||
$orderId = $_POST['babytuch_orderId']; | ||
} | ||
if ($orderId) { | ||
KwcShop_Kwc_Shop_Cart_Orders::setCartOrderId($orderId); | ||
$order = Kwf_Model_Abstract::getInstance(Kwc_Abstract::getSetting($this->_data->parent->parent->parent->componentClass, 'childModel')) | ||
->getReferencedModel('Order')->getCartOrder(); | ||
$order->status = 'cart'; | ||
$order->save(); | ||
unset($session->qentaCartId); | ||
} | ||
Kwf_Util_Redirect::redirect($this->_data->parent->parent->parent->getUrl()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
KwcShop/Kwc/Shop/Cart/Checkout/Payment/Qenta/ConfirmLink/Component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
var onReady = require('kwf/commonjs/on-ready'); | ||
var $ = require('jQuery'); | ||
|
||
onReady.onRender('.kwcClass', function(el) { | ||
var form = el.find('form'); | ||
form.one('submit', function(e) { | ||
e.preventDefault(); | ||
el.find('.kwcBem__process').show(); | ||
form.hide(); | ||
var config = el.data('options'); | ||
$.post(config.confirmOrderUrl, config.params) | ||
.done(function (response) { | ||
form.submit(); | ||
}); | ||
}); | ||
}); |
110 changes: 110 additions & 0 deletions
110
KwcShop/Kwc/Shop/Cart/Checkout/Payment/Qenta/ConfirmLink/Component.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?php | ||
class KwcShop_Kwc_Shop_Cart_Checkout_Payment_Qenta_ConfirmLink_Component extends Kwc_Abstract | ||
{ | ||
public static function getSettings($param = null) | ||
{ | ||
$ret = parent::getSettings($param); | ||
$ret['viewCache'] = false; | ||
return $ret; | ||
} | ||
|
||
public function getTemplateVars(Kwf_Component_Renderer_Abstract $renderer) | ||
{ | ||
$ret = parent::getTemplateVars($renderer); | ||
$controllerBaseUrl = Kwc_Admin::getInstance($this->getData()->componentClass)->getControllerUrl(); | ||
$ret['wirecardButton'] = $this->_getWirecardButton(); | ||
$ret['options'] = array( | ||
'confirmOrderUrl' => "$controllerBaseUrl/json-confirm-order", | ||
'initiatePaymentUrl' => "$controllerBaseUrl/json-initiate-payment", | ||
'params' => array( | ||
'paymentComponentId' => $this->getData()->parent->componentId | ||
) | ||
); | ||
return $ret; | ||
} | ||
|
||
//used in trl | ||
public static function buildWirecardButtonHtml($params, $payment, $order, $paymentUrl) | ||
{ | ||
$postData = array( | ||
'customerId' => Kwf_Config::getValue('qenta.customerId'), | ||
'consumerBillingFirstname' => $order->firstname, | ||
'consumerBillingLastname' => $order->lastname, | ||
'consumerEmail' => $order->email, | ||
'consumerBillingAddress1' => $order->street, | ||
'consumerBillingCity' => $order->city, | ||
'consumerBillingCountry' => $order->country, | ||
'consumerBillingZipCode' => $order->zip, | ||
'consumerChallengeIndicator' => '04', | ||
'merchantTokenizationFlag' => 'true', | ||
'orderDescription' => $order->firstname . ' ' . $order->lastname . ' (' . $order->zip . ') '.$payment->trlKwf('Order: {0}', $order->number), | ||
'customerStatement' => trl("Bestellung Nr. {$order->number}"), // bank statement | ||
'duplicateRequestCheck' => 'no', | ||
'successUrl' => $payment->getChildComponent('_success')->getAbsoluteUrl(), | ||
'cancelUrl' => $payment->getChildComponent('_cancel')->getAbsoluteUrl(), | ||
'serviceUrl' => $payment->getChildComponent('_cancel')->getAbsoluteUrl(), | ||
'failureUrl' => $payment->getChildComponent('_failure')->getAbsoluteUrl(), | ||
'language' => $payment->getLanguage(), | ||
'amount' => $params['amount'], | ||
'currency' => $params['currency'], | ||
'paymentType' => $params['paymentType'], | ||
'orderReference' => $params['orderId'], | ||
'babytuch_orderId' => $order->id | ||
); | ||
$postData['requestFingerprintOrder'] = self::_getRequestFingerprintOrder($postData); | ||
$postData['requestFingerprint'] = self::_getRequestFingerprint($postData, Kwf_Config::getValue('qenta.secret')); | ||
|
||
$ret = "<form action=\"$paymentUrl\" method=\"post\" name=\"form\">\n"; | ||
foreach ($postData as $k=>$i) { | ||
if ($k == 'secret') continue; | ||
$ret .= "<input type=\"hidden\" name=\"$k\" value=\"".Kwf_Util_HtmlSpecialChars::filter($i)."\">\n"; | ||
} | ||
$ret .= "<input type=\"submit\" value=\"{$payment->trlKwf('Buy now')}\" class=\"submit\">\n"; | ||
$ret .= "</form>\n"; | ||
return $ret; | ||
|
||
} | ||
|
||
protected function _getWirecardButton() | ||
{ | ||
$order = Kwf_Model_Abstract::getInstance(Kwc_Abstract::getSetting( | ||
$this->getData()->getParentByClass('KwcShop_Kwc_Shop_Cart_Component')->componentClass, 'childModel' | ||
))->getReferencedModel('Order')->getCartOrder(); | ||
$total = $this->getData()->getParentByClass('KwcShop_Kwc_Shop_Cart_Checkout_Component') | ||
->getComponent()->getTotal($order); | ||
|
||
$payment = $this->getData()->getParentByClass('KwcShop_Kwc_Shop_Cart_Checkout_Payment_Qenta_Component'); | ||
|
||
$params = array( | ||
'amount' => round($total, 2), | ||
'currency' => 'EUR', | ||
'paymentType' => Kwc_Abstract::getSetting($payment->componentClass, 'paymentType'), | ||
'orderId' => $order->id | ||
); | ||
$paymentUrl = Kwf_Config::getValue('qenta.url'); | ||
|
||
return self::buildWirecardButtonHtml($params, $payment, $order, $paymentUrl); | ||
} | ||
|
||
protected static function _getRequestFingerprintOrder($postData) | ||
{ | ||
$ret = ''; | ||
foreach ($postData as $key => $value) { | ||
$ret .= "{$key},"; | ||
} | ||
$ret .= 'requestFingerprintOrder,secret'; | ||
|
||
return $ret; | ||
} | ||
|
||
protected static function _getRequestFingerprint($postData, $secret) | ||
{ | ||
$ret = ''; | ||
foreach ($postData as $key => $value) { | ||
$ret .= "{$value}"; | ||
} | ||
$ret .= "{$secret}"; | ||
|
||
return hash_hmac('sha512', $ret, $secret); | ||
} | ||
} |
File renamed without changes.
24 changes: 24 additions & 0 deletions
24
KwcShop/Kwc/Shop/Cart/Checkout/Payment/Qenta/ConfirmLink/Controller.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
class KwcShop_Kwc_Shop_Cart_Checkout_Payment_Qenta_ConfirmLink_Controller extends Zend_Controller_Action | ||
{ | ||
// is called by js, so it might be that this code isn't called at all | ||
public function jsonConfirmOrderAction() | ||
{ | ||
$component = Kwf_Component_Data_Root::getInstance() | ||
->getComponentById($this->_getParam('paymentComponentId')); | ||
$order = Kwf_Model_Abstract::getInstance(Kwc_Abstract::getSetting($component->getParentByClass('KwcShop_Kwc_Shop_Cart_Component')->componentClass, 'childModel')) | ||
->getReferencedModel('Order')->getCartOrder(); | ||
if ($order && $component && | ||
is_instance_of($component->componentClass, 'KwcShop_Kwc_Shop_Cart_Checkout_Payment_Qenta_Component') | ||
) { | ||
$order->payment_component_id = $component->componentId; | ||
$order->checkout_component_id = $component->parent->componentId; | ||
$order->cart_component_class = $component->parent->parent->componentClass; | ||
$order->status = 'processing'; | ||
$order->date = date('Y-m-d H:i:s'); | ||
$order->save(); | ||
$session = new Kwf_Session_Namespace('kwcShopCart'); | ||
$session->qentaCartId = $order->id; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
KwcShop/Kwc/Shop/Cart/Checkout/Payment/Qenta/Failure/Component.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
class KwcShop_Kwc_Shop_Cart_Checkout_Payment_Qenta_Failure_Component extends Kwc_Editable_Component | ||
{ | ||
public static function getSettings($param = null) | ||
{ | ||
$ret = parent::getSettings($param); | ||
$ret['flags']['processInput'] = true; | ||
return $ret; | ||
} | ||
|
||
public function getNameForEdit() | ||
{ | ||
$ret = trlKwf('Shop Error Text'); | ||
$subroot = $this->getData()->getSubroot(); | ||
if ($subroot && isset($subroot->id)) $ret .= ' (' .$this->getData()->getSubroot()->id . ')'; | ||
$ret .= ' ' . Kwf_Trl::getInstance()->trlStaticExecute(Kwc_Abstract::getSetting($this->getData()->parent->componentClass, 'componentName')); | ||
return $ret; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ayment/Wirecard/Success/Trl/Component.php → ...t/Payment/Qenta/Success/Trl/Component.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.