Skip to content

Commit fb8533c

Browse files
committed
Release 1.0.25
1 parent 4fbddfb commit fb8533c

File tree

11 files changed

+175
-72
lines changed

11 files changed

+175
-72
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ account dashboard.
3636

3737
## Documentation
3838

39-
[Documentation](https://plugin-documentation.wallee.com/wallee-payment/jtl-5/1.0.24/docs/en/documentation.html)
39+
[Documentation](https://plugin-documentation.wallee.com/wallee-payment/jtl-5/1.0.25/docs/en/documentation.html)
4040

4141
## License
4242

Services/WalleeTransactionService.php

Lines changed: 61 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Plugin\jtl_wallee\Services;
44

5+
use JTL\Alert\Alert;
56
use JTL\Cart\CartItem;
67
use JTL\Catalog\Product\Preise;
78
use JTL\Checkout\Bestellung;
@@ -44,12 +45,18 @@ class WalleeTransactionService
4445
* @var $spaceViewId
4546
*/
4647
protected $spaceViewId;
48+
49+
/**
50+
* @var $plugin
51+
*/
52+
protected $plugin;
4753

4854
public function __construct(ApiClient $apiClient, $plugin)
4955
{
5056
$config = WalleeHelper::getConfigByID($plugin->getId());
5157
$spaceId = $config[WalleeHelper::SPACE_ID];
5258

59+
$this->plugin = $plugin;
5360
$this->apiClient = $apiClient;
5461
$this->spaceId = $spaceId;
5562
$this->spaceViewId = $config[WalleeHelper::SPACE_VIEW_ID];
@@ -80,8 +87,14 @@ public function createTransaction(Bestellung $order): Transaction
8087
$successUrl = Shop::getURL() . '/' . WalleeHelper::PLUGIN_CUSTOM_PAGES['thank-you-page'][$_SESSION['cISOSprache']];
8188
$failedUrl = Shop::getURL() . '/' . WalleeHelper::PLUGIN_CUSTOM_PAGES['fail-page'][$_SESSION['cISOSprache']];
8289

83-
$transactionPayload->setSuccessUrl($successUrl);
84-
$transactionPayload->setFailedUrl($failedUrl);
90+
$customer = $_SESSION['Kunde'];
91+
$customerEmail = $customer->cMail ?? '';
92+
$customerId = $customer->kKunde ?? '';
93+
94+
$transactionPayload->setSuccessUrl($successUrl)
95+
->setFailedUrl($failedUrl)
96+
->setCustomerEmailAddress($customerEmail)
97+
->setCustomerId($customerId);
8598

8699
$orderNr = WalleeHelper::getNextOrderNr();
87100
$transactionPayload->setMerchantReference($orderNr);
@@ -169,15 +182,30 @@ public function confirmTransaction(Transaction $transaction): void
169182
public function updateTransaction(int $transactionId)
170183
{
171184
$pendingTransaction = new TransactionPending();
172-
$pendingTransaction->setId($transactionId);
173-
174185
$transaction = $this->getTransactionFromPortal($transactionId);
175-
if (empty($transaction) || empty($transaction->getVersion())) {
176-
$_SESSION['transactionId'] = null;
177-
$createdTransactionId = $this->createTransaction();
178-
$_SESSION['transactionId'] = $createdTransactionId;
179-
return;
186+
$failedStates = [
187+
TransactionState::DECLINE,
188+
TransactionState::FAILED,
189+
TransactionState::VOIDED,
190+
];
191+
if (empty($transaction) || empty($transaction->getVersion()) || in_array($transaction->getState(), $failedStates)) {
192+
$_SESSION['transactionId'] = null;
193+
$translations = WalleeHelper::getTranslations($this->plugin->getLocalization(), [
194+
'jtl_wallee_transaction_timeout',
195+
]);
196+
197+
Shop::Container()->getAlertService()->addAlert(
198+
Alert::TYPE_ERROR,
199+
$translations['jtl_wallee_transaction_timeout'],
200+
'updateTransaction_transaction_timeout'
201+
);
202+
203+
$linkHelper = Shop::Container()->getLinkService();
204+
\header('Location: ' . $linkHelper->getStaticRoute('bestellvorgang.php') . '?editZahlungsart=1');
205+
exit;
180206
}
207+
208+
$pendingTransaction->setId($transactionId);
181209
$pendingTransaction->setVersion($transaction->getVersion());
182210

183211
$lineItems = $this->getLineItems($_SESSION['Warenkorb']->PositionenArr);
@@ -587,11 +615,32 @@ private function createBillingAddress(): AddressCreate
587615
$billingAddress->setPostalState($customer->cBundesland);
588616
$billingAddress->setOrganizationName($customer->cFirma);
589617
$billingAddress->setPhoneNumber($customer->cMobil);
590-
$billingAddress->setSalutation($customer->cTitel);
618+
619+
$company = $customer->cFirma ?? null;
620+
if ($company) {
621+
$billingAddress->setOrganizationName($company);
622+
}
623+
624+
$mobile = $customer->cMobil ?? null;
625+
if ($mobile) {
626+
$billingAddress->setMobilePhoneNumber($mobile);
627+
}
628+
629+
$phone = $customer->cTel ?? $mobile;
630+
if ($phone) {
631+
$billingAddress->setPhoneNumber($phone);
632+
}
633+
634+
$birthDate = $customer->dGeburtstag_formatted ?? null;
635+
if ($birthDate) {
636+
$birthday = new \DateTime();
637+
$birthday->setTimestamp(strtotime($birthDate));
638+
$birthday = $birthday->format('Y-m-d');
639+
$billingAddress->setDateOfBirth($birthday);
640+
}
591641

592-
$gender = $_SESSION['orderData']?->oKunde?->cAnrede ?? null;
642+
$gender = $_SESSION['orderData']?->oKunde?->cAnrede ?? '';
593643
if ($gender !== null) {
594-
595644
$billingAddress->setGender($gender === 'm' ? Gender::MALE : Gender::FEMALE);
596645
$billingAddress->setSalutation($gender === 'm' ? 'Mr' : 'Ms');
597646
}

adminmenu/AdminTabProvider.php

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,28 @@ class AdminTabProvider
5454
* @var JTLSmarty
5555
*/
5656
private $smarty;
57-
57+
58+
/**
59+
* @var ApiClient|null
60+
*/
61+
private $apiClient;
62+
63+
/**
64+
* @var WalleeTransactionService
65+
*/
66+
private $transactionService;
67+
68+
/**
69+
* @var WalleeRefundService
70+
*/
71+
private $refundService;
72+
73+
5874
/**
5975
* @param PluginInterface $plugin
76+
* @param DbInterface $db
77+
* @param JTLSmarty $smarty
6078
*/
61-
6279
public function __construct(PluginInterface $plugin, DbInterface $db, JTLSmarty $smarty)
6380
{
6481
$this->plugin = $plugin;
@@ -145,10 +162,13 @@ public function createOrdersTab(int $menuID): string
145162
$orderId = (int)$order->kBestellung;
146163
$ordObj = new Bestellung($orderId);
147164
$ordObj->fuelleBestellung(true, 0, false);
148-
$ordObj->wallee_transaction_id = $order->transaction_id;
149-
$ordObj->wallee_state = $order->state;
150-
$ordObj->total_amount = (float)$order->fGesamtsumme;
151-
$orders[$orderId] = $ordObj;
165+
$orderDetails = [
166+
'orderDetails' => $ordObj,
167+
'wallee_transaction_id' => $order->transaction_id,
168+
'wallee_state' => $order->state,
169+
'total_amount' => (float)$order->fGesamtsumme
170+
];
171+
$orders[$orderId] = $orderDetails;
152172
}
153173

154174
$paymentStatus = WalleeHelper::getPaymentStatusWithTransations($this->plugin->getLocalization());

adminmenu/templates/wallee_orders.tpl

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,41 +19,41 @@
1919
{foreach $orders as $order}
2020
<tr>
2121
<td class="text-left">
22-
<div>{$order->cBestellNr}</div>
22+
<div>{$order['orderDetails']->cBestellNr}</div>
2323
<small class="text-muted"><i class="far fa-calendar-alt"
24-
aria-hidden="true"></i> {$order->dErstellt}</small>
24+
aria-hidden="true"></i> {$order['orderDetails']->dErstellt}</small>
2525
</td>
2626
<td>
2727
<div>
28-
{if isset($order->oKunde->cVorname) || isset($order->oKunde->cNachname) || isset($order->oKunde->cFirma)}
29-
{$order->oKunde->cVorname} {$order->oKunde->cNachname}
30-
{if isset($order->oKunde->cFirma) && $order->oKunde->cFirma|strlen > 0}
31-
({$order->oKunde->cFirma})
28+
{if isset($order['orderDetails']->oKunde->cVorname) || isset($order['orderDetails']->oKunde->cNachname) || isset($order['orderDetails']->oKunde->cFirma)}
29+
{$order['orderDetails']->oKunde->cVorname} {$order['orderDetails']->oKunde->cNachname}
30+
{if isset($order['orderDetails']->oKunde->cFirma) && $order['orderDetails']->oKunde->cFirma|strlen > 0}
31+
({$order['orderDetails']->oKunde->cFirma})
3232
{/if}
3333
{else}
3434
{__('noAccount')}
3535
{/if}
3636
</div>
3737
<small class="text-muted">
3838
<i class="fa fa-user" aria-hidden="true"></i>
39-
{$order->oKunde->cMail}
39+
{$order['orderDetails']->oKunde->cMail}
4040
</small>
4141
</td>
42-
<td class="text-left">{$order->cZahlungsartName}</td>
42+
<td class="text-left">{$order['orderDetails']->cZahlungsartName}</td>
4343
<td class="text-left">
44-
{$paymentStatus[$order->cStatus]}
44+
{$paymentStatus[$order['orderDetails']->cStatus]}
4545
</td>
4646
<td class="text-left">
47-
{$order->WarensummeLocalized[0]}
47+
{$order['orderDetails']->WarensummeLocalized[0]}
4848
</td>
4949
<td onclick="showDetails({
50-
'total_amount':'{$order->total_amount}',
51-
'order_id':'{$order->kBestellung}',
52-
'order_no':'{$order->cBestellNr}',
53-
'transaction_id': '{$order->wallee_transaction_id}',
54-
'transaction_state': '{$order->wallee_state}',
55-
'action': 'order_details'
56-
})">
50+
'total_amount':'{$order['total_amount']}',
51+
'order_id':'{$order['orderDetails']->kBestellung}',
52+
'order_no':'{$order['orderDetails']->cBestellNr}',
53+
'transaction_id': '{$order['wallee_transaction_id']}',
54+
'transaction_state': '{$order['wallee_state']}',
55+
'action': 'order_details'
56+
})">
5757
<a href="#order-datails">
5858
<i class="fa fa-eye"></i>
5959
</a>

docs/en/documentation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ <h2>Documentation</h2> </div>
2323
</a>
2424
</li>
2525
<li>
26-
<a href="https://github.com/wallee-payment/jtl-5/releases/tag/1.0.24/">
26+
<a href="https://github.com/wallee-payment/jtl-5/releases/tag/1.0.25/">
2727
Source
2828
</a>
2929
</li>

frontend/Handler.php

Lines changed: 50 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -123,29 +123,32 @@ private function handleTransaction(): void
123123
}
124124

