-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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 #697 from magento-mpi/MAGETWO-54389
[MPI] Fix PayPal Express Checkout place order method
- Loading branch information
Showing
6 changed files
with
201 additions
and
166 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
95 changes: 95 additions & 0 deletions
95
dev/tests/integration/testsuite/Magento/Paypal/_files/quote_express.php
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,95 @@ | ||
<?php | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
\Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea('adminhtml'); | ||
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( | ||
\Magento\Framework\App\Config\MutableScopeConfigInterface::class | ||
)->setValue( | ||
'carriers/flatrate/active', | ||
1, | ||
\Magento\Store\Model\ScopeInterface::SCOPE_STORE | ||
); | ||
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( | ||
\Magento\Framework\App\Config\MutableScopeConfigInterface::class | ||
)->setValue( | ||
'payment/paypal_express/active', | ||
1, | ||
\Magento\Store\Model\ScopeInterface::SCOPE_STORE | ||
); | ||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); | ||
/** @var $product \Magento\Catalog\Model\Product */ | ||
$product = $objectManager->create(\Magento\Catalog\Model\Product::class); | ||
$product->setTypeId('simple') | ||
->setId(1) | ||
->setAttributeSetId(4) | ||
->setName('Simple Product') | ||
->setSku('simple') | ||
->setPrice(10) | ||
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) | ||
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) | ||
->setStockData( | ||
[ | ||
'qty' => 100, | ||
'is_in_stock' => 1, | ||
] | ||
)->save(); | ||
$product->load(1); | ||
|
||
$billingData = [ | ||
'firstname' => 'testname', | ||
'lastname' => 'lastname', | ||
'company' => '', | ||
'email' => '[email protected]', | ||
'street' => [ | ||
0 => 'test1', | ||
1 => '', | ||
], | ||
'city' => 'Test', | ||
'region_id' => '1', | ||
'region' => '', | ||
'postcode' => '9001', | ||
'country_id' => 'US', | ||
'telephone' => '11111111', | ||
'fax' => '', | ||
'confirm_password' => '', | ||
'save_in_address_book' => '1', | ||
'use_for_shipping' => '1', | ||
]; | ||
|
||
$billingAddress = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() | ||
->create(\Magento\Quote\Model\Quote\Address::class, ['data' => $billingData]); | ||
$billingAddress->setAddressType('billing'); | ||
|
||
$shippingAddress = clone $billingAddress; | ||
$shippingAddress->setId(null)->setAddressType('shipping'); | ||
$shippingAddress->setShippingMethod('flatrate_flatrate'); | ||
$shippingAddress->setCollectShippingRates(true); | ||
|
||
/** @var $quote \Magento\Quote\Model\Quote */ | ||
$quote = $objectManager->create(\Magento\Quote\Model\Quote::class); | ||
$quote->setCustomerIsGuest( | ||
true | ||
)->setStoreId( | ||
$objectManager->get( | ||
\Magento\Store\Model\StoreManagerInterface::class | ||
)->getStore()->getId() | ||
)->setReservedOrderId( | ||
'100000002' | ||
)->setBillingAddress( | ||
$billingAddress | ||
)->setShippingAddress( | ||
$shippingAddress | ||
)->addProduct( | ||
$product, | ||
10 | ||
); | ||
$quote->getShippingAddress()->setShippingMethod('flatrate_flatrate'); | ||
$quote->getShippingAddress()->setCollectShippingRates(true); | ||
$quote->getPayment()->setMethod(\Magento\Paypal\Model\Config::METHOD_WPS_EXPRESS); | ||
|
||
$quoteRepository = $objectManager->get(\Magento\Quote\Api\CartRepositoryInterface::class); | ||
$quoteRepository->save($quote); | ||
$quote = $quoteRepository->get($quote->getId()); | ||
$quote->setCustomerEmail('[email protected]'); |
77 changes: 77 additions & 0 deletions
77
dev/tests/integration/testsuite/Magento/Paypal/_files/quote_express_with_customer.php
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,77 @@ | ||
<?php | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
require __DIR__ . '/../../Customer/_files/customer.php'; | ||
require __DIR__ . '/../../Customer/_files/customer_two_addresses.php'; | ||
|
||
\Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea('adminhtml'); | ||
|
||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); | ||
|
||
$objectManager->get( | ||
\Magento\Framework\App\Config\MutableScopeConfigInterface::class | ||
)->setValue('carriers/flatrate/active', 1, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); | ||
$objectManager->get(\Magento\Framework\App\Config\MutableScopeConfigInterface::class) | ||
->setValue('payment/paypal_express/active', 1, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); | ||
|
||
/** @var \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository */ | ||
$customerRepository = $objectManager->create(\Magento\Customer\Api\CustomerRepositoryInterface::class); | ||
$customer = $customerRepository->getById(1); | ||
|
||
/** @var $product \Magento\Catalog\Model\Product */ | ||
$product = $objectManager->create(\Magento\Catalog\Model\Product::class); | ||
$product->setTypeId('simple') | ||
->setId(1) | ||
->setAttributeSetId(4) | ||
->setName('Simple Product') | ||
->setSku('simple') | ||
->setPrice(10) | ||
->setStockData([ | ||
'use_config_manage_stock' => 1, | ||
'qty' => 100, | ||
'is_qty_decimal' => 0, | ||
'is_in_stock' => 100, | ||
]) | ||
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) | ||
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) | ||
->save(); | ||
$product->load(1); | ||
|
||
$customerBillingAddress = $objectManager->create(\Magento\Customer\Model\Address::class); | ||
$customerBillingAddress->load(1); | ||
$billingAddressDataObject = $customerBillingAddress->getDataModel(); | ||
$billingAddress = $objectManager->create(\Magento\Quote\Model\Quote\Address::class); | ||
$billingAddress->importCustomerAddressData($billingAddressDataObject); | ||
$billingAddress->setAddressType('billing'); | ||
|
||
/** @var \Magento\Customer\Model\Address $customerShippingAddress */ | ||
$customerShippingAddress = $objectManager->create(\Magento\Customer\Model\Address::class); | ||
$customerShippingAddress->load(2); | ||
$shippingAddressDataObject = $customerShippingAddress->getDataModel(); | ||
$shippingAddress = $objectManager->create(\Magento\Quote\Model\Quote\Address::class); | ||
$shippingAddress->importCustomerAddressData($shippingAddressDataObject); | ||
$shippingAddress->setAddressType('shipping'); | ||
|
||
$shippingAddress->setShippingMethod('flatrate_flatrate'); | ||
$shippingAddress->setCollectShippingRates(true); | ||
|
||
/** @var $quote \Magento\Quote\Model\Quote */ | ||
$quote = $objectManager->create(\Magento\Quote\Model\Quote::class); | ||
$quote->setCustomerIsGuest(false) | ||
->setCustomerId($customer->getId()) | ||
->setCustomer($customer) | ||
->setStoreId($objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)->getStore()->getId()) | ||
->setReservedOrderId('test02') | ||
->setBillingAddress($billingAddress) | ||
->setShippingAddress($shippingAddress) | ||
->addProduct($product, 10); | ||
$quote->getShippingAddress()->setShippingMethod('flatrate_flatrate'); | ||
$quote->getShippingAddress()->setCollectShippingRates(true); | ||
$quote->getPayment()->setMethod(\Magento\Paypal\Model\Config::METHOD_WPS_EXPRESS); | ||
|
||
/** @var \Magento\Quote\Api\CartRepositoryInterface $quoteRepository */ | ||
$quoteRepository = $objectManager->create(\Magento\Quote\Api\CartRepositoryInterface::class); | ||
$quoteRepository->save($quote); | ||
$quote = $quoteRepository->get($quote->getId()); |
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 |
---|---|---|
|
@@ -3,96 +3,7 @@ | |
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
\Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea('adminhtml'); | ||
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( | ||
\Magento\Framework\App\Config\MutableScopeConfigInterface::class | ||
)->setValue( | ||
'carriers/flatrate/active', | ||
1, | ||
\Magento\Store\Model\ScopeInterface::SCOPE_STORE | ||
); | ||
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( | ||
\Magento\Framework\App\Config\MutableScopeConfigInterface::class | ||
)->setValue( | ||
'payment/paypal_express/active', | ||
1, | ||
\Magento\Store\Model\ScopeInterface::SCOPE_STORE | ||
); | ||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); | ||
/** @var $product \Magento\Catalog\Model\Product */ | ||
$product = $objectManager->create(\Magento\Catalog\Model\Product::class); | ||
$product->setTypeId('simple') | ||
->setId(1) | ||
->setAttributeSetId(4) | ||
->setName('Simple Product') | ||
->setSku('simple') | ||
->setPrice(10) | ||
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) | ||
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) | ||
->setStockData( | ||
[ | ||
'qty' => 100, | ||
'is_in_stock' => 1, | ||
] | ||
)->save(); | ||
$product->load(1); | ||
|
||
$billingData = [ | ||
'firstname' => 'testname', | ||
'lastname' => 'lastname', | ||
'company' => '', | ||
'email' => '[email protected]', | ||
'street' => [ | ||
0 => 'test1', | ||
1 => '', | ||
], | ||
'city' => 'Test', | ||
'region_id' => '1', | ||
'region' => '', | ||
'postcode' => '9001', | ||
'country_id' => 'US', | ||
'telephone' => '11111111', | ||
'fax' => '', | ||
'confirm_password' => '', | ||
'save_in_address_book' => '1', | ||
'use_for_shipping' => '1', | ||
]; | ||
|
||
$billingAddress = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() | ||
->create(\Magento\Quote\Model\Quote\Address::class, ['data' => $billingData]); | ||
$billingAddress->setAddressType('billing'); | ||
|
||
$shippingAddress = clone $billingAddress; | ||
$shippingAddress->setId(null)->setAddressType('shipping'); | ||
$shippingAddress->setShippingMethod('flatrate_flatrate'); | ||
$shippingAddress->setCollectShippingRates(true); | ||
|
||
/** @var $quote \Magento\Quote\Model\Quote */ | ||
$quote = $objectManager->create(\Magento\Quote\Model\Quote::class); | ||
$quote->setCustomerIsGuest( | ||
true | ||
)->setStoreId( | ||
$objectManager->get( | ||
\Magento\Store\Model\StoreManagerInterface::class | ||
)->getStore()->getId() | ||
)->setReservedOrderId( | ||
'100000002' | ||
)->setBillingAddress( | ||
$billingAddress | ||
)->setShippingAddress( | ||
$shippingAddress | ||
)->addProduct( | ||
$product, | ||
10 | ||
); | ||
$quote->getShippingAddress()->setShippingMethod('flatrate_flatrate'); | ||
$quote->getShippingAddress()->setCollectShippingRates(true); | ||
$quote->getPayment()->setMethod(\Magento\Paypal\Model\Config::METHOD_WPS_EXPRESS); | ||
|
||
$quoteRepository = $objectManager->get(\Magento\Quote\Api\CartRepositoryInterface::class); | ||
$quoteRepository->save($quote); | ||
$quote = $quoteRepository->get($quote->getId()); | ||
$quote->setCustomerEmail('[email protected]'); | ||
require __DIR__ . '/quote_express.php'; | ||
|
||
/** @var $service \Magento\Quote\Api\CartManagementInterface */ | ||
$service = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() | ||
|
Oops, something went wrong.