Skip to content

Commit

Permalink
Merge branch 'v2.22.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
zalazdi committed Jun 13, 2024
2 parents 91a6943 + 14f6fdf commit 3615966
Show file tree
Hide file tree
Showing 16 changed files with 157 additions and 18 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Co nowego w BluePayment?

## Wersja 2.22.8
- Dodaliśmy wsparcie dla modułu Amasty One Step Checkout.
- Dodaliśmy opcję ustawienia linku do odpowiedniego kalkulatora (0 lub 1%) dla "Alior Raty".
- Poprawiliśmy działanie Google Pay.

## Wersja 2.22.7
- Dodaliśmy wsparcie dla Magento 2.4.7.
- Naprawiliśmy błąd z CSP dla Analytics.
Expand All @@ -11,7 +16,6 @@
- Dodaliśmy nowe ustawienia (dot. zdjęcia) do białej listy CSP.
- Poprawiliśmy błąd z wielokrotną wysyłką e-maila przy płatności Google Pay / BLIK 0 / Kartą.
- Naprawiliśmy błąd z nieprawidłowym przekierowaniem, gdy opcja "Dodaj kod sklepu do adresu URL" była ustawiona na wartość true (dzięki @piotrmatras).
- Dodaliśmy wsparcie dla modułu Amasty One Step Checkout.

## Wersja 2.22.5
- Poprawiliśmy wsparcie dla Magneto 2.4.6 (zmiana Zend -> Laminas).
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG_EN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# What's new in BluePayment?

## Version 2.22.8
- We have added support for Amasty's One Step Checkout module.
- We have added the option to set a link to the relevant calculator (0 or 1%) for "Alior Instalments".
- Poprawiliśmy działanie Google Pay.

## Version 2.22.7
- We have added support for Magento 2.4.7.
- We have fixed issue with CSP for Analytics.
Expand All @@ -11,7 +16,6 @@
- We have added new entries (for photos) to CSP whitelist.
- We have fixed a bug with multiple email sending for Google Pay / BLIK 0 / Card payment.
- We have fixed a bug with wrong redirect when "Add Store Code to URLs" was set to true (credits @piotrmatras).
- We have added support for Amasty's One Step Checkout module.

## Version 2.22.5
- We have fixed support for Magneto 2.4.6 (Zend -> Laminas change).
Expand Down
12 changes: 12 additions & 0 deletions Controller/Processing/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ public function execute()
$order = $this->orderFactory->create()->loadByIncrementId($sessionLastRealOrderSessionId);

$currency = $order->getOrderCurrencyCode();

$this->logger->info('CREATE:' . __LINE__, [
'orderId' => $order->getId(),
'currency' => $currency
]);