125125
if (!$createdTransactionId || !$arrayOfPossibleMethods) {
126-
if ($createdTransactionId) {
127-
$config = WalleeHelper::getConfigByID($this->plugin->getId());
128-
$spaceId = $config[WalleeHelper::SPACE_ID];
129-
$transaction = $this->apiClient->getTransactionService()->read($spaceId, $createdTransactionId);
130-
if ($transaction->getState() === TransactionState::CONFIRMED) {
131-
$_SESSION['transactionId'] = null;
132-
$createdTransactionId = $this->createTransaction();
133-
$_SESSION['transactionId'] = $createdTransactionId;
134-
} else {
135-
$this->transactionService->updateTransaction($createdTransactionId);
136-
}
126+
if (!$createdTransactionId) {
127+
$this->resetTransaction();
128+
} else {
129+
$config = WalleeHelper::getConfigByID($this->plugin->getId());
130+
$spaceId = $config[WalleeHelper::SPACE_ID];
131+
$transaction = $this->apiClient->getTransactionService()->read($spaceId, $createdTransactionId);
132+
133+
$failedStates = [
134+
TransactionState::DECLINE,
135+
TransactionState::FAILED,
136+
TransactionState::VOIDED,
137+
];
138+
139+
if (empty($transaction) || empty($transaction->getVersion()) || in_array($transaction->getState(), $failedStates)) {
140+
$this->resetTransaction();
137141
} else {
138-
$_SESSION['transactionId'] = null;
139-
$createdTransactionId = $this->createTransaction();
140-
$_SESSION['transactionId'] = $createdTransactionId;
141-
}
142-
143-
$possiblePaymentMethods = $this->fetchPossiblePaymentMethods((string)$createdTransactionId);
144-
$arrayOfPossibleMethods = [];
145-
foreach ($possiblePaymentMethods as $possiblePaymentMethod) {
146-
$arrayOfPossibleMethods[] = WalleeHelper::PAYMENT_METHOD_PREFIX . '_' . $possiblePaymentMethod->getId();
142+
$this->transactionService->updateTransaction($createdTransactionId);
147143
}
148-
$_SESSION['arrayOfPossibleMethods'] = $arrayOfPossibleMethods;
144+
}
145+
146+
$possiblePaymentMethods = $this->fetchPossiblePaymentMethods((string)$createdTransactionId);
147+
$arrayOfPossibleMethods = [];
148+
foreach ($possiblePaymentMethods as $possiblePaymentMethod) {
149+
$arrayOfPossibleMethods[] = WalleeHelper::PAYMENT_METHOD_PREFIX . '_' . $possiblePaymentMethod->getId();
150+
}
151+
$_SESSION['arrayOfPossibleMethods'] = $arrayOfPossibleMethods;
149152
}
150153
}
151154

