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

Commit 99534d0

Browse files
committed
Release 1.0.29
1 parent 00db162 commit 99534d0

File tree

6 files changed

+61
-115
lines changed

6 files changed

+61
-115
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.28/docs/en/documentation.html)
14+
* [English](https://plugin-documentation.wallee.com/wallee-payment/opencart-2.0/1.0.29/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.28/LICENSE) for more information.
18+
Please see the [license file](https://github.com/wallee-payment/opencart-2.0/blob/1.0.29/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.28/">
24+
<a href="https://github.com/wallee-payment/opencart-2.0/releases/tag/1.0.29/">
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.28/">Download</a> the extension.</p>
51+
<p><a href="https://github.com/wallee-payment/opencart-2.0/releases/tag/1.0.29/">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/system/library/wallee/helper.php

Lines changed: 55 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ private function __construct(Registry $registry){
2828
$this->loggers = array(
2929
self::LOG_ERROR => $registry->get('log'),
3030
self::LOG_DEBUG => new Log('wallee_debug.log'),
31-
self::LOG_INFO => new Log('wallee_info.log')
31+
self::LOG_INFO => new Log('wallee_info.log')
3232
);
3333
}
3434
else {
@@ -108,14 +108,15 @@ public function compareStoredCustomerSessionIdentifier(){
108108
else {
109109
return false;
110110
}
111-
111+
112112
$parts = explode('_', $id);
113113
$customer = $this->getCustomer();
114114
switch ($parts[0]) {
115115
case 'customer':
116116
return isset($customer['customer_id']) && 'customer_' . $customer['customer_id'] == $id;
117117
case 'user':
118-
return (isset($customer['user_id']) && 'user_' . $customer['user_id'] == $id) || (isset($data['user_id']) && 'user_' . $data['user_id'] == $id);
118+
return (isset($customer['user_id']) && 'user_' . $customer['user_id'] == $id) ||
119+
(isset($data['user_id']) && 'user_' . $data['user_id'] == $id);
119120
case 'guest':
120121
return $this->buildGuestSessionIdentifier($customer) == $id;
121122
case 'cart':
@@ -140,17 +141,17 @@ public function getAddress($key, $order_info = array()){
140141
$session = $this->registry->get('session')->data;
141142
$address_model = $this->registry->get('model_account_address');
142143
$address = array();
143-
144+
144145
if (isset($order_info[$key . '_address'])) {
145146
$address = \WalleeHelper::mergeArray($address, $order_info[$key . '_address']);
146147
}
147148
if (isset($order_info[$key . '_address_id'])) {
148149
$address = \WalleeHelper::mergeArray($address, $address_model->getAddress($$order_info[$key . '_address_id']));
149150
}
150-
if(empty($address) && $key != 'payment') {
151+
if (empty($address) && $key != 'payment') {
151152
$address = $this->getAddress('payment', $order_info);
152153
}
153-
if(empty($address)) {
154+
if (empty($address)) {
154155
if ($customer && $customer->isLogged() && isset($session[$key . '_address_id'])) {
155156
$address = $address_model->getAddress($session[$key . '_address_id']);
156157
}
@@ -170,7 +171,7 @@ public function getAddress($key, $order_info = array()){
170171
public function refreshWebhook(){
171172
$db = $this->registry->get('db');
172173
$config = DB_PREFIX . 'setting';
173-
174+
174175
$generated = $this->getWebhookUrl();
175176
$saved = $this->registry->get('config')->get('wallee_notification_url');
176177
if ($generated == $saved) {
@@ -179,7 +180,7 @@ public function refreshWebhook(){
179180
$space_id = $this->registry->get('config')->get('wallee_space_id');
180181
\Wallee\Service\Webhook::instance($this->registry)->uninstall($space_id, $saved);
181182
\Wallee\Service\Webhook::instance($this->registry)->install($space_id, $generated);
182-
183+
183184
$store_id = $this->registry->get('config')->get('config_store_id');
184185
if ($store_id === null) {
185186
$store_id = 0;
@@ -217,22 +218,22 @@ public function areAmountsEqual($amount1, $amount2, $currency_code){
217218

218219
public function hasRunningJobs(\Wallee\Entity\TransactionInfo $transaction_info){
219220
return \Wallee\Entity\CompletionJob::countRunningForOrder($this->registry, $transaction_info->getOrderId()) +
220-
\Wallee\Entity\VoidJob::countRunningForOrder($this->registry, $transaction_info->getOrderId()) +
221-
\Wallee\Entity\RefundJob::countRunningForOrder($this->registry, $transaction_info->getOrderId()) > 0;
221+
\Wallee\Entity\VoidJob::countRunningForOrder($this->registry, $transaction_info->getOrderId()) +
222+
\Wallee\Entity\RefundJob::countRunningForOrder($this->registry, $transaction_info->getOrderId()) > 0;
222223
}
223224

224225
public function isCompletionPossible(\Wallee\Entity\TransactionInfo $transaction_info){
225226
return $transaction_info->getState() == \Wallee\Sdk\Model\TransactionState::AUTHORIZED &&
226-
(\Wallee\Entity\CompletionJob::countRunningForOrder($this->registry, $transaction_info->getOrderId()) == 0) &&
227-
(\Wallee\Entity\VoidJob::countRunningForOrder($this->registry, $transaction_info->getOrderId()) == 0);
227+
(\Wallee\Entity\CompletionJob::countRunningForOrder($this->registry, $transaction_info->getOrderId()) == 0) &&
228+
(\Wallee\Entity\VoidJob::countRunningForOrder($this->registry, $transaction_info->getOrderId()) == 0);
228229
}
229230

230231
public function isRefundPossible(\Wallee\Entity\TransactionInfo $transaction_info){
231232
if (!in_array($transaction_info->getState(),
232233
array(
233234
\Wallee\Sdk\Model\TransactionState::COMPLETED,
234235
\Wallee\Sdk\Model\TransactionState::FULFILL,
235-
\Wallee\Sdk\Model\TransactionState::DECLINE
236+
\Wallee\Sdk\Model\TransactionState::DECLINE
236237
))) {
237238
return false;
238239
}
@@ -372,14 +373,14 @@ public function dbTransactionRollback(){
372373
*/
373374
public function dbTransactionLock($space_id, $transaction_id){
374375
$db = $this->registry->get('db');
375-
376+
376377
$table = DB_PREFIX . 'wallee_transaction_info';
377378
$locked_at = date('Y-m-d H:i:s');
378379
$space_id = $db->escape($space_id);
379380
$transaction_id = $db->escape($transaction_id);
380-
381+
381382
$db->query("SELECT locked_at FROM $table WHERE transaction_id = '$transaction_id' AND space_id = '$space_id' FOR UPDATE");
382-
383+
383384
$db->query("UPDATE $table SET locked_at = '$locked_at' WHERE transaction_id = '$transaction_id' AND space_id = '$space_id'");
384385
}
385386

@@ -388,7 +389,7 @@ public function translate($strings, $language = null){
388389
if (isset($strings[$language])) {
389390
return $strings[$language];
390391
}
391-
392+
392393
if ($language) {
393394
try {
394395
$language_provider = \Wallee\Provider\Language::instance($this->registry);
@@ -434,10 +435,10 @@ public function getCleanLanguageCode($language = null){
434435
$language = $config->get('config_admin_language');
435436
}
436437
}
437-
438+
438439
$prefixWithDash = substr($language, 0, 3);
439440
$postfix = strtoupper(substr($language, 3));
440-
441+
441442
return $prefixWithDash . $postfix;
442443
}
443444

@@ -468,7 +469,7 @@ public function getCache(){
468469

469470
public function getSuccessUrl(){
470471
return WalleeVersionHelper::createUrl($this->getCatalogUrl(), 'checkout/success', array(
471-
'utm_nooverride' => 1
472+
'utm_nooverride' => 1
472473
), $this->registry->get('config')->get('config_secure'));
473474
}
474475

@@ -477,7 +478,7 @@ public function getFailedUrl($order_id){
477478
WalleeVersionHelper::createUrl($this->getCatalogUrl(), 'extension/wallee/transaction/fail',
478479
array(
479480
'order_id' => $order_id,
480-
'utm_nooverride' => 1
481+
'utm_nooverride' => 1
481482
), $this->registry->get('config')->get('config_secure')));
482483
}
483484

@@ -494,7 +495,8 @@ public function getWebhookUrl(){
494495
public function isValidOrder($order_id){
495496
if (!$this->isAdmin()) {
496497
$order_info = $this->getOrder($order_id);
497-
if ($this->registry->get('customer') && $this->registry->get('customer')->isLogged() && isset($this->registry->get('session')->data['customer_id'])) {
498+
if ($this->registry->get('customer') && $this->registry->get('customer')->isLogged() &&
499+
isset($this->registry->get('session')->data['customer_id'])) {
498500
if ($this->registry->get('session')->data['customer_id'] != $order_info['customer_id']) {
499501
return false;
500502
}
@@ -539,6 +541,21 @@ public function addOrderHistory($order_id, $status, $message = '', $notify = fal
539541
$this->registry->get('model_checkout_order')->addOrderHistory($order_id, $status, $message, $notify);
540542
}
541543

544+
public function ensurePaymentCode(array $order_info, \Wallee\Sdk\Model\Transaction $transaction){
545+
$code = 'wallee_' . $transaction->getPaymentConnectorConfiguration()->getPaymentMethodConfiguration()->getId();
546+
if ($order_info['payment_code'] == $code) {
547+
return;
548+
}
549+
$db = $this->registry->get('db');
550+
$table = DB_PREFIX . 'order';
551+
$code = $db->escape($code);
552+
$title = $db->escape($transaction->getPaymentConnectorConfiguration()->getPaymentMethodConfiguration()->getName());
553+
$order_id = $db->escape($order_info['order_id']);
554+
$query = "UPDATE `$table` SET `payment_code`='$code', `payment_method`='$title' WHERE `order_id`='$order_id';";
555+
$this->log("Changing payment method on order: [" . $query . "], was [" . $order_info['payment_code'] . "]", self::LOG_DEBUG);
556+
$db->query($query);
557+
}
558+
542559
/**
543560
*
544561
* @return Url
@@ -580,10 +597,10 @@ private function getStoreUrl($ssl = true){
580597
public function rewrite($url){
581598
return str_replace(array(
582599
HTTP_SERVER,
583-
HTTPS_SERVER
600+
HTTPS_SERVER
584601
), array(
585602
HTTP_CATALOG,
586-
HTTPS_CATALOG
603+
HTTPS_CATALOG
587604
), $url);
588605
}
589606

@@ -614,30 +631,31 @@ public function getLimitEnd($page){
614631
$limit = $this->registry->get('config')->get('config_limit_admin');
615632
return $page * $limit;
616633
}
617-
634+
618635
/**
619-
* Disable inc vat setting in xfeepro. Necessary to ensure taxes are calculated and transmitted correctly.
636+
* Disable inc vat setting in xfeepro.
637+
* Necessary to ensure taxes are calculated and transmitted correctly.
620638
*/
621-
public function xfeeproDisableIncVat() {
639+
public function xfeeproDisableIncVat(){
622640
$config = $this->registry->get('config');
623641
$xfeepro = $config->get('xfeepro');
624-
if($xfeepro) {
642+
if ($xfeepro) {
625643
$xfeepro = unserialize(base64_decode($xfeepro));
626644
$this->xfeepro = $xfeepro;
627-
if(isset($xfeepro['inc_vat'])) {
628-
foreach($xfeepro['inc_vat'] as $i => $value) {
645+
if (isset($xfeepro['inc_vat'])) {
646+
foreach ($xfeepro['inc_vat'] as $i => $value) {
629647
$xfeepro['inc_vat'][$i] = 0;
630-
}
648+
}
631649
}
632650
$config->set('xfeepro', base64_encode(serialize($xfeepro)));
633651
}
634652
}
635-
653+
636654
/**
637655
* Restore xfeepro settings.
638656
*/
639-
public function xfeeProRestoreIncVat() {
640-
if($this->xfeepro) {
657+
public function xfeeProRestoreIncVat(){
658+
if ($this->xfeepro) {
641659
$this->registry->get('config')->set('xfeepro', base64_encode(serialize($this->xfeepro)));
642660
}
643661
}
@@ -648,8 +666,8 @@ public static function instance(Registry $registry){
648666
}
649667
return self::$instance;
650668
}
651-
652-
public static function extractPaymentMethodId($code) {
669+
670+
public static function extractPaymentMethodId($code){
653671
return substr($code, strlen('wallee_'));
654672
}
655673

@@ -669,7 +687,7 @@ public static function isEditableState($state){
669687
$completable_states = array(
670688
\Wallee\Sdk\Model\TransactionState::AUTHORIZED,
671689
\Wallee\Sdk\Model\TransactionState::CONFIRMED,
672-
\Wallee\Sdk\Model\TransactionState::PROCESSING
690+
\Wallee\Sdk\Model\TransactionState::PROCESSING
673691
);
674692
return in_array($state, $completable_states);
675693
}

upload/system/library/wallee/service/transaction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ public function updateTransactionInfo(\Wallee\Sdk\Model\Transaction $transaction
327327
$transaction->getPaymentConnectorConfiguration() != null ? $transaction->getPaymentConnectorConfiguration()->getConnector() : null);
328328
$info->setPaymentMethodId(
329329
$transaction->getPaymentConnectorConfiguration() != null && $transaction->getPaymentConnectorConfiguration()->getPaymentMethodConfiguration() !=
330-
null ? $transaction->getPaymentConnectorConfiguration()->getPaymentMethodConfiguration()->getPaymentMethod() : null);
330+
null ? $transaction->getPaymentConnectorConfiguration()->getPaymentMethodConfiguration()->getPaymentMethod() : null);
331331
$info->setImage($this->getPaymentMethodImage($transaction));
332332
$info->setLabels($this->getTransactionLabels($transaction));
333333
if ($transaction->getState() == \Wallee\Sdk\Model\TransactionState::FAILED ||

upload/system/library/wallee/version_helper.php

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -141,72 +141,4 @@ public static function createUrl(\Url $url_provider, $route, $query, $ssl){
141141
}
142142
return $url_provider->link($route, $query, $ssl);
143143
}
144-
145-
public static function getOrderTotals($registry){
146-
// Load total extensions
147-
$registry->get('load')->model('setting/extension');
148-
$totalExtensions = $registry->get('model_setting_extension')->getExtensions('total');
149-
$orderedKeys = array();
150-
foreach ($totalExtensions as $key => $value) {
151-
$orderedKeys[$key] = $registry->get('config')->get($value['code'] . '_sort_order');
152-
}
153-
array_multisort($orderedKeys, SORT_ASC, $totalExtensions);
154-
155-
$resolvedData = self::buildOrderTotalData($registry, $totalExtensions);
156-
157-
$taxAmounts = $resolvedData['taxAmounts'];
158-
$totalData = $resolvedData['totalData'];
159-
160-
// Calculate the tax rates (aggregated per position)
161-
foreach ($totalData as $id => $data) {
162-
$key = $data['code'];
163-
$taxRate = 0;
164-
165-
$totalData[$id]['value'] = self::formatAmount($totalData[$id]['value']);
166-
167-
if (isset($taxAmounts[$key]) && $taxAmounts[$key] > 0 && $totalData[$id]['value'] != 0) {
168-
$taxAmounts[$key] = self::formatAmount($taxAmounts[$key]);
169-
$taxRate = round(abs($taxAmounts[$key] / $totalData[$id]['value'] * 100), 4);
170-
}
171-
$totalData[$id]['tax_rate'] = $taxRate;
172-
}
173-
174-
return $totalData;
175-
}
176-
177-
private function formatAmount(\Registry $registry, $amount){
178-
//TODO helper / version helper moving
179-
return $registry->get('currency')->getValue($currency) * $amount;
180-
}
181-
182-
private static function getCurrency(\Registry $registry){
183-
if (isset($registry->get('session')->data['currency'])) {
184-
return $registry->get('session')->data['currency'];
185-
}
186-
return $registry->get('config')->get('config_currency');
187-
}
188-
189-
private static function buildOrderTotalData($registry, $totalExtensions){
190-
$taxAmounts = array();
191-
$totalData = array();
192-
$total = 0;
193-
foreach ($totalExtensions as $extension) {
194-
if ($registry->get('config')->get($extension['code'] . '_status')) {
195-
$registry->get('load')->model('total/' . $extension['code']);
196-
197-
$taxes = array();
198-
$registry->get('model_total_' . $extension['code'])->getTotal($totalData, $total, $taxes);
199-
$amount = 0;
200-
201-
foreach ($taxes as $value) {
202-
$amount += $value;
203-
}
204-
$taxAmounts[$extension['code']] = $amount;
205-
}
206-
}
207-
return array(
208-
'taxAmounts' => $taxAmounts,
209-
'totalData' => $totalData
210-
);
211-
}
212144
}

0 commit comments

Comments
 (0)