Open schwarzh opened 7 years ago
Made a couple attempts at this, but haven't had much luck. I tried a few things, but the last attempt was adding the following code to the build_rate_request method (in fedex.rb):
if package_value = packages.map(&:value).inject(0, :+)
xml.TotalInsuredValue(package_value)
end
Which resulted in the following error:
<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<SOAP-ENV:Fault xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"><faultcode>SOAP-ENV:Server</faultcode><faultstring xml:lang=\"en\">Fault</faultstring><detail><cause>UnrecoverableClientError</cause><code>SchemaError</code><desc>validation failure for RateRequest Error:cvc-complex-type.2.3: Element 'TotalInsuredValue' cannot have character [children], because the type's content type is element-only.\ncvc-complex-type.2.4.a: Invalid content was found starting with element 'DropoffType'. One of '{\"http://fedex.com/ws/rate/v13\":TotalDimensions, \"http://fedex.com/ws/rate/v13\":PreferredCurrency, \"http://fedex.com/ws/rate/v13\":Shipper, \"http://fedex.com/ws/rate/v13\":Recipient, \"http://fedex.com/ws/rate/v13\":RecipientLocationNumber, \"http://fedex.com/ws/rate/v13\":Origin, \"http://fedex.com/ws/rate/v13\":ShippingChargesPayment, \"http://fedex.com/ws/rate/v13\":SpecialServicesRequested, \"http://fedex.com/ws/rate/v13\":ProcessingOptionsRequested, \"http://fedex.com/ws/rate/v13\":ExpressFreightDetail, \"http://fedex.com/ws/rate/v13\":FreightShipmentDetail, \"http://fedex.com/ws/rate/v13\":ConsolidationDetail, \"http://fedex.com/ws/rate/v13\":DeliveryInstructions, \"http://fedex.com/ws/rate/v13\":VariableHandlingChargeDetail, \"http://fedex.com/ws/rate/v13\":CustomsClearanceDetail, \"http://fedex.com/ws/rate/v13\":PickupDetail, \"http://fedex.com/ws/rate/v13\":SmartPostDetail, \"http://fedex.com/ws/rate/v13\":BlockInsightVisibility, \"http://fedex.com/ws/rate/v13\":ErrorLabelBehavior, \"http://fedex.com/ws/rate/v13\":LabelSpecification, \"http://fedex.com/ws/rate/v13\":ShippingDocumentSpecification, \"http://fedex.com/ws/rate/v13\":RateRequestTypes, \"http://fedex.com/ws/rate/v13\":CustomerSelectedActualRateType, \"http://fedex.com/ws/rate/v13\":EdtRequestType, \"http://fedex.com/ws/rate/v13\":CustomRatingOptionDetail, \"http://fedex.com/ws/rate/v13\":MasterTrackingId, \"http://fedex.com/ws/rate/v13\":PackageCount, \"http://fedex.com/ws/rate/v13\":ShipmentOnlyFields, \"http://fedex.com/ws/rate/v13\":ConfigurationData, \"http://fedex.com/ws/rate/v13\":RequestedPackageLineItems}' is expected.</desc></detail></SOAP-ENV:Fault>"
And this is the XML that was sent:
<RateRequest xmlns=\"http://fedex.com/ws/rate/v13\">
<WebAuthenticationDetail> <UserCredential> <Key>fPGqDwpdKoveCE6z</Key>
<Password>2tFEETmfNbF50mtUiMXNIw4zX</Password> </UserCredential>
</WebAuthenticationDetail> <ClientDetail> <AccountNumber>510087160</AccountNumber>
<MeterNumber>100316538</MeterNumber> </ClientDetail> <TransactionDetail>
<CustomerTransactionId>ActiveShipping</CustomerTransactionId> </TransactionDetail>
<Version> <ServiceId>crs</ServiceId> <Major>13</Major> <Intermediate>0</Intermediate>
<Minor>0</Minor> </Version> <ReturnTransitAndCommit>true</ReturnTransitAndCommit>
<VariableOptions>SATURDAY_DELIVERY</VariableOptions> <RequestedShipment>
<ShipTimestamp>2017-03-29T10:33:02-07:00</ShipTimestamp>
<TotalInsuredValue>200</TotalInsuredValue> <DropoffType>REGULAR_PICKUP</DropoffType>
<PackagingType>YOUR_PACKAGING</PackagingType> <Shipper> <Address>
<PostalCode>07114</PostalCode> <CountryCode>US</CountryCode>
<Residential>true</Residential> </Address> </Shipper> <Recipient> <Address>
<City>Mississauga</City> <PostalCode>L5N 2L8</PostalCode>
<CountryCode>CA</CountryCode> <Residential>true</Residential> </Address>
</Recipient> <SmartPostDetail> <Indicia>PARCEL_SELECT</Indicia> <HubId>5902</HubId>
</SmartPostDetail> <RateRequestTypes>ACCOUNT</RateRequestTypes>
<PackageCount>1</PackageCount> <RequestedPackageLineItems>
<GroupPackageCount>1</GroupPackageCount> <Weight> <Units>LB</Units>
<Value>7.5</Value> </Weight> <Dimensions> <Length>15</Length>
<Width>10</Width> <Height>5</Height> <Units>IN</Units> </Dimensions>
</RequestedPackageLineItems> </RequestedShipment> </RateRequest>
This XML looks correct to me based on the FedEx Developers guide. Feeling pretty stuck here, so I'm going to try this with a different Rails gem.
Brad
It doesn't look like active_shipping currently supports passing the insured value for a package when using FedEx. It appears to be implemented for UPS. What is the best way to implement this for FedEx?
It looks like it may be as simple as adding some code to the FedEx build_packages_nodes method that does something similar to how it was done with UPS (see commit below)?
https://github.com/Shopify/active_shipping/commit/b26844fbd2535c635afbed04acb78716646b6d69
Any advice would be much appreciated.
Thanks much, Brad