@@ -213,8 +216,22 @@ public function cancelOrderAfterWawi(array $args): void
213216
*/
214217
public function confirmTransaction(string $spaceId, int $transactionId): void
215218
{
216-
$transaction = $this->apiClient->getTransactionService()->read($spaceId, $transactionId);
217-
$this->transactionService->confirmTransaction($transaction);
219+
$transaction = $this->apiClient->getTransactionService()->read($spaceId, $transactionId);
220+
221+
$failedStates = [
222+
TransactionState::DECLINE,
223+
TransactionState::FAILED,
224+
TransactionState::VOIDED,
225+
];
226+
227+
if (empty($transaction) || empty($transaction->getVersion()) || in_array($transaction->getState(), $failedStates)) {
228+
$_SESSION['transactionId'] = null;
229+
$linkHelper = Shop::Container()->getLinkService();
230+
\header('Location: ' . $linkHelper->getStaticRoute('bestellvorgang.php') . '?editZahlungsart=1');
231+
exit;
232+
}
233+
234+
$this->transactionService->confirmTransaction($transaction);
218235
}
219236

220237
public function getRedirectUrlAfterCreatedTransaction($orderData): string
@@ -297,5 +314,15 @@ public function setPaymentMethodLogoSize(): void
297314
pq('head')->append($paymentMethodsCss);
298315
}
299316
}
317+
318+
/**
319+
* @return void
320+
*/
321+
private function resetTransaction(): void
322+
{
323+
$_SESSION['transactionId'] = null;
324+
$createdTransactionId = $this->createTransaction();
325+
$_SESSION['transactionId'] = $createdTransactionId;
326+
}
300327

