diff --git a/Api/Data/Quote/ExtendedShippingInformationInterface.php b/Api/Data/Quote/ExtendedShippingInformationInterface.php
deleted file mode 100644
index 89a0970..0000000
--- a/Api/Data/Quote/ExtendedShippingInformationInterface.php
+++ /dev/null
@@ -1,23 +0,0 @@
- $quote->getReservedOrderId(),
'taxAmount' => [
'amount' => $this->formatPrice(
- $billingTaxAmount ?: $shippingTaxAmount
+ (float)$billingTaxAmount ?: $shippingTaxAmount
),
'currency' => $isCBTCurrencyAvailable ? $quote->getQuoteCurrencyCode() : $quote->getBaseCurrencyCode()
],
diff --git a/Gateway/Request/ExpressCheckoutDataBuilder.php b/Gateway/Request/ExpressCheckoutDataBuilder.php
index c4f325c..5702565 100644
--- a/Gateway/Request/ExpressCheckoutDataBuilder.php
+++ b/Gateway/Request/ExpressCheckoutDataBuilder.php
@@ -4,22 +4,6 @@
class ExpressCheckoutDataBuilder extends \Afterpay\Afterpay\Gateway\Request\Checkout\CheckoutDataBuilder
{
- /**
- * @var \Afterpay\Afterpay\Api\Data\Quote\ExtendedShippingInformationInterface
- */
- private $extendedShippingInformation;
-
- public function __construct(
- \Magento\Framework\UrlInterface $url,
- \Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
- \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder,
- \Afterpay\Afterpay\Model\CBT\CheckCBTCurrencyAvailabilityInterface $checkCBTCurrencyAvailability,
- \Afterpay\Afterpay\Api\Data\Quote\ExtendedShippingInformationInterface $extendedShippingInformation
- ) {
- parent::__construct($url, $productRepository, $searchCriteriaBuilder, $checkCBTCurrencyAvailability);
- $this->extendedShippingInformation = $extendedShippingInformation;
- }
-
public function build(array $buildSubject): array
{
/** @var \Magento\Quote\Model\Quote $quote */
@@ -29,10 +13,11 @@ public function build(array $buildSubject): array
$amount = $isCBTCurrencyAvailable ? $quote->getGrandTotal() : $quote->getBaseGrandTotal();
$currencyCode = $isCBTCurrencyAvailable ? $currentCurrencyCode : $quote->getBaseCurrencyCode();
$popupOriginUrl = $buildSubject['popup_origin_url'];
- $lastSelectedShippingRate = $this->extendedShippingInformation->getParam(
- $quote,
- \Afterpay\Afterpay\Api\Data\Quote\ExtendedShippingInformationInterface::LAST_SELECTED_SHIPPING_RATE
- );
+
+ $lastSelectedShippingRate = null;
+ if ($quote->getShippingAddress() && $quote->getShippingAddress()->getShippingMethod()) {
+ $lastSelectedShippingRate = $quote->getShippingAddress()->getShippingMethod();
+ }
$data = [
'mode' => 'express',
diff --git a/Gateway/Response/DiscountHandler.php b/Gateway/Response/DiscountHandler.php
index cd51e45..a806820 100644
--- a/Gateway/Response/DiscountHandler.php
+++ b/Gateway/Response/DiscountHandler.php
@@ -44,9 +44,9 @@ protected function getOrderDiscountAmount(\Magento\Sales\Model\Order $order): fl
);
if ($isCBTCurrency) {
- return (float)($order->getGiftCardsAmount() + $order->getCustomerBalanceAmount());
+ return (float)($order->getGiftCardsAmount() + $order->getCustomerBalanceAmount() + $order->getRewardCurrencyAmount());
} else {
- return (float)($order->getBaseGiftCardsAmount() + $order->getBaseCustomerBalanceAmount());
+ return (float)($order->getBaseGiftCardsAmount() + $order->getBaseCustomerBalanceAmount() + $order->getBaseRewardCurrencyAmount());
}
}
}
diff --git a/Gateway/Response/PaymentDetailsHandler.php b/Gateway/Response/PaymentDetailsHandler.php
index b240c54..015055f 100644
--- a/Gateway/Response/PaymentDetailsHandler.php
+++ b/Gateway/Response/PaymentDetailsHandler.php
@@ -6,22 +6,33 @@ class PaymentDetailsHandler implements \Magento\Payment\Gateway\Response\Handler
{
private $authExpiryDate;
+ private $paymentUpdater;
+
public function __construct(
- \Afterpay\Afterpay\Model\Order\Payment\Auth\ExpiryDate $authExpiryDate
+ \Afterpay\Afterpay\Model\Order\Payment\Auth\ExpiryDate $authExpiryDate,
+ \Afterpay\Afterpay\Model\Order\CreditMemo\PaymentUpdater\Proxy $paymentUpdater
) {
$this->authExpiryDate = $authExpiryDate;
+ $this->paymentUpdater = $paymentUpdater;
}
public function handle(array $handlingSubject, array $response): void
{
if (!isset($response['id'])) {
- throw new \Magento\Payment\Gateway\Command\CommandException(
- __(
- 'Afterpay response error: Code: %1, Id: %2',
- $response['errorCode'] ?? '',
- $response['errorId'] ?? ''
- )
- );
+ if (isset($response['errorCode'], $response['errorId'])) {
+ throw new \Magento\Payment\Gateway\Command\CommandException(
+ __(
+ 'Afterpay response error: Code: %1, Id: %2',
+ $response['errorCode'],
+ $response['errorId']
+ )
+ );
+ }
+
+ $paymentDO = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
+ $this->paymentUpdater->updatePayment($paymentDO->getPayment());
+
+ return;
}
$paymentDO = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
diff --git a/Model/Order/CreditMemo/CreditMemoInitiator.php b/Model/Order/CreditMemo/CreditMemoInitiator.php
index 86e02af..8561b72 100644
--- a/Model/Order/CreditMemo/CreditMemoInitiator.php
+++ b/Model/Order/CreditMemo/CreditMemoInitiator.php
@@ -15,8 +15,23 @@ public function __construct(
public function init(\Magento\Sales\Model\Order $order): \Magento\Sales\Model\Order\Creditmemo
{
$qtysToRefund = [];
+ /** @var \Magento\Sales\Model\Order\Item $orderItem */
foreach ($order->getItemsCollection() as $orderItem) {
- /** @var $orderItem \Magento\Sales\Model\Order\Item */
+ if ($orderItem->getProductType() == \Magento\Bundle\Model\Product\Type::TYPE_CODE) {
+ /** @var \Magento\Sales\Model\Order\Item $childrenItem */
+ foreach ($orderItem->getChildrenItems() as $childrenItem) {
+ if (!$childrenItem->getIsVirtual()) {
+ $qtyShipped = $childrenItem->getQtyShipped();
+ $qtyOrdered = $childrenItem->getQtyOrdered();
+ $qtyRefunded = $childrenItem->getQtyRefunded();
+ $childItemLeftToShip = $qtyOrdered - ($qtyShipped + $qtyRefunded);
+ if ($childItemLeftToShip > 0) {
+ $qtysToRefund[$childrenItem->getId()] = $childItemLeftToShip;
+ }
+ }
+ }
+ }
+
if (!$orderItem->getParentItem() && !$orderItem->getIsVirtual()) {
$qtyShipped = $orderItem->getQtyShipped();
$qtyOrdered = $orderItem->getQtyOrdered();
diff --git a/Model/Quote/ExtendedShippingInformation.php b/Model/Quote/ExtendedShippingInformation.php
deleted file mode 100644
index 95159b4..0000000
--- a/Model/Quote/ExtendedShippingInformation.php
+++ /dev/null
@@ -1,59 +0,0 @@
-cartRepository = $cartRepository;
- $this->serializer = $serializer;
- }
-
- public function update(\Magento\Quote\Model\Quote $quote, string $param, $data): \Magento\Quote\Model\Quote
- {
- $extShippingInfo = $quote->getExtShippingInfo();
- if ($extShippingInfo) {
- $extShippingInfo = $this->serializer->unserialize($extShippingInfo);
- }
-
- if (!$extShippingInfo) {
- $extShippingInfo = [];
- }
-
- if (is_array($extShippingInfo)) {
- $extShippingInfo[$param] = $data;
- $quote->setExtShippingInfo($this->serializer->serialize($extShippingInfo));
-
- $this->cartRepository->save($quote);
- }
-
- return $quote;
- }
-
- public function getParam(\Magento\Quote\Model\Quote $quote, string $param)
- {
- $extShippingInfo = $quote->getExtShippingInfo();
-
- if ($extShippingInfo) {
- $extShippingInfo = $this->serializer->unserialize($extShippingInfo);
-
- if (isset($extShippingInfo[$param])) {
- return $extShippingInfo[$param];
- }
- }
-
- return $extShippingInfo;
- }
-}
diff --git a/Plugin/Checkout/Model/TotalsInformationManagement/AddLastSelectedShippingRate.php b/Plugin/Checkout/Model/TotalsInformationManagement/AddLastSelectedShippingRate.php
deleted file mode 100644
index 6d53712..0000000
--- a/Plugin/Checkout/Model/TotalsInformationManagement/AddLastSelectedShippingRate.php
+++ /dev/null
@@ -1,75 +0,0 @@
-cartRepository = $cartRepository;
- $this->extendedShippingInformation = $extendedShippingInformation;
- $this->config = $config;
- }
-
- public function afterCalculate(
- TotalsInformationManagementInterface $subject,
- TotalsInterface $result,
- $cartId,
- TotalsInformationInterface $addressInformation
- ) {
- if (!$this->config->getAddLastSelectedShipRate()
- || (!$this->config->getIsEnableExpressCheckoutMiniCart()
- && !$this->config->getIsEnableExpressCheckoutProductPage()
- && !$this->config->getIsEnableExpressCheckoutCartPage())) {
- return $result;
- }
-
- /** @var Quote $quote */
- $quote = $this->cartRepository->get($cartId);
- $shippingRate = '';
- if ($quote->getShippingAddress()->getShippingMethod()) {
- $shippingRate = $quote->getShippingAddress()->getShippingMethod();
- } elseif ($addressInformation->getShippingCarrierCode() && $addressInformation->getShippingMethodCode()) {
- $shippingRate = implode(
- '_',
- [$addressInformation->getShippingCarrierCode(), $addressInformation->getShippingMethodCode()]
- );
- }
-
- if ($shippingRate) {
- $this->extendedShippingInformation->update(
- $quote,
- ExtendedShippingInformationInterface::LAST_SELECTED_SHIPPING_RATE,
- $shippingRate
- );
- }
-
- return $result;
- }
-}
diff --git a/Plugin/Order/Payment/State/CaptureCommand.php b/Plugin/Order/Payment/State/CaptureCommand.php
index c52b6f1..71e51cd 100644
--- a/Plugin/Order/Payment/State/CaptureCommand.php
+++ b/Plugin/Order/Payment/State/CaptureCommand.php
@@ -60,7 +60,7 @@ public function aroundExecute(
$order->setState($state);
$order->setStatus($status);
- return __($message, $order->getBaseCurrency()->formatTxt($amount));
+ return __($message, $order->getOrderCurrency()->formatTxt($amount));
}
return $proceed($payment, $amount, $order);
diff --git a/ViewModel/Container/ExpressCheckout/ExpressCheckout.php b/ViewModel/Container/ExpressCheckout/ExpressCheckout.php
index f91dd35..46bfeb0 100644
--- a/ViewModel/Container/ExpressCheckout/ExpressCheckout.php
+++ b/ViewModel/Container/ExpressCheckout/ExpressCheckout.php
@@ -1,7 +1,6 @@
'CA',
'GBP' => 'GB'
];
+ protected $localeResolver;
+ public function __construct(
+ \Magento\Framework\Serialize\SerializerInterface $serializer,
+ \Afterpay\Afterpay\Model\Config $config,
+ \Afterpay\Afterpay\Model\ResourceModel\NotAllowedProductsProvider $notAllowedProductsProvider,
+ \Magento\Store\Model\StoreManagerInterface $storeManager,
+ \Magento\Framework\Locale\Resolver $localeResolver
+ ) {
+ parent::__construct($serializer, $config, $notAllowedProductsProvider, $storeManager);
+ $this->localeResolver = $localeResolver;
+ }
public function updateJsLayout(
string $jsLayoutJson,
bool $remove = false,
@@ -22,6 +32,8 @@ public function updateJsLayout(
$config['minOrderTotal'] = $this->config->getMinOrderTotal();
$config['maxOrderTotal'] = $this->config->getMaxOrderTotal();
$config['countryCode'] = $this->getCountryCode();
+ $config['buttonImageUrl'] = 'https://static.afterpay.com/'.str_replace("_","-",$this->localeResolver->getLocale()).'/integration/button/checkout-with-afterpay/white-on-black.svg';
+
}
return parent::updateJsLayout($jsLayoutJson, $remove, $containerNodeName, $config);
}
diff --git a/ViewModel/Container/ExpressCheckout/ExpressCheckoutPdp.php b/ViewModel/Container/ExpressCheckout/ExpressCheckoutPdp.php
index 6bb1635..d03833e 100644
--- a/ViewModel/Container/ExpressCheckout/ExpressCheckoutPdp.php
+++ b/ViewModel/Container/ExpressCheckout/ExpressCheckoutPdp.php
@@ -12,10 +12,11 @@ public function __construct(
\Afterpay\Afterpay\Model\Config $config,
\Afterpay\Afterpay\Model\ResourceModel\NotAllowedProductsProvider $notAllowedProductsProvider,
\Magento\Store\Model\StoreManagerInterface $storeManager,
+ \Magento\Framework\Locale\Resolver $localeResolver,
\Magento\Catalog\Helper\Data $catalogHelper,
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory
) {
- parent::__construct($serializer, $config, $notAllowedProductsProvider, $storeManager);
+ parent::__construct($serializer, $config, $notAllowedProductsProvider, $storeManager, $localeResolver);
$this->catalogHelper = $catalogHelper;
$this->productCollectionFactory = $productCollectionFactory;
}
@@ -31,6 +32,8 @@ public function updateJsLayout(
if ($product) {
$config['isVirtual'] = $this->isProductVirtual($product);
}
+ $config['buttonImageUrl'] = 'https://static.afterpay.com/'.str_replace("_","-",$this->localeResolver->getLocale()).'/integration/button/checkout-with-afterpay/white-on-black.svg';
+
}
return parent::updateJsLayout($jsLayoutJson, $remove, $containerNodeName, $config);
}
diff --git a/composer.json b/composer.json
index 61574c9..2e44447 100644
--- a/composer.json
+++ b/composer.json
@@ -3,7 +3,7 @@
"license": "Apache-2.0",
"type": "magento2-module",
"description": "Magento 2 Afterpay Payment Module",
- "version": "4.3.2",
+ "version": "4.3.3",
"require": {
"php": "~7.1.3||~7.2.0||~7.3.0||~7.4.0",
"magento/framework": "^102.0",
diff --git a/etc/di.xml b/etc/di.xml
index 4326146..b99d178 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -7,7 +7,6 @@
-
@@ -78,6 +77,7 @@
Afterpay\Afterpay\Gateway\Request\PaymentAction\RefundAndVoidDataBuilder
Afterpay\Afterpay\Gateway\Http\RefundTransferFactory
Afterpay\Afterpay\Gateway\Http\Client\Client
+ Afterpay\Afterpay\Gateway\Response\PaymentDetailsHandler
Afterpay\Afterpay\Gateway\Validator\RefundResponseValidator
@@ -86,6 +86,7 @@
Afterpay\Afterpay\Gateway\Request\PaymentAction\ReversalDataBuilder
Afterpay\Afterpay\Gateway\Http\ReversalTransferFactory
Afterpay\Afterpay\Gateway\Http\Client\Client
+ Afterpay\Afterpay\Gateway\Response\PaymentDetailsHandler
Afterpay\Afterpay\Gateway\Validator\ReversalResponseValidator
diff --git a/etc/module.xml b/etc/module.xml
index 97346da..fe968a9 100644
--- a/etc/module.xml
+++ b/etc/module.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/etc/webapi_rest/di.xml b/etc/webapi_rest/di.xml
deleted file mode 100644
index 5aa2b9f..0000000
--- a/etc/webapi_rest/di.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
diff --git a/view/frontend/web/template/express-checkout/button-minicart.html b/view/frontend/web/template/express-checkout/button-minicart.html
index a43ee85..be3f11a 100644
--- a/view/frontend/web/template/express-checkout/button-minicart.html
+++ b/view/frontend/web/template/express-checkout/button-minicart.html
@@ -5,7 +5,7 @@
afterRender: initAfterpay
"
class="afterpay primary express-button afterpay-express-button">
-
diff --git a/view/frontend/web/template/express-checkout/button.html b/view/frontend/web/template/express-checkout/button.html
index 1f65ee8..4f5dc9a 100644
--- a/view/frontend/web/template/express-checkout/button.html
+++ b/view/frontend/web/template/express-checkout/button.html
@@ -4,7 +4,7 @@
afterRender: initAfterpay
"
class="afterpay primary express-button afterpay-express-button">
-