-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1064 from BearGroup/release/5.6.0
Release/5.6.0
- Loading branch information
Showing
40 changed files
with
423 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<?php | ||
/** | ||
* Copyright © Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
namespace Amazon\Pay\Command\Sales; | ||
|
||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Magento\Sales\Api\Data\OrderInterface; | ||
|
||
class AmazonChargePermissionCommand extends Command | ||
{ | ||
|
||
const ORDER_ID = 'orderId'; | ||
|
||
/** | ||
* @var \Magento\Framework\App\State $state | ||
*/ | ||
private $state; | ||
|
||
/** | ||
* @var \Magento\Sales\Model\OrderRepository $orderRepository | ||
*/ | ||
private $orderRepository; | ||
|
||
/** | ||
* @var \Amazon\Pay\Model\Adapter\AmazonPayAdapter $amazonAdapter | ||
*/ | ||
private $amazonAdapter; | ||
|
||
/** | ||
* @var \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder | ||
*/ | ||
private $searchCriteriaBuilder; | ||
|
||
public function __construct( | ||
\Magento\Framework\App\State $state, | ||
\Magento\Sales\Model\OrderRepository $orderRepository, | ||
\Amazon\Pay\Model\Adapter\AmazonPayAdapter $amazonAdapter, | ||
\Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder | ||
) { | ||
$this->state = $state; | ||
$this->orderRepository = $orderRepository; | ||
$this->amazonAdapter = $amazonAdapter; | ||
$this->searchCriteriaBuilder = $searchCriteriaBuilder; | ||
|
||
parent::__construct(); | ||
} | ||
|
||
protected function configure() | ||
{ | ||
$this->setName('amazon:payment:sales:verify-charge-permission'); | ||
$this->addOption( | ||
self::ORDER_ID, | ||
null, | ||
InputOption::VALUE_REQUIRED, | ||
'OrderId' | ||
); | ||
|
||
parent::configure(); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$this->state->setAreaCode(\Magento\Framework\App\Area::AREA_ADMINHTML); | ||
|
||
if ($orderId = $input->getOption(self::ORDER_ID)) { | ||
$searchCriteria = $this->searchCriteriaBuilder | ||
->addFilter(OrderInterface::INCREMENT_ID, $orderId)->create(); | ||
|
||
$orderResults = $this->orderRepository->getList($searchCriteria)->getItems(); | ||
if (empty($orderResults)) { | ||
$output->writeln('<info>No order found for order number ' . $orderId . '</info>'); | ||
return; | ||
} | ||
|
||
$order = reset($orderResults); | ||
$storeId = $order->getStoreId(); | ||
$chargePermissionId = $order->getPayment()->getAdditionalInformation('charge_permission_id'); | ||
|
||
try { | ||
$resp = $this->amazonAdapter->getChargePermission($storeId, $chargePermissionId); | ||
} catch (\Exception $ex) { | ||
$output->writeLn('<error>Error retrieving charge permission from Amazon.</error>'); | ||
} | ||
|
||
if (isset($resp['merchantMetadata']['merchantReferenceId'])) { | ||
$referenceID = $resp['merchantMetadata']['merchantReferenceId']; | ||
} | ||
|
||
$verified = $referenceID == $orderId; | ||
$output->writeln(var_export($verified)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
Test/Mftf-23/ActionGroup/AmazonShipmentFormActionGroup.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> | ||
|
||
<actionGroup name="AmazonShipmentFormActionGroup"> | ||
<fillField selector="{{StorefrontCheckoutCheckoutCustomerLoginSection.email}}" userInput="{{AmazonShippingFormData.email}}" stepKey="setCustomerEmail"/> | ||
<fillField selector="{{AmazonFillShipmentFormSection.firstname}}" userInput="{{AmazonShippingFormData.fname}}" stepKey="SetCustomerFirstName"/> | ||
<fillField selector="{{AmazonFillShipmentFormSection.lastname}}" userInput="{{AmazonShippingFormData.lname}}" stepKey="SetCustomerLastName"/> | ||
<fillField selector="{{AmazonFillShipmentFormSection.street}}" userInput="{{AmazonShippingFormData.street}}" stepKey="SetCustomerStreetAddress"/> | ||
<fillField selector="{{AmazonFillShipmentFormSection.city}}" userInput="{{AmazonShippingFormData.city}}" stepKey="SetCustomerCity"/> | ||
<fillField selector="{{AmazonFillShipmentFormSection.postcode}}" userInput="{{AmazonShippingFormData.postcode}}" stepKey="SetCustomerZipCode"/> | ||
<fillField selector="{{AmazonFillShipmentFormSection.telephone}}" userInput="{{AmazonShippingFormData.telephone}}" stepKey="SetCustomerPhoneNumber"/> | ||
<click selector="{{AmazonFillShipmentFormSection.region}}" stepKey="clickToSetState"/> | ||
<click selector="{{AmazonFillShipmentFormSection.state}}" stepKey="clickToChooseState"/> | ||
<click selector="{{AmazonFillShipmentFormSection.next}}" stepKey="clickToSaveShippingInfo"/> | ||
<waitForPageLoad time="5" stepKey="waitForReviewAndPaymentsPageIsLoaded"/> | ||
<seeInCurrentUrl url="payment" stepKey="reviewAndPaymentIsShown"/> | ||
</actionGroup> | ||
|
||
</actionGroups> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataProfileSchema.xsd"> | ||
|
||
<entity name="AmazonShippingFormData" type="shipping"> | ||
<data key="email" unique="prefix">mail@gmail.com</data> | ||
<data key="fname">firstname</data> | ||
<data key="lname">lastname</data> | ||
<data key="street">BirminghamStreet</data> | ||
<data key="city">Birmingham</data> | ||
<data key="postcode">35005</data> | ||
<data key="telephone">222222222</data> | ||
</entity> | ||
|
||
</entities> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd"> | ||
|
||
<!--Fill all required fields in shipping form--> | ||
<section name="AmazonFillShipmentFormSection"> | ||
<element name="email" type="input" selector="#customer-email" /> | ||
<element name="firstname" type="input" selector="//input[@name='firstname']"/> | ||
<element name="lastname" type="input" selector="//input[@name='lastname']"/> | ||
<element name="street" type="input" selector="//input[contains(@name, 'street')]"/> | ||
<element name="city" type="input" selector="//input[@name='city']"/> | ||
<element name="postcode" type="input" selector="//input[@name='postcode']"/> | ||
<element name="telephone" type="input" selector="//input[@name='telephone']"/> | ||
<element name="region" type="button" selector="//*[@name='region_id']"/> | ||
<element name="state" type="button" selector="//*[text()='Alabama']"/> | ||
<element name="next" type="button" selector="//span[text()='Next']"/> | ||
</section> | ||
</sections> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.