$serviceId = $this->scopeConfig->getValue(
'payment/bluepayment/'.strtolower($currency).'/service_id',
ScopeInterface::SCOPE_STORE
Expand Down Expand Up @@ -193,6 +199,12 @@ public function execute()
$this->orderRepository->save($order);
$this->sendConfirmationEmail->execute($order);

$this->logger->info('CREATE:' . __LINE__, [
'orderId' => $order->getId(),
'gatewayId' => $gatewayId,
'automatic' => $automatic === true ? 'true' : 'false'
]);

if (ConfigProvider::CARD_GATEWAY_ID == $gatewayId && $automatic === true) {
$params = $this->bluepayment->getFormRedirectFields(
$order,
Expand Down
21 changes: 21 additions & 0 deletions Model/Config/Source/AliorInstallments.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace BlueMedia\BluePayment\Model\Config\Source;

use Magento\Framework\Data\OptionSourceInterface;

class AliorInstallments implements OptionSourceInterface
{
/**
* Options getter
*
* @return array
*/
public function toOptionArray(): array
{
return [
['value' => 'one', 'label' => __('Installments 1 %')],
['value' => 'zero', 'label' => __('Installments 0 %')]
];
}
}
39 changes: 38 additions & 1 deletion Model/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public function getPaymentConfig(): array
$resultSeparated = [];
$result = [];

$amount = (float) $this->checkoutSession->getQuote()->getGrandTotal();
$amount = $this->getGrandTotalForQuote();

$gateways = $this->getActiveGateways($currency, (float) $amount);

Expand All @@ -297,6 +297,7 @@ public function getPaymentConfig(): array
'logo' => $this->block->getLogoSrc(),
'iframe_enabled' => $this->iframePaymentEnabled(),
'blik_zero_enabled' => $this->blikZeroEnabled(),
'alior_calculator_url' => $this->getAliorCalculatorUrl(),
'options' => $result,
'separated' => $resultSeparated,
'cards' => $this->prepareCards(),
Expand Down Expand Up @@ -657,4 +658,40 @@ public function isWithPhoneEnabled(): bool
ScopeInterface::SCOPE_STORE
);
}

/**
* Returns current configuration for alior installments.
*
* @return string 'one' or 'zero'
*/
public function getAliorInstallments(): string
{
$value = (string) $this->scopeConfig->getValue(
'payment/bluepayment/alior_installments',
ScopeInterface::SCOPE_STORE
);

if (!in_array($value, ['one', 'zero'])) {
return 'one';
}

return $value;
}

public function getAliorCalculatorUrl(): string
{
if ($this->getAliorInstallments() === 'zero') {
$url = 'https://kalkulator.raty.aliorbank.pl/init?supervisor=B776&promotionList=F&amount={amount}';;
} else {
$url = 'https://kalkulator.raty.aliorbank.pl/init?supervisor=B776&promotionList=B&amount={amount}';

}

return $url;
}

protected function getGrandTotalForQuote(): float
{
return (float) $this->checkoutSession->getQuote()->getGrandTotal();
}
}
2 changes: 1 addition & 1 deletion Model/Metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class Metadata
{
private const VERSION = '2.22.7';
private const VERSION = '2.22.8';

/** @var ProductMetadataInterface */
private $productMetadata;
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "bluepayment-plugin/module-bluepayment",
"description": "Autopay payment gateway for Magento 2.",
"type": "magento2-module",
"version": "2.22.7",
"version": "2.22.8",
"require": {
"magento/framework": "^102||^103",
"magento/module-config": "^101.1",
Expand Down
8 changes: 8 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@
<field id="gateway_selection">1</field>
</depends>
</field>
<field id="alior_installments" translate="label comment" type="select" sortOrder="556" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Alior Installments - link to calculator</label>
<source_model>BlueMedia\BluePayment\Model\Config\Source\AliorInstallments</source_model>
<comment><![CDATA[Select the appropriate interest rate in your agreement with Autopay to display the correct calculator to the customer.]]></comment>
<depends>
<field id="gateway_selection">1</field>
</depends>
</field>
<field id="collapsible" translate="label comment" type="select" sortOrder="560" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Collapsible gateway list</label>
<source_model>Magento\Config\Model\Config\Source\Enabledisable</source_model>
Expand Down
1 change: 1 addition & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<show_manual_refund>1</show_manual_refund>
<blik_zero>1</blik_zero>
<with_phone>0</with_phone>
<alior_installments>one</alior_installments>
<paymentInfoKeys>bluepayment_gateway</paymentInfoKeys>
<privateInfoKeys>bluepayment_gateway</privateInfoKeys>

Expand Down
4 changes: 4 additions & 0 deletions i18n/pl_PL.csv
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,7 @@ You have to select payment card.,"Musisz wybrać kartę płatniczą."
"Expand","Rozwiń"
"Start transaction with phone number","Rozpoczynaj transakcję z numerem telefonu"
"Requires configuration on the Autopay side. ENABLE ONLY AT THE REQUEST OF THE SUPPORT TEAM.","Wymaga konfiguracji po stronie Autopay. WŁĄCZ TYLKO NA PROŚBĘ ZESPOŁU WSPARCIA."
"Alior Installments - link to calculator","Raty Alior - link do kalkulatora"
"Installments 1%","Raty 1%"
"Installments 0%","Raty 0%"
"Select the appropriate interest rate in your agreement with Autopay to display the correct calculator to the customer.",""Wybierz odpowiednie oprocentowanie w swojej Umowie z Autopay, aby wyświetlić prawidłowy kalkulator klientowi.",
1 change: 1 addition & 0 deletions view/frontend/web/js/model/checkout/bluepayment-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ define(function () {
cards: config?.cards ?? [],
oneClickAgreement: config?.one_click_agreement ?? false,
blikZeroEnabled: config?.blik_zero_enabled ?? true,
aliorCalculatorUrl: config?.alior_calculator_url ?? 'one',
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ define([
* @return {Boolean}
*/
validate: function () {
if (! additionalValidators.validate()) {
return false;
}

return true;
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,38 @@ define([
'mage/translate',
'mage/url',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/payment/additional-validators',
'Magento_Ui/js/modal/modal',
'BlueMedia_BluePayment/js/checkout-data',
'BlueMedia_BluePayment/js/view/payment/method-renderer/bluepayment-separated',
'BlueMedia_BluePayment/js/model/checkout/bluepayment-config',
'BlueMedia_BluePayment/js/model/checkout/bluepayment-gateways',
'text!BlueMedia_BluePayment/template/wait-popup.html',
], function (
$,
ko,
$t,
url,
quote,
additionalValidators,
modal,
checkoutData,
Component,
config,
gateways,
popupTpl,
) {
'use strict';

return Component.extend({
defaults: {
template: 'BlueMedia_BluePayment/payment/bluepayment-google-pay',
gateway_id: 1512,
gateway_id: gateways.ids.google_pay,
gateway_logo_url: null,
gateway_name: null,
gateway_description: null,
},
redirectAfterPlaceOrder: false,
client: ko.observable(false),
testMode: config.testMode,
merchantInfo: null,
Expand All @@ -53,15 +58,8 @@ define([
*/
initObservable: function () {
this._super();
this.grandTotalAmount = parseFloat(quote.totals()['base_grand_total']).toFixed(2);
this.currencyCode = quote.totals()['base_currency_code'];

quote.totals.subscribe(function () {
if (this.grandTotalAmount !== quote.totals()['base_grand_total']) {
this.grandTotalAmount = parseFloat(quote.totals()['base_grand_total']).toFixed(2);
}
}.bind(this));

return this;
},

Expand All @@ -76,6 +74,28 @@ define([
}
},


/**
* Place order - with validation.
*/
placeOrder: function (data, event) {
if (event) {
event.preventDefault();
}

if (this.validate() &&
additionalValidators.validate()
) {
this.callGooglePayPayment();
}

return false;
},

afterPlaceOrder: function () {
return true;
},

/**
* Is Google Pay available
*
Expand Down Expand Up @@ -141,7 +161,6 @@ define([
});
},


/**
* Get Google Pay transaction data
*
Expand Down Expand Up @@ -170,7 +189,7 @@ define([
shippingAddressRequired: false,
transactionInfo: {
totalPriceStatus: 'FINAL',
totalPrice: this.grandTotalAmount,
totalPrice: this.grandTotalAmount(),
currencyCode: this.currencyCode
},
};
Expand All @@ -188,7 +207,7 @@ define([
self.placeOrderAfterValidation(function () {
const token = data.paymentMethodData.tokenizationData.token;
const urlResponse = url.build('bluepayment/processing/create')
+ '?gateway_id=1512'
+ '?gateway_id=' + gateways.ids.google_pay
+ '&automatic=true';

$.ajax({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ define([
'Magento_Checkout/js/model/quote',
'BlueMedia_BluePayment/js/view/payment/method-renderer/bluepayment-abstract',
'BlueMedia_BluePayment/js/model/checkout/bluepayment',
'BlueMedia_BluePayment/js/model/checkout/bluepayment-config',
], function (
ko,
$t,
quote,
Component,
model,
config
) {
'use strict';

Expand All @@ -22,6 +24,24 @@ define([
gateway_description: null,
},

grandTotalAmount: ko.observable(0),

/**
* Subscribe to grand totals
*/
initObservable: function () {
this._super();

this.grandTotalAmount(parseFloat(quote.totals()['base_grand_total']).toFixed(2));
quote.totals.subscribe(function () {
if (this.grandTotalAmount() !== quote.totals()['base_grand_total']) {
this.grandTotalAmount(parseFloat(quote.totals()['base_grand_total']).toFixed(2));
}
}.bind(this));

return this;
},

/**
* Get payment method data
*/
Expand Down Expand Up @@ -88,8 +108,12 @@ define([
let gatewayId = Number(this.gateway_id);

if (gatewayId === model.gatewaysIds.alior_installments) {
const link = '<a href="' + config.aliorCalculatorUrl + '" target="_blank">'
+ $t('Learn more') +
'</a>';

return $t('Pay for your purchases using convenient instalments. %1')
.replace('%1', '<a href="https://kalkulator.raty.aliorbank.pl/init?supervisor=B776&promotionList=B" target="_blank">' + $t('Learn more') + '</a>');
.replace('%1', link.replace('{amount}', Math.round(this.grandTotalAmount())));
}

if (gatewayId === model.gatewaysIds.paypo) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<button class="action primary checkout"
type="submit"
data-bind="
click: callGooglePayPayment
click: placeOrder
">
<span translate="'Place Order'"></span>
</button>
Expand Down

0 comments on commit 3615966

Please sign in to comment.