Skip to content

Commit c0c2411

Browse files
committed
MAGETWO-60326: [Backport] - [GITHUB] Orders always get a status of Suspected Fraud in multi-currency store configurations #4263 - for 2.1
1 parent f56188d commit c0c2411

File tree

10 files changed

+385
-2
lines changed

10 files changed

+385
-2
lines changed

app/code/Magento/Sales/Model/Order/Payment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1272,7 +1272,7 @@ public function getAuthorizationTransaction()
12721272
*/
12731273
public function isCaptureFinal($amountToCapture)
12741274
{
1275-
$total = $this->getOrder()->getTotalDue();
1275+
$total = $this->getOrder()->getBaseTotalDue();
12761276
return $this->formatAmount($total, true) == $this->formatAmount($amountToCapture, true);
12771277
}
12781278

app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1520,7 +1520,7 @@ public function testIsCaptureFinal()
15201520
$partialAmount = 12.00;
15211521

15221522
$this->orderMock->expects(static::exactly(2))
1523-
->method('getTotalDue')
1523+
->method('getBaseTotalDue')
15241524
->willReturn($amount);
15251525

15261526
static::assertFalse($this->payment->isCaptureFinal($partialAmount));

dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Repository/ConfigData.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,5 +159,34 @@
159159
</item>
160160
</field>
161161
</dataset>
162+
163+
<dataset name="config_allow_and_default_currency_eur">
164+
<field name="currency/options/allow" xsi:type="array">
165+
<item name="scope" xsi:type="string">currency</item>
166+
<item name="value" xsi:type="array">
167+
<item name="US Dollar" xsi:type="string">USD</item>
168+
<item name="Euro" xsi:type="string">EUR</item>
169+
</item>
170+
</field>
171+
<field name="currency/options/default" xsi:type="array">
172+
<item name="scope" xsi:type="string">currency</item>
173+
<item name="label" xsi:type="string">Euro</item>
174+
<item name="value" xsi:type="string">EUR</item>
175+
</field>
176+
</dataset>
177+
178+
<dataset name="config_allow_and_default_currency_eur_rollback">
179+
<field name="currency/options/allow" xsi:type="array">
180+
<item name="scope" xsi:type="string">currency</item>
181+
<item name="value" xsi:type="array">
182+
<item name="US Dollar" xsi:type="string">USD</item>
183+
</item>
184+
</field>
185+
<field name="currency/options/default" xsi:type="array">
186+
<item name="scope" xsi:type="string">currency</item>
187+
<item name="label" xsi:type="string">US Dollar</item>
188+
<item name="value" xsi:type="string">USD</item>
189+
</field>
190+
</dataset>
162191
</repository>
163192
</config>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Paypal\Test\TestCase;
7+
8+
use Magento\Mtf\TestCase\Scenario;
9+
use Magento\Mtf\TestStep\TestStepFactory;
10+
11+
/**
12+
* Preconditions:
13+
* 1. Create simple product.
14+
* 2. Configure PayPal Payflow Pro.
15+
* 3. Configure Flat Rate.
16+
* 4. Set Base Currency US Dollar
17+
* 5. Create custom store view for Main Website.
18+
* 6. Set default display currency Euro for custom store view.
19+
*
20+
* Steps:
21+
* 1. Go to storefront.
22+
* 2. Switch to the additional Store View.
23+
* 3. Add simple product to the cart.
24+
* 4. Proceed to checkout.
25+
* 5. Specify shiping address data (US Customer 1).
26+
* 6. Specify shipping method (Fixed Flat Rate).
27+
* 7. Select payment method Credit Card (PayFlow Pro).
28+
* 8. Fill required fields for credit card.
29+
* 9. Click Submit order button.
30+
* 10. Make assertions.
31+
*
32+
* @group PayPal
33+
* @ZephyrId MAGETWO-61668
34+
*/
35+
class CreatePayFlowOrderCustomStoreTest extends Scenario
36+
{
37+
/* tags */
38+
const MVP = 'yes';
39+
const TEST_TYPE = '3rd_party_test';
40+
const SEVERITY = 'S2';
41+
/* end tags */
42+
43+
/**
44+
* Runs sales order on backend.
45+
*
46+
* @return void
47+
*/
48+
public function test()
49+
{
50+
$this->executeScenario();
51+
}
52+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
9+
<testCase name="Magento\Paypal\Test\TestCase\CreatePayFlowOrderCustomStoreTest"
10+
summary="Place order using PayPal Payflow Pro from different store-view with non base currency"
11+
ticketId="MAGETWO-61668">
12+
<variation name="CreatePayFlowOrderCustomStoreTestVariation1"
13+
summary="Place order using PayPal Payflow Pro from different store-view with non base currency">
14+
<data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S2</data>
15+
<data name="products/0" xsi:type="string">catalogProductSimple::product_10_dollar</data>
16+
<data name="checkoutMethod" xsi:type="string">guest</data>
17+
<data name="shippingAddress/dataset" xsi:type="string">default</data>
18+
<data name="saveAddress" xsi:type="string">No</data>
19+
<data name="shipping/shipping_service" xsi:type="string">Flat Rate</data>
20+
<data name="shipping/shipping_method" xsi:type="string">Fixed</data>
21+
<data name="prices" xsi:type="array">
22+
<item name="grandTotal" xsi:type="string">10.60</item>
23+
<item name="grandTotalBase" xsi:type="string">15</item>
24+
</data>
25+
<data name="payment/method" xsi:type="string">payflowpro</data>
26+
<data name="creditCardClass" xsi:type="string">credit_card</data>
27+
<data name="creditCard/dataset" xsi:type="string">visa_payflow</data>
28+
<data name="store/dataset" xsi:type="string">custom</data>
29+
<data name="configData" xsi:type="string">payflowpro</data>
30+
<data name="storeConfig" xsi:type="string">config_allow_and_default_currency_eur</data>
31+
<data name="status" xsi:type="string">Processing</data>
32+
<constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" />
33+
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotalBase" />
34+
</variation>
35+
</testCase>
36+
</config>

dev/tests/functional/tests/app/Magento/Paypal/Test/etc/testcase.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,21 @@
8585
<step name="saveCreditCardOnBackend" module="Magento_Vault" next="submitOrderNegative" />
8686
<step name="submitOrderNegative" module="Magento_Sales" />
8787
</scenario>
88+
<scenario name="CreatePayFlowOrderCustomStoreTest" firstStep="createProducts">
89+
<step name="createProducts" module="Magento_Catalog" next="createCustomStore" />
90+
<step name="createCustomStore" module="Magento_Store" next="setupConfiguration" />
91+
<step name="setupConfiguration" module="Magento_Config" next="applyStoreConfig" />
92+
<step name="applyStoreConfig" module="Magento_Store" next="selectStoreFrontend" />
93+
<step name="selectStoreFrontend" module="Magento_Sales" next="addProductsToTheCart" />
94+
<step name="addProductsToTheCart" module="Magento_Checkout" next="estimateShippingAndTax" />
95+
<step name="estimateShippingAndTax" module="Magento_Checkout" next="clickProceedToCheckout" />
96+
<step name="clickProceedToCheckout" module="Magento_Checkout" next="selectCheckoutMethod" />
97+
<step name="selectCheckoutMethod" module="Magento_Checkout" next="fillShippingAddress" />
98+
<step name="fillShippingAddress" module="Magento_Checkout" next="fillShippingMethod" />
99+
<step name="fillShippingMethod" module="Magento_Checkout" next="selectPaymentMethod" />
100+
<step name="selectPaymentMethod" module="Magento_Checkout" next="fillBillingInformation" />
101+
<step name="fillBillingInformation" module="Magento_Checkout" next="placeOrder" />
102+
<step name="placeOrder" module="Magento_Checkout" next="openOrder" />
103+
<step name="openOrder" module="Magento_Sales" />
104+
</scenario>
88105
</config>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Sales\Test\Constraint;
8+
9+
use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
10+
use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
11+
use Magento\Mtf\Constraint\AbstractConstraint;
12+
13+
/**
14+
* Assert that Order Grand Total (base currency) is correct on order page in backend.
15+
*/
16+
class AssertOrderGrandTotalBase extends AbstractConstraint
17+
{
18+
/**
19+
* Assert that Order Grand Total (base currency) is correct on order page in backend.
20+
*
21+
* @param SalesOrderView $salesOrderView
22+
* @param OrderIndex $salesOrder
23+
* @param string $orderId
24+
* @param array $prices
25+
* @return void
26+
*/
27+
public function processAssert(
28+
SalesOrderView $salesOrderView,
29+
OrderIndex $salesOrder,
30+
$orderId,
31+
array $prices
32+
) {
33+
$salesOrder->open();
34+
$salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
35+
36+
\PHPUnit_Framework_Assert::assertEquals(
37+
$prices['grandTotalBase'],
38+
$salesOrderView->getOrderTotalsBlock()->getGrandTotal(),
39+
'Grand Total price does not equal to price from data set.'
40+
);
41+
}
42+
43+
/**
44+
* Returns a string representation of the object.
45+
*
46+
* @return string
47+
*/
48+
public function toString()
49+
{
50+
return 'Grand Total price equals to price from data set.';
51+
}
52+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Sales\Test\TestStep;
8+
9+
use Magento\Cms\Test\Page\CmsIndex;
10+
use Magento\Store\Test\Fixture\Store;
11+
use Magento\Mtf\TestStep\TestStepInterface;
12+
13+
/**
14+
* Step for select store.
15+
*/
16+
class SelectStoreFrontendStep implements TestStepInterface
17+
{
18+
/**
19+
* Store fixture.
20+
*
21+
* @var Store
22+
*/
23+
private $store;
24+
25+
/**
26+
* Cms Index page.
27+
*
28+
* @var CmsIndex
29+
*/
30+
private $cmsIndex;
31+
32+
/**
33+
* Preparing step properties.
34+
*
35+
* @param Store $store
36+
* @param CmsIndex $cmsIndex
37+
*/
38+
public function __construct(Store $store, CmsIndex $cmsIndex)
39+
{
40+
$this->store = $store;
41+
$this->cmsIndex = $cmsIndex;
42+
}
43+
44+
/**
45+
* Select store on order create page.
46+
*
47+
* @return void
48+
*/
49+
public function run()
50+
{
51+
$this->cmsIndex->open();
52+
if ($this->cmsIndex->getStoreSwitcherBlock()->isVisible()) {
53+
$this->cmsIndex->getStoreSwitcherBlock()->selectStoreView($this->store->getName());
54+
}
55+
}
56+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Store\Test\TestStep;
8+
9+
use Magento\Config\Test\Fixture\ConfigData;
10+
use Magento\Mtf\Fixture\FixtureFactory;
11+
use Magento\Mtf\TestStep\TestStepInterface;
12+
use Magento\Store\Test\Fixture\Store;
13+
14+
/**
15+
* Apply Store Config.
16+
*/
17+
class ApplyStoreConfigStep implements TestStepInterface
18+
{
19+
/**
20+
* Fixture creation factory.
21+
*
22+
* @var FixtureFactory
23+
*/
24+
private $fixtureFactory;
25+
26+
/**
27+
* Fixture Store.
28+
*
29+
* @var Store
30+
*/
31+
private $store;
32+
33+
/**
34+
* Store specific config data.
35+
*
36+
* @var string
37+
*/
38+
private $storeConfigData;
39+
40+
/**
41+
* Rollback.
42+
*
43+
* @var bool
44+
*/
45+
private $rollback;
46+
47+
/**
48+
* @param FixtureFactory $fixtureFactory
49+
* @param Store $store
50+
* @param string $storeConfig
51+
* @param bool $rollback
52+
*/
53+
public function __construct(FixtureFactory $fixtureFactory, Store $store, $storeConfig, $rollback = false)
54+
{
55+
$this->fixtureFactory = $fixtureFactory;
56+
$this->store = $store;
57+
$this->storeConfigData = $storeConfig;
58+
$this->rollback = $rollback;
59+
}
60+
61+
/**
62+
* Apply Custom Store config.
63+
*
64+
* @return void
65+
*/
66+
public function run()
67+
{
68+
$configData = array_map('trim', explode(',', $this->storeConfigData));
69+
$prefix = ($this->rollback == false) ? '' : '_rollback';
70+
71+
foreach ($configData as $configDataSet) {
72+
/** @var ConfigData $config */
73+
$config = $this->fixtureFactory->createByCode('configData', ['dataset' => $configDataSet . $prefix]);
74+
if ($config->hasData('section')) {
75+
$data = array_merge(
76+
['scope' => ['fixture' => $this->store, 'scope_type' => 'store', 'set_level' => 'store']],
77+
$config->getSection()
78+
);
79+
80+
$config = $this->fixtureFactory->createByCode('configData', ['data' => $data]);
81+
$config->persist();
82+
}
83+
}
84+
}
85+
86+
/**
87+
* Rollback configuration.
88+
*
89+
* @return void
90+
*/
91+
public function cleanup()
92+
{
93+
$this->rollback = true;
94+
$this->run();
95+
}
96+
}

0 commit comments

Comments
 (0)