Skip to content

Commit

Permalink
Merge pull request #1139 from BearGroup/release/5.14.0
Browse files Browse the repository at this point in the history
Release/5.14.0
  • Loading branch information
Christian Zichichi authored Aug 1, 2022
2 parents 2f2051f + 69a01a7 commit d2070bf
Show file tree
Hide file tree
Showing 32 changed files with 235 additions and 38 deletions.
4 changes: 3 additions & 1 deletion Block/Adminhtml/System/Config/AutoKeyExchangeAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public function getRegion()
*/
public function getCurrency()
{
return $this->autokeyexchange->getCurrency();
$currency = $this->autokeyexchange->getCurrency();
if($currency) $currency = strtoupper($currency);
return $currency;
}
}
3 changes: 2 additions & 1 deletion Block/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public function getConfig()
'is_pay_only' => $this->amazonHelper->isPayOnly(),
'is_lwa_enabled' => $this->isLwaEnabled(),
'is_guest_checkout_enabled' => $this->amazonConfig->isGuestCheckoutEnabled(),
'has_restricted_products' => $this->amazonHelper->hasRestrictedProducts()
'has_restricted_products' => $this->amazonHelper->hasRestrictedProducts(),
'is_multicurrency_enabled' => $this->amazonConfig->multiCurrencyEnabled()
];

return $config;
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Change Log

## 5.14.0
* Added configurable options for checkout and signin cancel return urls
* Added estimated order amount to the button payload
* Fixed issue with ExceptionLogger using a removed method
* Fixed issue with customer names having characters that Magento doesn’t allow
* Fixed issue with APB and virtual orders when taxes are applied
* Improved compatibility with b2b modules and address display
* Updated config to not show Auto Key Exchange button for JPY as it is not supported

