I'm trying to use the active_shipping
gem from Shopify to ship and track packages from several carriers.
I'm having trouble with the create_shipment
method from Fedex carrier. When it's a domestic shipping everything works fine, but when the destination country is different from the origin country, I always get an error message:
ERROR - 2033: Customs Value is required.
or ERROR - 3907: Invalid Customs Value
depending on the service type.
I understand that I have to supply the package content information for the customs declaration, but I didn't find any way to pass it to the method.
I looked in ActiveShipping::FedEx
, especially the create_shipment
and the build_shipment_request
methods, but didn't find anything related to the package content.
Here is how I try to create the shipment:
package = ActiveShipping::Package.new(
weight,
[width, height, depth],
{
units: :metric,
value: value,
currency: 'CAD'
}
)
origin = ActiveShipping::Location.new(
company: '***',
address1: '***',
country: 'CA',
province: 'QC',
city: '***',
postal_code: '***',
phone: '***',
address_type: 'commercial'
)
destination = ActiveShipping::Location.new(
name: shipment.name,
company: shipment.company,
address1: shipment.line_1,
address2: shipment.line_2,
country: shipment.country,
province: shipment.state,
city: shipment.city,
postal_code: shipment.zip,
phone: shipment.phone
)
fedex = ActiveShipping::FedEx.new(
login: '***',
password: '***',
key: '***',
account: '***',
test: true
)
options = {
service_type: service_code
}
response = fedex.create_shipment(origin, destination, package, options)
Am I missing something or is the active_shipping
gem simply not compatible with international shipments using Fedex?
With other carriers like Canada Post you can pass an array of ActiveShipping::PackageItem
but apparently not with Fedex.
I'm using the latest gem version (1.4.2) on Rails 4.2.3