1

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

Daniel Widdis
  • 8,424
  • 13
  • 41
  • 63
Johann
  • 748
  • 5
  • 17
  • I know this is stagnant but I'm facing it now, did you by any chance find a solution to this? – Datise Apr 20 '16 at 03:46
  • Sadly no, I never found a solution for this. I was going to investigate further and possibly make a PR on the active_shipping repo, but my employer at the time decided to stop using Fedex as a carrier for other reasons, so I stopped looking. – Johann Apr 20 '16 at 18:13
  • @Datise did you find any solution ? Even I'm stuck with the same issue. – Nitin Satish Salunke May 17 '16 at 15:07
  • @NitinSatishSalunke No unfortunately, I don't think there is one within the functionality of the current gem. After going over the docs it seems like all fedex needs is an extra xml field. It would be pretty easy to thread a new parameter and add it to their xml building but I haven't had the time to fork/pull request. Hoping to get around to it this week. – Datise May 18 '16 at 21:11
  • @Datise yes we need to add additional fields in the xml. – Nitin Satish Salunke May 18 '16 at 21:30
  • @NitinSatishSalunke I see you made a PR a while ago but I am having trouble reading it, is the COD option to support this problem? – Datise May 19 '16 at 17:30
  • @Datise COD is just my requirement, you have to just look at the CustomeClearanceDetail part. – Nitin Satish Salunke May 19 '16 at 21:17
  • @Datise Btw I feel there is an excellent solution out there instead of wasting time with Fedex's WSDL. Check this out http://postmen.com/ – Nitin Satish Salunke May 19 '16 at 21:21
  • Thanks for the link, postmen looks pretty basic. I'm pretty close to finishing this contract so maybe on my next go around. – Datise May 19 '16 at 21:58

2 Answers2

0

We need to add the following xml fields just after the

"ShippingChargesPayment" element

in "build_shipment_request" method

       xml.CustomsClearanceDetail do
          xml.DutiesPayment do
            xml.PaymentType('SENDER')
            xml.Payor do
              xml.ResponsibleParty do
                xml.AccountNumber(6xxxxxx61)
                xml.Contact do
                  xml.PersonName('Sender Name')
                  xml.EMailAddress('sender@email.com')
                end
                xml.Address do
                  xml.StreetLines('Steetline 1')
                  xml.StreetLines('Streetline 2')
                  xml.City('Margao')
                  xml.StateOrProvinceCode('GA')
                  xml.PostalCode(403601)
                  xml.CountryCode('IN')
                end
              end
            end
          end

          xml.DocumentContent('NON_DOCUMENTS')

          xml.CustomsValue do
            xml.Currency('INR')
            xml.Amount(100)
          end

          xml.FreightOnValue('CARRIER_RISK')

          xml.CommercialInvoice do
            xml.Comments('Comments from seller.')
            xml.SpecialInstructions('Special Instructions from seller.')
            xml.Purpose('SOLD')
            xml.CustomerReferences do
              xml.CustomerReferenceType('CUSTOMER_REFERENCE')
              xml.Value('Bill D/T Sender')
            end
          end

          xml.Commodities do
            xml.NumberOfPieces(1)
            xml.Description('Pink Toy')
            xml.CountryOfManufacture('IN')
            xml.Weight do
              xml.Units('KG')
              xml.Value(2)
            end
            xml.Quantity(1)
            xml.QuantityUnits('EA')
            xml.UnitPrice do
              xml.Currency('INR')
              xml.Amount(100)
            end
            xml.CustomsValue do
              xml.Currency('INR')
              xml.Amount(100)
            end
          end
        end
Community
  • 1
  • 1
0

I've created a full example script for FedEx international shipments via the Python FedEx wrapper - you can find it here. It should be fairly easy to translate for use in Ruby.

mfcss
  • 1,039
  • 1
  • 9
  • 25