Skip to content

Commit

Permalink
Merge pull request #89 from Adyen/develop
Browse files Browse the repository at this point in the history
Release v2.1.0
  • Loading branch information
RokPopov authored Apr 22, 2024
2 parents 4d3d0a3 + 8e3c0c2 commit 0a80b3c
Show file tree
Hide file tree
Showing 10 changed files with 438 additions and 254 deletions.
18 changes: 18 additions & 0 deletions Api/Data/ExpressDataInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ interface ExpressDataInterface
public const MASKED_QUOTE_ID = 'masked_quote_id';
public const ADYEN_PAYMENT_METHODS = 'adyen_payment_methods';
public const TOTALS = 'totals';
public const IS_VIRTUAL_QUOTE = 'is_virtual_quote';

/**
* Get Masked Quote ID
Expand Down Expand Up @@ -59,4 +60,21 @@ public function getTotals(): ?\Magento\Quote\Api\Data\TotalsInterface;
public function setTotals(
\Magento\Quote\Api\Data\TotalsInterface $totals
): void;

/**
* Is quote virtual
*
* @return bool|null
*/
public function getIsVirtualQuote(): ?bool;

/**
* Set is quote virtual
*
* @param bool $isVirtual
* @return void
*/
public function setIsVirtualQuote(
bool $isVirtual
): void;
}
25 changes: 24 additions & 1 deletion Model/ExpressData.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Adyen\ExpressCheckout\Api\Data\ExpressDataInterface;
use Magento\Framework\DataObject;
use Magento\Quote\Api\Data\TotalsInterface;
use Magento\Quote\Model\Quote\Address\Total;

class ExpressData extends DataObject implements ExpressDataInterface
{
Expand Down Expand Up @@ -94,4 +93,28 @@ public function setTotals(TotalsInterface $totals): void
$totals
);
}

/**
* @return bool|null
*/
public function getIsVirtualQuote(): ?bool
{
$isVirtual = $this->getData(self::IS_VIRTUAL_QUOTE);

return $isVirtual ?
(bool) $isVirtual :
null;
}

/**
* @param bool $isVirtual
* @return void
*/
public function setIsVirtualQuote(bool $isVirtual): void
{
$this->setData(
self::IS_VIRTUAL_QUOTE,
$isVirtual
);
}
}
1 change: 1 addition & 0 deletions Model/ExpressDataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public function execute(
$expressData->setAdyenPaymentMethods($adyenPaymentMethods);
$maskedQuoteId = $this->getMaskedQuoteId($quote);
$expressData->setMaskedQuoteId($maskedQuoteId);
$expressData->setIsVirtualQuote($quote->isVirtual());
$cartTotals = $this->cartTotalRepository->get(
$quote->getId()
);
Expand Down
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": "adyen/adyen-magento2-expresscheckout",
"description": "Official Adyen Magento2 plugin to add express payment method shortcuts.",
"type": "magento2-module",
"version": "2.0.2",
"version": "2.1.0",
"license": "MIT",
"repositories": [
{
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Adyen_ExpressCheckout" setup_version="2.0.2">
<module name="Adyen_ExpressCheckout" setup_version="2.1.0">
<sequence>
<module name="Adyen_Payment"/>
</sequence>
Expand Down
39 changes: 39 additions & 0 deletions view/frontend/web/js/actions/getPaymentStatus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
define([
'mage/storage',
'Adyen_ExpressCheckout/js/helpers/getIsLoggedIn',
'Adyen_ExpressCheckout/js/model/maskedId',
'Adyen_ExpressCheckout/js/model/config',
'Adyen_ExpressCheckout/js/helpers/getMaskedIdFromCart'
], function (
storage,
isLoggedIn,
maskedIdModel,
configModel,
getMaskedIdFromCart
) {
'use strict';

return function (orderId, isProductView) {

return new Promise(function (resolve, reject) {
const maskedId = isProductView
? maskedIdModel().getMaskedId()
: getMaskedIdFromCart();

const config = configModel().getConfig();

let url = isLoggedIn()
? 'rest/' + config.storeCode + '/V1/adyen/orders/carts/mine/payment-status'
: 'rest/' + config.storeCode + '/V1/adyen/orders/guest-carts/' + maskedId + '/payment-status';

let payload = {
orderId: orderId
}

storage.post(
url,
JSON.stringify(payload)
).done(resolve).fail(reject);
});
};
});
13 changes: 13 additions & 0 deletions view/frontend/web/js/actions/setBillingAddress.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
define([
'mage/storage',
'Adyen_ExpressCheckout/js/helpers/getApiUrl'
], function (storage, getApiUrl) {
'use strict';

return function (payload, isProductView) {
return storage.post(
getApiUrl('billing-address', isProductView),
JSON.stringify(payload)
);
};
});
Loading

0 comments on commit 0a80b3c

Please sign in to comment.