Skip to content

Commit b341ebb

Browse files
Release 2.1.12
1 parent f205c06 commit b341ebb

File tree

15 files changed

+91
-17
lines changed

15 files changed

+91
-17
lines changed

Model/Service/Quote/TransactionService.php

+45-4
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,22 @@ public function __construct(ResourceConnection $resource,Helper $helper, ScopeCo
119119
$this->logger = $logger;
120120
}
121121

122+
/**
123+
* Gets the payment URL in the session if exists.
124+
*
125+
* @param Quote $quote
126+
* @return string|null
127+
*/
128+
private function getPaymentUrlInSession(Quote $quote)
129+
{
130+
$url = $this->checkoutSession->getPaymentUrl();
131+
$transactionId = $quote->getWalleeTransactionId();
132+
if ($url && preg_match('/transactionId=(\d+)/', $url, $matches)
133+
&& isset($matches[1]) && $matches[1] == $transactionId) {
134+
return $url;
135+
}
136+
}
137+
122138
/**
123139
* Gets the URL to the JavaScript library that is required to display the iframe payment form.
124140
*
@@ -127,10 +143,17 @@ public function __construct(ResourceConnection $resource,Helper $helper, ScopeCo
127143
*/
128144
public function getJavaScriptUrl(Quote $quote)
129145
{
146+
$url = $this->getPaymentUrlInSession($quote);
147+
if ($url !== null) {
148+
$this->logger->debug("QUOTE-TRANSACTION-SERVICE::getJavaScriptUrl URL already exists: ".$url);
149+
return $url;
150+
}
151+
130152
$transaction = $this->getTransactionByQuote($quote);
131153
$url = $this->apiClient->getService(TransactionIframeService::class)->javascriptUrl(
132154
$transaction->getLinkedSpaceId(), $transaction->getId());
133-
$this->logger->debug("QUOTE-TRANSACTION-SERVICE::getJavaScriptUrl URL: ".$url);
155+
$this->checkoutSession->setPaymentUrl($url);
156+
$this->logger->debug("QUOTE-TRANSACTION-SERVICE::getJavaScriptUrl new URL: ".$url);
134157
return $url;
135158
}
136159

@@ -142,10 +165,18 @@ public function getJavaScriptUrl(Quote $quote)
142165
*/
143166
public function getLightboxUrl(Quote $quote)
144167
{
168+
$url = $this->getPaymentUrlInSession($quote);
169+
if ($url !== null) {
170+
$this->logger->debug("QUOTE-TRANSACTION-SERVICE::getLightboxUrl API CALL URL already exists: ".$url);
171+
return $url;
172+
}
173+
145174
$transaction = $this->getTransactionByQuote($quote);
146-
$this->logger->debug("QUOTE-TRANSACTION-SERVICE::getLightboxUrl API CALL");
147-
return $this->apiClient->getService(TransactionLightboxService::class)->javascriptUrl(
175+
$url = $this->apiClient->getService(TransactionLightboxService::class)->javascriptUrl(
148176
$transaction->getLinkedSpaceId(), $transaction->getId());
177+
$this->checkoutSession->setPaymentUrl($url);
178+
$this->logger->debug("QUOTE-TRANSACTION-SERVICE::getLightboxUrl new API CALL URL: ".$url);
179+
return $url;
149180
}
150181

151182
/**
@@ -156,10 +187,16 @@ public function getLightboxUrl(Quote $quote)
156187
*/
157188
public function getPaymentPageUrl(Quote $quote)
158189
{
190+
$url = $this->getPaymentUrlInSession($quote);
191+
if ($url !== null) {
192+
$this->logger->debug("QUOTE-TRANSACTION-SERVICE::getPaymentPageUrl URL already exists: ".$url);
193+
return $url;
194+
}
159195
$transaction = $this->getTransactionByQuote($quote);
160196
$url = $this->apiClient->getService(TransactionPaymentPageService::class)->paymentPageUrl(
161197
$transaction->getLinkedSpaceId(), $transaction->getId());
162-
$this->logger->debug("QUOTE-TRANSACTION-SERVICE::getPaymentPageUrl URL: ".$url);
198+
$this->checkoutSession->setPaymentUrl($url);
199+
$this->logger->debug("QUOTE-TRANSACTION-SERVICE::getPaymentPageUrl new URL: ".$url);
163200
return $url;
164201
}
165202

@@ -310,6 +347,10 @@ private function createTransactionByQuote(Quote $quote)
310347
$this->assembleTransactionDataFromQuote($createTransaction, $quote);
311348
$transaction = $this->apiClient->getApiClient()->getTransactionService()->create($spaceId, $createTransaction);
312349
$this->updateQuote($quote, $transaction);
350+
//here the order must be updated with the space and transaction, this avoids error before landing on the payment page
351+
$quote->setWalleeTransactionId($transaction->getId());
352+
$quote->setWalleeSpaceId($spaceId);
353+
$quote->save();
313354
return $transaction;
314355
}
315356

