Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
quote_payment_payflow.php
Go to the documentation of this file.
1 <?php
9  \Magento\Framework\App\Config\MutableScopeConfigInterface::class
10 )->setValue(
11  'carriers/flatrate/active',
12  1,
13  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
14 );
17 $product->setTypeId(
18  'simple'
19 )->setId(
20  1
21 )->setAttributeSetId(
22  4
23 )->setName(
24  'Simple Product'
25 )->setSku(
26  'simple'
27 )->setPrice(
28  10
29 )->setStockData(
30  ['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 100]
31 )->setVisibility(
32  \Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH
33 )->setStatus(
34  \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
35 )->save();
36 $product->load(1);
37 
39  'region' => 'CA',
40  'postcode' => '11111',
41  'lastname' => 'lastname',
42  'firstname' => 'firstname',
43  'street' => 'street',
44  'city' => 'Los Angeles',
45  'email' => '[email protected]',
46  'telephone' => '11111111',
47  'country_id' => 'US',
48 ];
49 
51  'address_id' => '',
52  'firstname' => 'testname',
53  'lastname' => 'lastname',
54  'company' => '',
55  'email' => '[email protected]',
56  'street' => [0 => 'test1', 1 => ''],
57  'city' => 'Test',
58  'region_id' => '1',
59  'region' => '',
60  'postcode' => '9001',
61  'country_id' => 'US',
62  'telephone' => '11111111',
63  'fax' => '',
64  'confirm_password' => '',
65  'save_in_address_book' => '1',
66  'use_for_shipping' => '1',
67 ];
68 
70  \Magento\Quote\Model\Quote\Address::class,
71  ['data' => $billingData]
72 );
73 $billingAddress->setAddressType('billing');
74 
76 $shippingAddress->setId(null)->setAddressType('shipping');
77 $shippingAddress->setShippingMethod('flatrate_flatrate');
78 $shippingAddress->setCollectShippingRates(true);
79 
82 $quote->setCustomerIsGuest(
83  true
84 )->setStoreId(
85  \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
86  \Magento\Store\Model\StoreManagerInterface::class
87  )->getStore()->getId()
88 )->setReservedOrderId(
89  'test02'
90 )->setBillingAddress(
92 )->setShippingAddress(
94 )->addProduct(
95  $product,
96  10
97 );
98 $quote->getShippingAddress()->setShippingMethod('flatrate_flatrate');
99 $quote->getShippingAddress()->setCollectShippingRates(true);
100 $quote->collectTotals()->save();
101 
103  \Magento\Sales\Model\Order\Payment::class
104 );
105 $payment->setMethod(\Magento\Paypal\Model\Config::METHOD_WPS_EXPRESS);
106 
107 $quote->getPayment()->setMethod(\Magento\Paypal\Model\Config::METHOD_WPS_EXPRESS)->save();
108 
111  ->create(\Magento\Quote\Api\CartManagementInterface::class);
112 $order = $service->submit($quote, ['increment_id' => '100000001']);