Skip to content
This repository was archived by the owner on Jan 25, 2024. It is now read-only.

Commit 0575e4d

Browse files
committed
Release 1.0.11
1 parent 02c020a commit 0575e4d

File tree

13 files changed

+246
-105
lines changed

13 files changed

+246
-105
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ This repository contains the OpenCart wallee payment module that enables the sh
1111

1212
## Documentation
1313

14-
* [English](https://plugin-documentation.wallee.com/wallee-payment/opencart-2.0/1.0.10/docs/en/documentation.html)
14+
* [English](https://plugin-documentation.wallee.com/wallee-payment/opencart-2.0/1.0.11/docs/en/documentation.html)
1515

1616
## License
1717

18-
Please see the [license file](https://github.com/wallee-payment/opencart-2.0/blob/1.0.10/LICENSE) for more information.
18+
Please see the [license file](https://github.com/wallee-payment/opencart-2.0/blob/1.0.11/LICENSE) for more information.

docs/en/documentation.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ <h2>Documentation</h2> </div>
2121
</a>
2222
</li>
2323
<li>
24-
<a href="https://github.com/wallee-payment/opencart-2.0/releases/tag/1.0.10/">
24+
<a href="https://github.com/wallee-payment/opencart-2.0/releases/tag/1.0.11/">
2525
Source
2626
</a>
2727
</li>
@@ -48,7 +48,7 @@ <h1>
4848
<div class="olist arabic">
4949
<ol class="arabic">
5050
<li>
51-
<p><a href="https://github.com/wallee-payment/opencart-2.0/releases/tag/1.0.10/">Download</a> the extension.</p>
51+
<p><a href="https://github.com/wallee-payment/opencart-2.0/releases/tag/1.0.11/">Download</a> the extension.</p>
5252
</li>
5353
<li>
5454
<p>Extract the files and upload the content of the <code>Upload</code> directory into the root directory of your store using FTP/SSH.</p>

upload/catalog/controller/extension/wallee/event.php

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function includeDeviceIdentifier(){
1919
$script .= '/s/[spaceId]/payment/device.js?sessionIdentifier=[UniqueSessionIdentifier]';
2020

2121
$this->setDeviceCookie();
22-
22+
2323
$script = str_replace(array(
2424
'[spaceId]',
2525
'[UniqueSessionIdentifier]'
@@ -81,15 +81,29 @@ public function canSaveOrder($order_info){
8181
}
8282

8383
if (!empty($new_order)) {
84-
\WalleeHelper::instance($this->registry)->log($this->language->get('error_order_edit') . " ($order_id)", \WalleeHelper::LOG_ERROR);
84+
\WalleeHelper::instance($this->registry)->log($this->language->get('error_order_edit') . " ($order_id)",
85+
\WalleeHelper::LOG_ERROR);
8586

86-
$this->language->load('payment/wallee');
87-
$this->response->addHeader('Content-Type: application/json');
88-
$this->response->setOutput(json_encode(array(
89-
'error' => $this->language->get('error_order_edit')
90-
)));
91-
$this->response->output();
92-
die();
87+
if ($this->request->get['route'] == 'checkout/checkout') {
88+
// ensure reload without order_id
89+
unset($this->session->data['order_id']);
90+
\Wallee\Service\Transaction::instance($this->registry)->waitForStates($this->request->get['order_id'],
91+
array(
92+
\Wallee\Sdk\Model\TransactionState::FAILED
93+
), 5);
94+
$transaction_info = \Wallee\Entity\TransactionInfo::loadByOrderId($this->registry, $order_id);
95+
$this->session->data['error'] = $transaction_info->getFailureReason();
96+
$this->response->redirect($this->createUrl('checkout/checkout', $this->request->get));
97+
}
98+
else {
99+
$this->language->load('payment/wallee');
100+
$this->response->addHeader('Content-Type: application/json');
101+
$this->response->setOutput(json_encode(array(
102+
'error' => $this->language->get('error_order_edit')
103+
)));
104+
$this->response->output();
105+
die();
106+
}
93107
}
94108
}
95109

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
require_once modification(DIR_SYSTEM . 'library/wallee/helper.php');
3+
use Wallee\Controller\AbstractController;
4+
5+
class ControllerExtensionWalleeTransaction extends AbstractController {
6+
7+
public function fail(){
8+
if (isset($this->request->get['order_id']) &&
9+
\Wallee\Service\Transaction::instance($this->registry)->waitForStates($this->request->get['order_id'],
10+
array(
11+
\Wallee\Sdk\Model\TransactionState::FAILED
12+
), 5)) {
13+
$transaction_info = \Wallee\Entity\TransactionInfo::loadByOrderId($this->registry, $this->request->get['order_id']);
14+
unset($this->registry->get('session')->data['order_id']);
15+
$this->session->data['error'] = $transaction_info->getFailureReason();
16+
}
17+
else {
18+
$this->session->data['error'] = $this->language->get('error'); //TODO error text
19+
}
20+
$this->response->redirect($this->createUrl('checkout/checkout', ''));
21+
}
22+
23+
protected function getRequiredPermission(){
24+
return '';
25+
}
26+
}

upload/catalog/view/javascript/wallee.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@
8080
Wallee.handler
8181
.setInitializeCallback(this.initialized);
8282
Wallee.handler
83-
.setValidationCallback(this.validated);
83+
.setValidationCallback(this.validated);
84+
Wallee.handler
85+
.setEnableSubmitCallback(this.enableConfirmButton);
86+
Wallee.handler
87+
.setDisableSubmitCallback(this.disableConfirmButton);
8488
Wallee.handler
8589
.create('wallee-iframe-container');
8690
}

upload/catalog/view/theme/default/template/payment/wallee/iframe.tpl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
</div>
66
<div style="padding: 15px;">
77
<div id="wallee-iframe-spinner" class="text-center">
8-
<i style="font-size: 12em;"
9-
class='fa fa-spinner fa-spin '></i>
10-
</div>
11-
<div id="wallee-iframe-container" class="text-center" style="display:none;">
8+
<i style="font-size: 12em;" class='fa fa-spinner fa-spin '></i>
129
</div>
10+
<div id="wallee-iframe-container" class="text-center"
11+
style="display: none;"></div>
1312

14-
<div class="buttons" style="overflow:hidden;">
13+
<div class="buttons" style="overflow: hidden;">
1514
<div class="pull-right">
1615
<input type="button" value="<?php echo $button_confirm; ?>"
1716
id="button-confirm" class="btn btn-primary"
@@ -24,11 +23,14 @@
2423
<script type="text/javascript">
2524
function initWalleeIframe(){
2625
if(typeof Wallee === 'undefined') {
27-
setTimeout(initWalleeIframe, 500);
26+
Window.loadWalleeTimeout = setTimeout(initWalleeIframe, 500);
2827
} else {
2928
Wallee.init('<?php echo $configuration_id; ?>');
3029
}
3130
}
31+
if(typeof Window.loadWalleeTimeout !== 'undefined') {
32+
clearTimeout(Window.loadWalleeTimeout);
33+
}
3234
jQuery().ready(initWalleeIframe);
3335
</script>
3436
</div>

upload/system/library/wallee/dynamic/catalog/controller.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function confirm(){
4040
catch (Exception $e) {
4141
\WalleeHelper::instance($this->registry)->dbTransactionRollback();
4242
\WalleeHelper::instance($this->registry)->log($e->getMessage(), \WalleeHelper::LOG_ERROR);
43+
$this->load->language('payment/wallee');
4344
$result['message'] = $this->language->get('error_confirmation');
4445
unset($this->session->data['order_id']); // this order number cannot be used anymore
4546
}
@@ -49,7 +50,7 @@ public function confirm(){
4950
}
5051

5152
private function confirmTransaction(){
52-
$transaction = Wallee\Service\Transaction::instance($this->registry)->getTransaction(array(), false,
53+
$transaction = Wallee\Service\Transaction::instance($this->registry)->getTransaction($this->getOrderInfo(), false,
5354
array(
5455
\Wallee\Sdk\Model\TransactionState::PENDING
5556
));
@@ -63,6 +64,14 @@ private function confirmTransaction(){
6364

6465
throw new Exception('Transaction is not pending.');
6566
}
67+
68+
private function getOrderInfo() {
69+
if(!isset($this->session->data['order_id'])) {
70+
throw new Exception("No order_id to confirm.");
71+
}
72+
$this->load->model('checkout/order');
73+
return $this->model_checkout_order->getOrder($this->session->data['order_id']);
74+
}
6675

6776
protected function getRequiredPermission(){
6877
return '';

upload/system/library/wallee/helper.php

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class WalleeHelper {
1414
* @var Registry
1515
*/
1616
private $registry;
17+
private $xfeepro;
1718
private static $instance;
1819
private $catalog_url;
1920
const LOG_INFO = 2;
@@ -302,7 +303,7 @@ public function getCustomer(){
302303
}
303304
return array();
304305
}
305-
306+
306307
/**
307308
* Formats the given amount for the given currency.
308309
* If no currency is given, the current session currency is used. If that is not set the shop configuration is used.
@@ -317,7 +318,7 @@ public function formatAmount($amount, $currency = null){
317318
}
318319
return $this->registry->get('currency')->format($amount, $currency, false, false);
319320
}
320-
321+
321322
/**
322323
* Rounds the amount like Xfee would
323324
*
@@ -331,7 +332,7 @@ public function roundXfeeAmount($amount, $currency = null){
331332
}
332333
$decimals = $this->registry->get('currency')->getDecimalPlace();
333334
$mode = PHP_ROUND_HALF_UP;
334-
if($amount < 0) {
335+
if ($amount < 0) {
335336
$mode = PHP_ROUND_HALF_DOWN;
336337
}
337338
return round($amount, $decimals, $mode);
@@ -461,15 +462,18 @@ public function getCache(){
461462
}
462463

463464
public function getSuccessUrl(){
464-
return WalleeVersionHelper::createUrl($this->getCatalogUrl(), 'checkout/success', '',
465-
$this->registry->get('config')->get('config_secure'));
465+
return WalleeVersionHelper::createUrl($this->getCatalogUrl(), 'checkout/success', array(
466+
'utm_nooverride' => 1
467+
), $this->registry->get('config')->get('config_secure'));
466468
}
467469

468470
public function getFailedUrl($order_id){
469471
return str_replace('&amp;', '&',
470-
WalleeVersionHelper::createUrl($this->getCatalogUrl(), 'checkout/checkout', array(
471-
'order_id' => $order_id
472-
), $this->registry->get('config')->get('config_secure')));
472+
WalleeVersionHelper::createUrl($this->getCatalogUrl(), 'extension/wallee/transaction/fail',
473+
array(
474+
'order_id' => $order_id,
475+
'utm_nooverride' => 1
476+
), $this->registry->get('config')->get('config_secure')));
473477
}
474478

475479
public function getWebhookUrl(){
@@ -605,6 +609,31 @@ public function getLimitEnd($page){
605609
$limit = $this->registry->get('config')->get('config_limit_admin');
606610
return $page * $limit;
607611
}
612+
613+
/**
614+
* Disable inc vat setting in xfeepro. Necessary to ensure taxes are calculated and transmitted correctly.
615+
*/
616+
public function xfeeproDisableIncVat() {
617+
$config = $this->registry->get('config');
618+
$xfeepro = $config->get('xfeepro');
619+
if($xfeepro) {
620+
$xfeepro = unserialize(base64_decode($xfeepro));
621+
$this->xfeepro = $xfeepro;
622+
foreach($xfeepro['inc_vat'] as $i => $value) {
623+
$xfeepro['inc_vat'][$i] = 0;
624+
}
625+
$config->set('xfeepro', base64_encode(serialize($xfeepro)));
626+
}
627+
}
628+
629+
/**
630+
* Restore xfeepro settings.
631+
*/
632+
public function xfeeProRestoreIncVat() {
633+
if($this->xfeepro) {
634+
$this->registry->get('config')->set('xfeepro', base64_encode(serialize($this->xfeepro)));
635+
}
636+
}
608637

609638
public static function instance(Registry $registry){
610639
if (self::$instance === null) {

upload/system/library/wallee/modification/WalleeCore.ocmod.xml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,9 @@
33
<code>WalleeCore</code>
44
<name>wallee core: load payment methods.
55
</name>
6-
<version>1.0.2</version>
6+
<version>1.0.3</version>
77
<author>Customweb GmbH</author>
88
<link>http://github.com/wallee-payment/opencart</link>
9-
<file path="catalog/controller/checkout/checkout.php">
10-
<operation>
11-
<search><![CDATA[
12-
if (isset($this->session->data['error'])) {
13-
]]></search>
14-
<add position="before"><![CDATA[
15-
require_once modification(DIR_SYSTEM . 'library/wallee/helper.php');
16-
if (isset($this->request->get['order_id']) && \WalleeHelper::instance($this->registry)->isValidOrder($this->request->get['order_id'])
17-
&& \Wallee\Service\Transaction::instance($this->registry)->waitForStates($this->request->get['order_id'], array(\Wallee\Sdk\Model\TransactionState::FAILED), 5)) {
18-
$transaction_info = \Wallee\Entity\TransactionInfo::loadByOrderId($this->registry, $this->request->get['order_id']);
19-
unset($this->registry->get('session')->data['order_id']);
20-
$data['error_warning'] = $transaction_info->getFailureReason();
21-
} else
22-
]]></add>
23-
</operation>
24-
</file>
259
<file path="admin/controller/extension/payment.php">
2610
<operation>
2711
<search><![CDATA[

upload/system/library/wallee/modification/WalleeJournalCompatibility.ocmod.xml

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)