301328
}

info.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,16 @@
99
<Icon>logo.jpg</Icon>
1010
<PluginID>jtl_wallee</PluginID>
1111
<CreateDate>2023-05-29</CreateDate>
12-
<Version>1.0.24</Version>
12+
<Version>1.0.25</Version>
1313
<Install>
1414
<Locales>
15+
<Variable>
16+
<Name>jtl_wallee_transaction_timeout</Name>
17+
<VariableLocalized iso="GER">Die Transaktion ist abgelaufen</VariableLocalized>
18+
<VariableLocalized iso="ENG">Transaction was expired</VariableLocalized>
19+
<VariableLocalized iso="ITA">La transazione era scaduta</VariableLocalized>
20+
<VariableLocalized iso="FRE">La transaction a expiré</VariableLocalized>
21+
</Variable>
1522
<Variable>
1623
<Name>jtl_wallee_cancel</Name>
1724
<VariableLocalized iso="GER">Stornieren</VariableLocalized>

vendor/autoload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222

2323
require_once __DIR__ . '/composer/autoload_real.php';
2424

25-
return ComposerAutoloaderInitbb36d9e72c8b0ce3341be49810f52e97::getLoader();
25+
return ComposerAutoloaderInitfbf4f5b5940cc1faaf2d04e7841222ff::getLoader();

vendor/composer/autoload_real.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// autoload_real.php @generated by Composer
44

5-
class ComposerAutoloaderInitbb36d9e72c8b0ce3341be49810f52e97
5+
class ComposerAutoloaderInitfbf4f5b5940cc1faaf2d04e7841222ff
66
{
77
private static $loader;
88

@@ -24,12 +24,12 @@ public static function getLoader()
2424

2525
require __DIR__ . '/platform_check.php';
2626

27-
spl_autoload_register(array('ComposerAutoloaderInitbb36d9e72c8b0ce3341be49810f52e97', 'loadClassLoader'), true, true);
27+
spl_autoload_register(array('ComposerAutoloaderInitfbf4f5b5940cc1faaf2d04e7841222ff', 'loadClassLoader'), true, true);
2828
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
29-
spl_autoload_unregister(array('ComposerAutoloaderInitbb36d9e72c8b0ce3341be49810f52e97', 'loadClassLoader'));
29+
spl_autoload_unregister(array('ComposerAutoloaderInitfbf4f5b5940cc1faaf2d04e7841222ff', 'loadClassLoader'));
3030

3131
require __DIR__ . '/autoload_static.php';
32-
call_user_func(\Composer\Autoload\ComposerStaticInitbb36d9e72c8b0ce3341be49810f52e97::getInitializer($loader));
32+
call_user_func(\Composer\Autoload\ComposerStaticInitfbf4f5b5940cc1faaf2d04e7841222ff::getInitializer($loader));
3333

3434
$loader->register(true);
3535

0 commit comments

Comments
 (0)