Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/5.13.1 #1132

Merged
merged 9 commits into from
Jun 6, 2022
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 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
* Fixed issue with switching stores to refresh the Amazon Pay button config

## 5.13.0
* Added Graphql support
* Added endpoints to fetch individual config types
Expand Down
19 changes: 13 additions & 6 deletions Model/AsyncManagement/Charge.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,19 @@ public function decline($order, $chargeId, $detail)
}
if ($order->canHold() || $order->isPaymentReview()) {
$this->closeLastTransaction($order);
$this->amazonAdapter->closeChargePermission(
$order->getStoreId(),
$order->getPayment()->getAdditionalInformation()['charge_permission_id'],
'Canceled due to capture declined.',
true
);
$chargePermissionId = $order->getPayment()->getAdditionalInformation()['charge_permission_id'] ?? '';
if (!empty($chargePermissionId)) {
$this->amazonAdapter->closeChargePermission(
$order->getStoreId(),
$chargePermissionId,
'Canceled due to capture declined.',
true
);
} else {
$this->asyncLogger->info('Unable to close charge permission for order #' . $order->getIncrementId()
. '; no charge permission ID associated with order');
}

$this->setOrderState($order, 'canceled');
$payment = $order->getPayment();
$transaction = $this->transactionBuilder->setPayment($payment)
Expand Down
3 changes: 2 additions & 1 deletion Model/Resolver/CheckoutSessionConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ public function __construct(
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
{
$cartId = $args['cartId'] ?? null;
$omitPayloads = $args['omitPayloads'] ?? false;

$response = $this->checkoutSessionManagement->getConfig($cartId);
$response = $this->checkoutSessionManagement->getConfig($cartId, $omitPayloads);
return array_shift($response);
}
}
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.0
2.3.0 - 2.4.x | [master](https://github.com/amzn/amazon-payments-magento-2-plugin/tree/master) | 5.13.1

## Release Notes
See [CHANGELOG.md](/CHANGELOG.md)
6 changes: 3 additions & 3 deletions Test/Mftf-24/Test/AmazonCheckoutSuccessTest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@

<grabTextFrom selector="{{CheckoutSuccessMainSection.orderNumber}}" stepKey="orderNumber" />
<magentoCLI command="amazon:payment:sales:verify-charge-permission" arguments="--orderId {$orderNumber}" stepKey="command" />
<assertEquals stepKey="refIdAssert">
<assertStringContainsString stepKey="seeMerchantReferenceIdMatchesOrderNumber">
<expectedResult type="string">true</expectedResult>
<actualResult type="string">${command}</actualResult>
<expectedResult type="string">true\n</expectedResult>
</assertEquals>
</assertStringContainsString>
</test>
</tests>
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.0",
"version": "5.13.1",
"license": [
"Apache-2.0"
],
Expand Down
2 changes: 1 addition & 1 deletion etc/schema.graphqls
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type Query {
checkoutSessionConfig(cartId: String): CheckoutSessionConfigOutput
checkoutSessionConfig(cartId: String, omitPayloads: Boolean): CheckoutSessionConfigOutput
@resolver(class:"Amazon\\Pay\\Model\\Resolver\\CheckoutSessionConfig")

checkoutSessionDetails(amazonSessionId: String!, queryTypes: [String!]): CheckoutSessionDetailsOutput
Expand Down
7 changes: 6 additions & 1 deletion view/frontend/web/js/action/checkout-session-config-load.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ define([
], function ($, _, remoteStorage, url, customerData) {
'use strict';

const storageKey = 'amzn-checkout-session-config';
$('.switcher-option').on('click', function () {
$.localStorage.remove(storageKey);
});

var localStorage = null;
var getLocalStorage = function () {
if (localStorage === null) {
localStorage = $.initNamespaceStorage('amzn-checkout-session-config').localStorage;
localStorage = $.initNamespaceStorage(storageKey).localStorage;
}
return localStorage;
};
Expand Down