Skip to content

Commit 6729e36

Browse files
committed
MAGETWO-90533: Error on RMA shipping label creation for FedEx Smart Post
- Fixed incorrect payment type for FedEx Smart Post Return request - Added possibility to parse multiple tracking codes for one Return request
1 parent 7509a5f commit 6729e36

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

app/code/Magento/Fedex/Model/Carrier.php

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
namespace Magento\Fedex\Model;
1010

1111
use Magento\Framework\App\ObjectManager;
12+
use Magento\Framework\DataObject;
1213
use Magento\Framework\Module\Dir;
1314
use Magento\Framework\Serialize\Serializer\Json;
15+
use Magento\Framework\Webapi\Soap\ClientFactory;
1416
use Magento\Framework\Xml\Security;
1517
use Magento\Quote\Model\Quote\Address\RateRequest;
1618
use Magento\Shipping\Model\Carrier\AbstractCarrierOnline;
@@ -19,7 +21,6 @@
1921
/**
2022
* Fedex shipping implementation
2123
*
22-
* @author Magento Core Team <core@magentocommerce.com>
2324
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
2425
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2526
*/
@@ -145,6 +146,11 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C
145146
*/
146147
private $serializer;
147148

149+
/**
150+
* @var ClientFactory
151+
*/
152+
private $soapClientFactory;
153+
148154
/**
149155
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
150156
* @param \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory
@@ -166,7 +172,7 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C
166172
* @param \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory
167173
* @param array $data
168174
* @param Json|null $serializer
169-
*
175+
* @param ClientFactory|null $soapClientFactory
170176
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
171177
*/
172178
public function __construct(
@@ -189,7 +195,8 @@ public function __construct(
189195
\Magento\Framework\Module\Dir\Reader $configReader,
190196
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,
191197
array $data = [],
192-
Json $serializer = null
198+
Json $serializer = null,
199+
ClientFactory $soapClientFactory = null
193200
) {
194201
$this->_storeManager = $storeManager;
195202
$this->_productCollectionFactory = $productCollectionFactory;
@@ -216,6 +223,7 @@ public function __construct(
216223
$this->_rateServiceWsdl = $wsdlBasePath . 'RateService_v10.wsdl';
217224
$this->_trackServiceWsdl = $wsdlBasePath . 'TrackService_v' . self::$trackServiceVersion . '.wsdl';
218225
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(Json::class);
226+
$this->soapClientFactory = $soapClientFactory ?: ObjectManager::getInstance()->get(ClientFactory::class);
219227
}
220228

221229
/**
@@ -227,7 +235,7 @@ public function __construct(
227235
*/
228236
protected function _createSoapClient($wsdl, $trace = false)
229237
{
230-
$client = new \SoapClient($wsdl, ['trace' => $trace]);
238+
$client = $this->soapClientFactory->create($wsdl, ['trace' => $trace]);
231239
$client->__setLocation(
232240
$this->getConfigFlag(
233241
'sandbox_mode'
@@ -1264,7 +1272,7 @@ protected function _formShipmentRequest(\Magento\Framework\DataObject $request)
12641272
$countriesOfManufacture[] = $product->getCountryOfManufacture();
12651273
}
12661274

1267-
$paymentType = $request->getIsReturn() ? 'RECIPIENT' : 'SENDER';
1275+
$paymentType = $this->getPaymentType($request);
12681276
$optionType = $request->getShippingMethod() == self::RATE_REQUEST_SMARTPOST
12691277
? 'SERVICE_DEFAULT' : $packageParams->getDeliveryConfirmation();
12701278
$requestClient = [
@@ -1750,4 +1758,18 @@ private function parseDate($timestamp)
17501758

17511759
return false;
17521760
}
1761+
1762+
/**
1763+
* Defines payment type by request.
1764+
* Two values are available: RECIPIENT or SENDER.
1765+
*
1766+
* @param DataObject $request
1767+
* @return string
1768+
*/
1769+
private function getPaymentType(DataObject $request): string
1770+
{
1771+
return $request->getIsReturn() && $request->getShippingMethod() !== self::RATE_REQUEST_SMARTPOST
1772+
? 'RECIPIENT'
1773+
: 'SENDER';
1774+
}
17531775
}

dev/tests/integration/testsuite/Magento/Sales/_files/address_data.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
return [
88
'region' => 'CA',
9+
'region_id' => '12',
910
'postcode' => '11111',
1011
'lastname' => 'lastname',
1112
'firstname' => 'firstname',

0 commit comments

Comments
 (0)