## 5.13.1
* Fixed issue with invalid array reference if a transaction doesn’t have a charge permission
* Fixed issue with GraphQL config query supporting omitPayloads
Expand Down
2 changes: 1 addition & 1 deletion Logger/ExceptionLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public function __construct(LoggerInterface $logger)
public function logException(\Exception $e)
{
$message = (string) $e;
$this->logger->addError($message);
$this->logger->error($message);
}
}
28 changes: 24 additions & 4 deletions Model/Adapter/AmazonPayAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ public function generateLoginButtonPayload()
{
$payload = [
'signInReturnUrl' => $this->getSignInUrl(),
'signInCancelUrl' => $this->getCancelUrl(),
'signInCancelUrl' => $this->getSignInCancelUrl(),
'storeId' => $this->amazonConfig->getClientId(),
'signInScopes' => ['name', 'email'],
];
Expand All @@ -528,7 +528,7 @@ public function generateCheckoutButtonPayload()
$payload = [
'webCheckoutDetails' => [
'checkoutReviewReturnUrl' => $this->amazonConfig->getCheckoutReviewReturnUrl(),
'checkoutCancelUrl' => $this->getCancelUrl(),
'checkoutCancelUrl' => $this->getCheckoutCancelUrl(),
],
'storeId' => $this->amazonConfig->getClientId(),
'scopes' => ['name', 'email', 'phoneNumber', 'billingAddress'],
Expand All @@ -551,7 +551,7 @@ public function generatePayNowButtonPayload(Quote $quote, $paymentIntent = Payme
'webCheckoutDetails' => [
'checkoutMode' => 'ProcessOrder',
'checkoutResultReturnUrl' => $this->amazonConfig->getPayNowResultUrl(),
'checkoutCancelUrl' => $this->getCancelUrl(),
'checkoutCancelUrl' => $this->getCheckoutCancelUrl(),
],
'storeId' => $this->amazonConfig->getClientId(),
'scopes' => ['name', 'email', 'phoneNumber', 'billingAddress'],
Expand Down Expand Up @@ -608,7 +608,27 @@ public function signButton($payload, $storeId = null)
return $this->clientFactory->create($storeId)->generateButtonSignature($payload);
}

protected function getCancelUrl()
protected function getCheckoutCancelUrl()
{
$checkoutCancelUrl = $this->amazonConfig->getCheckoutCancelUrl();
if (empty($checkoutCancelUrl)) {
return $this->getDefaultCancelUrl();
}

return $this->url->getUrl($checkoutCancelUrl);
}

protected function getSignInCancelUrl()
{
$signInCancelUrl = $this->amazonConfig->getSignInCancelUrl();
if (empty($signInCancelUrl)) {
return $this->getDefaultCancelUrl();
}

return $this->url->getUrl($signInCancelUrl);
}

protected function getDefaultCancelUrl()
{
$referer = $this->redirect->getRefererUrl();
if ($referer == $this->url->getUrl('checkout')) {
Expand Down
28 changes: 28 additions & 0 deletions Model/AmazonConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,34 @@ public function getPayNowResultUrl($scope = ScopeInterface::SCOPE_STORE, $scopeC
return $this->getCheckoutResultReturnUrl($scope, $scopeCode);
}

/**
* @return string|null
*/
public function getCheckoutCancelUrl($scope = ScopeInterface::SCOPE_STORE, $scopeCode = null)
{
$result = $this->scopeConfig->getValue(
'payment/amazon_payment_v2/checkout_cancel_url',
$scope,
$scopeCode
);

return $result;
}

/**
* @return string|null
*/
public function getSignInCancelUrl($scope = ScopeInterface::SCOPE_STORE, $scopeCode = null)
{
$result = $this->scopeConfig->getValue(
'payment/amazon_payment_v2/signin_cancel_url',
$scope,
$scopeCode
);

return $result;
}

/**
* @param string $scope
* @param mixed $scopeCode
Expand Down
13 changes: 0 additions & 13 deletions Model/CheckoutSessionManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -738,19 +738,6 @@ public function completeCheckoutSession($amazonSessionId, $cartId = null)
}

if ($amazonSession['productType'] == 'PayOnly') {
$addressData = $amazonSession['billingAddress'];

$addressData['state'] = $addressData['stateOrRegion'];
$addressData['phone'] = $addressData['phoneNumber'];

$address = array_combine(
array_map('ucfirst', array_keys($addressData)),
array_values($addressData)
);
$amazonAddress = $this->amazonAddressFactory->create(['address' => $address]);

$customerAddress = $this->addressHelper->convertToMagentoEntity($amazonAddress);
$quote->getBillingAddress()->importCustomerAddressData($customerAddress);
if (empty($quote->getCustomerEmail())) {
$quote->setCustomerEmail($amazonSession['buyer']['email']);
}
Expand Down
19 changes: 17 additions & 2 deletions Model/CustomerLinkManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ public function getByCustomerId($customerId)
public function create(AmazonCustomerInterface $amazonCustomer)
{
$customerData = $this->customerDataFactory->create();
$sanitizedNames = $this->getSanitizedNameData($amazonCustomer);

$customerData->setFirstname($amazonCustomer->getFirstName());
$customerData->setLastname($amazonCustomer->getLastName());
$customerData->setFirstname($sanitizedNames['first_name']);
$customerData->setLastname($sanitizedNames['last_name']);
$customerData->setEmail($amazonCustomer->getEmail());
$password = $this->random->getRandomString(64);

Expand All @@ -120,4 +121,18 @@ public function updateLink($customerId, $amazonId)

$this->customerLinkRepository->save($customerLink);
}

/**
* @param AmazonCustomerInterface $customer
* @return array
*/
private function getSanitizedNameData($customer)
{
$pattern = '/([^\p{L}\p{M}\,\-\_\.\'\s\d]){1,255}+/u';

return [
'first_name' => trim(preg_replace($pattern, '', htmlspecialchars_decode($customer->getFirstname()))),
'last_name' => trim(preg_replace($pattern, '', htmlspecialchars_decode($customer->getLastname())))
];
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ The following table provides an overview on which Git branch is compatible to wh
Magento Version | Github Branch | Latest release
---|---|---
2.2.6 - 2.2.11 (EOL) | [V2checkout-1.2.x](https://github.com/amzn/amazon-payments-magento-2-plugin/tree/V2checkout-1.2.x) | 1.20.0 (EOL)
2.3.0 - 2.4.x | [master](https://github.com/amzn/amazon-payments-magento-2-plugin/tree/master) | 5.13.1
2.3.0 - 2.4.x | [master](https://github.com/amzn/amazon-payments-magento-2-plugin/tree/master) | 5.14.0

## Release Notes
See [CHANGELOG.md](/CHANGELOG.md)
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": "amzn/amazon-pay-magento-2-module",
"description": "Official Magento2 Plugin to integrate with Amazon Pay",
"type": "magento2-module",
"version": "5.13.1",
"version": "5.14.0",
"license": [
"Apache-2.0"
],
Expand Down
11 changes: 11 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,17 @@
<comment><![CDATA[<strong>Amazon Pay Checkout could potentially break if this value is modified. Do it only if it is needed by your website.</strong><br />Magento will redirect to this URL after completing the checkout session. Do not use a leading slash.]]></comment>
<config_path>payment/amazon_payment_v2/checkout_result_url</config_path>
</field>
<field id="checkout_cancel_url" translate="label comment" type="text" sortOrder="22" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Amazon Checkout cancel URL Path</label>
<!-- <br /> -->
<comment><![CDATA[<strong>Amazon Pay Checkout could potentially break if this value is modified. Do it only if it is needed by your website.</strong><br />Amazon Pay will redirect to this URL if the customer clicks "Cancel Amazon Pay checkout and return to [merchant site]" from the Amazon-hosted page. Do not use a leading slash. Leave blank to return the customer to the last page visited before checkout (EU/UK regions only).]]></comment>
<config_path>payment/amazon_payment_v2/checkout_cancel_url</config_path>
</field>
<field id="signin_cancel_url" translate="label comment" type="text" sortOrder="23" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Amazon Sign In cancel URL Path</label>
<comment><![CDATA[<strong>Amazon Pay Sign In could potentially break if this value is modified. Do it only if it is needed by your website.</strong><br />Amazon Pay will redirect to this URL if the customer clicks "Cancel" from the Amazon-hosted page. Do not use a leading slash. Leave blank to return the customer to the last page visited before sign in (EU/UK regions only).]]></comment>
<config_path>payment/amazon_payment_v2/signin_cancel_url</config_path>
</field>
<field id="allowed_ips_v2" translate="label comment" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Allowed IPs</label>
<comment><![CDATA[Enter IPs seperated by commas. Note: The Amazon Pay button will only be visible to clients with corresponding IP addresses.]]></comment>
Expand Down
4 changes: 4 additions & 0 deletions i18n/de_AT.csv
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,7 @@
"<strong>Only change this value if required. Improper modifications can break the integration. After the order is complete, your customer will be redirected to this URL. Don't enter a leading slash.","<strong>Ändern Sie diesen Wert nur bei Bedarf. Unsachgemäße Änderungen können zu einer fehlerhaften Integration führen. Nachdem die Bestellung abgeschlossen ist, werden Ihre Kunden zu dieser URL weitergeleitet. Tragen Sie keinen vorangestellten Schrägstrich ein."
"Refund declined for order #%1","Erstattung für Bestellung #%1 wurde abgelehnt"
"Note: Amazon Pay only supports multi-currency functionality for the payment regions United Kingdom and Euro region. Supported currencies: AUD, GBP, DKK, EUR, HKD, JPY, NZD, NOK, ZAR, SEK, CHF, USD.","Hinweis: Amazon Pay unterstützt die Fremdwährungsfunktion nur für die Zahlungsregionen Vereinigtes Königreich und Euroraum. Unterstützte Währungen: AUD, GBP, DKK, EUR, HKD, JPY, NZD, NOK, ZAR, SEK, CHF, USD."
"Amazon Checkout cancel URL Path","URL-Pfad bei Abbruch des Amazon Pay Checkout (nur für die Regionen EU/UK)"
"<strong>Amazon Pay Checkout could potentially break if this value is modified. Do it only if it is needed by your website.</strong><br />Amazon Pay will redirect to this URL if the customer clicks ""Cancel Amazon Pay checkout and return to [merchant site]"" from the Amazon-hosted page. Do not use a leading slash. Leave blank to return the customer to the last page visited before checkout (EU/UK regions only).","<strong>Unsachgemäße Änderungen können zu einer fehlerhaften Integration führen. Ändern Sie diesen Wert nur bei Bedarf.</strong><br />Ihre Kunden werden zu dieser URL weitergeleitet, wenn sie während des Bezahlvorgangs auf „Amazon Pay-Bezahlvorgang abbrechen und zu [Händlername] zurückkehren“ klicken. Standardmäßig werden Ihre Kunden auf die Warenkorbseite geleitet."
"Amazon Sign In cancel URL Path","URL-Pfad bei Abbruch der Anmeldung mit Amazon (nur für die Regionen EU/UK)"
"<strong>Amazon Pay Sign In could potentially break if this value is modified. Do it only if it is needed by your website.</strong><br />Amazon Pay will redirect to this URL if the customer clicks ""Cancel"" from the Amazon-hosted page. Do not use a leading slash. Leave blank to return the customer to the last page visited before sign in (EU/UK regions only).","<strong>Unsachgemäße Änderungen können zu einer fehlerhaften Integration führen. Ändern Sie diesen Wert nur bei Bedarf.</strong><br />Ihre Kunden werden zu dieser URL weitergeleitet, wenn sie auf der Seite „Mit Amazon anmelden“ auf „Abbrechen“ klicken. Tragen Sie keinen vorangestellten Schrägstrich ein. Standardmäßig werden Ihre Kunden zur vorherigen Seite zurückgeleitet."
4 changes: 4 additions & 0 deletions i18n/de_CH.csv
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,7 @@
"<strong>Only change this value if required. Improper modifications can break the integration. After the order is complete, your customer will be redirected to this URL. Don't enter a leading slash.","<strong>Ändern Sie diesen Wert nur bei Bedarf. Unsachgemäße Änderungen können zu einer fehlerhaften Integration führen. Nachdem die Bestellung abgeschlossen ist, werden Ihre Kunden zu dieser URL weitergeleitet. Tragen Sie keinen vorangestellten Schrägstrich ein."
"Refund declined for order #%1","Erstattung für Bestellung #%1 wurde abgelehnt"
"Note: Amazon Pay only supports multi-currency functionality for the payment regions United Kingdom and Euro region. Supported currencies: AUD, GBP, DKK, EUR, HKD, JPY, NZD, NOK, ZAR, SEK, CHF, USD.","Hinweis: Amazon Pay unterstützt die Fremdwährungsfunktion nur für die Zahlungsregionen Vereinigtes Königreich und Euroraum. Unterstützte Währungen: AUD, GBP, DKK, EUR, HKD, JPY, NZD, NOK, ZAR, SEK, CHF, USD."
"Amazon Checkout cancel URL Path","URL-Pfad bei Abbruch des Amazon Pay Checkout (nur für die Regionen EU/UK)"
"<strong>Amazon Pay Checkout could potentially break if this value is modified. Do it only if it is needed by your website.</strong><br />Amazon Pay will redirect to this URL if the customer clicks ""Cancel Amazon Pay checkout and return to [merchant site]"" from the Amazon-hosted page. Do not use a leading slash. Leave blank to return the customer to the last page visited before checkout (EU/UK regions only).","<strong>Unsachgemäße Änderungen können zu einer fehlerhaften Integration führen. Ändern Sie diesen Wert nur bei Bedarf.</strong><br />Ihre Kunden werden zu dieser URL weitergeleitet, wenn sie während des Bezahlvorgangs auf „Amazon Pay-Bezahlvorgang abbrechen und zu [Händlername] zurückkehren“ klicken. Standardmäßig werden Ihre Kunden auf die Warenkorbseite geleitet."
"Amazon Sign In cancel URL Path","URL-Pfad bei Abbruch der Anmeldung mit Amazon (nur für die Regionen EU/UK)"
"<strong>Amazon Pay Sign In could potentially break if this value is modified. Do it only if it is needed by your website.</strong><br />Amazon Pay will redirect to this URL if the customer clicks ""Cancel"" from the Amazon-hosted page. Do not use a leading slash. Leave blank to return the customer to the last page visited before sign in (EU/UK regions only).","<strong>Unsachgemäße Änderungen können zu einer fehlerhaften Integration führen. Ändern Sie diesen Wert nur bei Bedarf.</strong><br />Ihre Kunden werden zu dieser URL weitergeleitet, wenn sie auf der Seite „Mit Amazon anmelden“ auf „Abbrechen“ klicken. Tragen Sie keinen vorangestellten Schrägstrich ein. Standardmäßig werden Ihre Kunden zur vorherigen Seite zurückgeleitet."
4 changes: 4 additions & 0 deletions i18n/de_DE.csv
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,7 @@
"<strong>Only change this value if required. Improper modifications can break the integration. After the order is complete, your customer will be redirected to this URL. Don't enter a leading slash.","<strong>Ändern Sie diesen Wert nur bei Bedarf. Unsachgemäße Änderungen können zu einer fehlerhaften Integration führen. Nachdem die Bestellung abgeschlossen ist, werden Ihre Kunden zu dieser URL weitergeleitet. Tragen Sie keinen vorangestellten Schrägstrich ein."
"Refund declined for order #%1","Erstattung für Bestellung #%1 wurde abgelehnt"
"Note: Amazon Pay only supports multi-currency functionality for the payment regions United Kingdom and Euro region. Supported currencies: AUD, GBP, DKK, EUR, HKD, JPY, NZD, NOK, ZAR, SEK, CHF, USD.","Hinweis: Amazon Pay unterstützt die Fremdwährungsfunktion nur für die Zahlungsregionen Vereinigtes Königreich und Euroraum. Unterstützte Währungen: AUD, GBP, DKK, EUR, HKD, JPY, NZD, NOK, ZAR, SEK, CHF, USD."
"Amazon Checkout cancel URL Path","URL-Pfad bei Abbruch des Amazon Pay Checkout (nur für die Regionen EU/UK)"
"<strong>Amazon Pay Checkout could potentially break if this value is modified. Do it only if it is needed by your website.</strong><br />Amazon Pay will redirect to this URL if the customer clicks ""Cancel Amazon Pay checkout and return to [merchant site]"" from the Amazon-hosted page. Do not use a leading slash. Leave blank to return the customer to the last page visited before checkout (EU/UK regions only).","<strong>Unsachgemäße Änderungen können zu einer fehlerhaften Integration führen. Ändern Sie diesen Wert nur bei Bedarf.</strong><br />Ihre Kunden werden zu dieser URL weitergeleitet, wenn sie während des Bezahlvorgangs auf „Amazon Pay-Bezahlvorgang abbrechen und zu [Händlername] zurückkehren“ klicken. Standardmäßig werden Ihre Kunden auf die Warenkorbseite geleitet."
"Amazon Sign In cancel URL Path","URL-Pfad bei Abbruch der Anmeldung mit Amazon (nur für die Regionen EU/UK)"
"<strong>Amazon Pay Sign In could potentially break if this value is modified. Do it only if it is needed by your website.</strong><br />Amazon Pay will redirect to this URL if the customer clicks ""Cancel"" from the Amazon-hosted page. Do not use a leading slash. Leave blank to return the customer to the last page visited before sign in (EU/UK regions only).","<strong>Unsachgemäße Änderungen können zu einer fehlerhaften Integration führen. Ändern Sie diesen Wert nur bei Bedarf.</strong><br />Ihre Kunden werden zu dieser URL weitergeleitet, wenn sie auf der Seite „Mit Amazon anmelden“ auf „Abbrechen“ klicken. Tragen Sie keinen vorangestellten Schrägstrich ein. Standardmäßig werden Ihre Kunden zur vorherigen Seite zurückgeleitet."
Loading

0 comments on commit d2070bf

Please sign in to comment.