Observer/CartEventListener.php

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public function execute(Observer $observer)
5656
try{
5757
$this->checkoutSession->unsTransaction();
5858
$this->checkoutSession->unsPaymentMethods();
59+
$this->checkoutSession->unsPaymentUrl();
5960
} catch (\Exception $ignored){}
6061
}
6162
}

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This repository contains the Magento 2 extension that enables to process payment
1212

1313
## Documentation
1414

15-
* [Documentation](https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.11/docs/en/documentation.html)
15+
* [Documentation](https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.12/docs/en/documentation.html)
1616

1717

1818
## Support
@@ -39,4 +39,4 @@ We do provide special integrations for the following one step checkouts:
3939

4040
## License
4141

42-
Please see the [license file](https://github.com/pfpayments/magento-2/blob/2.1.11/LICENSE) for more information.
42+
Please see the [license file](https://github.com/pfpayments/magento-2/blob/2.1.12/LICENSE) for more information.

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"type" : "magento2-module",
19-
"version" : "2.1.11",
19+
"version" : "2.1.12",
2020
"require" : {
2121
"php" : "~7.1.3||~7.2.0||~7.3.0||~7.4.0||~8.0||~8.1",
2222
"magento/framework" : "^102.0.0||^103.0.0",

docs/en/documentation.html

+1-1
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/pfpayments/magento-2/releases/tag/2.1.11/">
26+
<a href="https://github.com/pfpayments/magento-2/releases/tag/2.1.12/">
2727
Source
2828
</a>
2929
</li>

etc/adminhtml/system.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<resource>PostFinanceCheckout_Payment::config</resource>
2020
<group id="information" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
2121
<label>Information</label>
22-
<comment><![CDATA[If you need help setting up the PostFinance Checkout extension, check out the <a href="https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.11/docs/en/documentation.html" target="_blank">documentation</a>.]]></comment>
22+
<comment><![CDATA[If you need help setting up the PostFinance Checkout extension, check out the <a href="https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.12/docs/en/documentation.html" target="_blank">documentation</a>.]]></comment>
2323
<field id="version" translate="label" type="label" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
2424
<label>Module Version</label>
2525
</field>

etc/config.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<default>
1616
<postfinancecheckout_payment>
1717
<information>
18-
<version>2.1.11</version>
18+
<version>2.1.12</version>
1919
<sdk_version>4.0.2</sdk_version>
2020
</information>
2121
<general>

etc/module.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313
-->
1414
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
15-
<module name="PostFinanceCheckout_Payment" setup_version="2.1.11">
15+
<module name="PostFinanceCheckout_Payment" setup_version="2.1.12">
1616
<sequence>
1717
<module name="Magento_Sales"/>
1818
<module name="Magento_Payment"/>

i18n/de_DE.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"Gift Wrap","Geschenkverpackung"
5151
"Hold Delivery","Lieferung halten"
5252
"ID required","ID erforderlich"
53-
"If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.11/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Falls Sie Hilfe benötigen beim Einrichten der PostFinance Checkout-Erweiterung, sehen Sie sich die <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.11/docs/en/documentation.html"" target=""_blank"">Dokumentation</a> an."
53+
"If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.12/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Falls Sie Hilfe benötigen beim Einrichten der PostFinance Checkout-Erweiterung, sehen Sie sich die <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.12/docs/en/documentation.html"" target=""_blank"">Dokumentation</a> an."
5454
"Inactive","Inaktiv"
5555
"Information","Informationen"
5656
"Invoice","Rechnung"

i18n/en_US.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"Gift Wrap","Gift Wrap"
5151
"Hold Delivery","Hold Delivery"
5252
"ID required","ID required"
53-
"If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.11/docs/en/documentation.html"" target=""_blank"">documentation</a>.","If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.11/docs/en/documentation.html"" target=""_blank"">documentation</a>."
53+
"If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.12/docs/en/documentation.html"" target=""_blank"">documentation</a>.","If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.12/docs/en/documentation.html"" target=""_blank"">documentation</a>."
5454
"Inactive","Inactive"
5555
"Information","Information"
5656
"Invoice","Invoice"

i18n/fr_CH.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"Gift Wrap","Papier cadeau"
5151
"Hold Delivery","Suspendre la livraison"
5252
"ID required","Pièce d'identité requise"
53-
"If you need help setting up the postfinancecheckout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.11/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Si vous avez besoin d'aide pour configurer l'extension postfinancecheckout, consultez la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.11/docs/en/documentation.html"" target=""_blank"">documentation</a> an."
53+
"If you need help setting up the postfinancecheckout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.12/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Si vous avez besoin d'aide pour configurer l'extension postfinancecheckout, consultez la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.12/docs/en/documentation.html"" target=""_blank"">documentation</a> an."
5454
"Inactive","Inactif"
5555
"Information","Information"
5656
"Invoice","Facture"

i18n/fr_FR.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"Gift Wrap","Papier cadeau"
5151
"Hold Delivery","Suspendre la livraison"
5252
"ID required","Pièce d'identité requise"
53-
"If you need help setting up the postfinancecheckout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.11/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Si vous avez besoin d'aide pour configurer l'extension postfinancecheckout, consultez la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.11/docs/en/documentation.html"" target=""_blank"">documentation</a> an."
53+
"If you need help setting up the postfinancecheckout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.12/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Si vous avez besoin d'aide pour configurer l'extension postfinancecheckout, consultez la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.12/docs/en/documentation.html"" target=""_blank"">documentation</a> an."
5454
"Inactive","Inactif"
5555
"Information","Information"
5656
"Invoice","Facture"

i18n/it_CH.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"Gift Wrap","Confezione regalo"
5151
"Hold Delivery","Sospendi la consegna"
5252
"ID required","ID richiesto"
53-
"If you need help setting up the postfinancecheckout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.11/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Se hai bisogno di aiuto per configurare l'estensione postfinancecheckout, consulta la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.11/docs/en/documentation.html"" target=""_blank"">documentazione</a> an."
53+
"If you need help setting up the postfinancecheckout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.12/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Se hai bisogno di aiuto per configurare l'estensione postfinancecheckout, consulta la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.12/docs/en/documentation.html"" target=""_blank"">documentazione</a> an."
5454
"Inactive","Inattivo"
5555
"Information","Informazione"
5656
"Invoice","Fattura"

i18n/it_IT.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"Gift Wrap","Confezione regalo"
5151
"Hold Delivery","Sospendi la consegna"
5252
"ID required","ID richiesto"
53-
"If you need help setting up the postfinancecheckout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.11/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Se hai bisogno di aiuto per configurare l'estensione postfinancecheckout, consulta la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.11/docs/en/documentation.html"" target=""_blank"">documentazione</a> an."
53+
"If you need help setting up the postfinancecheckout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.12/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Se hai bisogno di aiuto per configurare l'estensione postfinancecheckout, consulta la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.12/docs/en/documentation.html"" target=""_blank"">documentazione</a> an."
5454
"Inactive","Inattivo"
5555
"Information","Informazione"
5656
"Invoice","Fattura"

view/frontend/web/js/view/payment/method-renderer/postfinancecheckout-method.js

+32
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,38 @@ define([
4444

4545
if (window.checkoutConfig.postfinancecheckout.integrationMethod == 'iframe') {
4646
this.checkoutHandler = checkoutHandler(this.getFormId(), this.isActive.bind(this), this.createIframeHandler.bind(this));
47+
var methods = methodList();
48+
49+
//When there is only 1 active payment method magento's behaviour is not to display the iframe,
50+
//until the user selects the payment method by clicking on the icon.
51+
//These lines allow to trigger the iframe to show it by default if there is only one payment method active.
52+
if (methods !== null && methods.length === 1) {
53+
this.checkoutHandler.updateAddresses(this._super.bind(this));
54+
}
55+
56+
//Every time the checkout page is initialised/refreshed
57+
//here we are checking if there is at least one chekbox selected,
58+
//if the condition is met, then we will update the iframe with the user's billing address,
59+
//this will trigger the form to be displayed and the transaction to have a payment method selected before clicking on the place order button.
60+
//This will only run once, only if the checkbox is selected.
61+
if (methods !== null && methods.length >= 1) {
62+
let _this = this;
63+
let _super = this._super;
64+
let checkboxId = this.getCode();
65+
let checkoutHandler = this.checkoutHandler;
66+
var updateAddressesCallback = function() {
67+
checkoutHandler.updateAddresses(_super.bind(_this));
68+
};
69+
let intervalId = setInterval(function () {
70+
// stop loader when frame will be loaded
71+
if ($('#' + checkboxId).length >= 1 && $('#' + checkboxId).is(':checked')) {
72+
clearInterval(intervalId);
73+
fullScreenLoader.startLoader();
74+
updateAddressesCallback();
75+
fullScreenLoader.stopLoader(true);
76+
}
77+
}, 100);
78+
}
4779
}
4880
},
4981

0 commit comments

Comments
 (0)