International USPS for Spree Active Shipping

92 views
Skip to first unread message

Jennifer Maas

unread,
Feb 12, 2010, 5:03:36 PM2/12/10
to Spree
I'm using Active Shipping for Spree, and it returns $0 for
international addresses using the USPS calculators. I'm guessing I
need to create new calculators for USPS International services.

Before I did too deep into the code, I was just wondering if anyone
else has had success with International USPS and if any branches of
Spree Active Shipping exist where this already works. Also if anyone
knows off-hand of any challenges that have prevented someone from
doing this already, that would be great to know. Thanks so much in
advance!

Jennifer

jumph4x

unread,
Feb 12, 2010, 7:31:55 PM2/12/10
to Spree
I think at one point I tried to contribute USPS support to our Active
Shipping extension but I'm not sure if that got accepted or not as I
was just learning github and may have pressed a bunch of wrong buttons
and gotten nowhere.

First suggestion would be to run rails console and create a shipping
quote manually, step by step so you can trace exact output at each
step.

Jennifer Maas

unread,
Feb 18, 2010, 12:55:33 PM2/18/10
to Spree
Thank you

On Feb 12, 4:31 pm, jumph4x <visible....@gmail.com> wrote:
> I think at one point I tried to contributeUSPSsupport to our Active


> Shipping extension but I'm not sure if that got accepted or not as I
> was just learning github and may have pressed a bunch of wrong buttons
> and gotten nowhere.
>
> First suggestion would be to run rails console and create a shipping
> quote manually, step by step so you can trace exact output at each
> step.
>
> On Feb 12, 5:03 pm, Jennifer Maas <jenniferm...@gmail.com> wrote:
>
> > I'm using Active Shipping for Spree, and it returns $0 for

> > international addresses using theUSPScalculators.  I'm guessing I
> > need to create new calculators forUSPSInternational services.


>
> > Before I did too deep into the code, I was just wondering if anyone

> > else has had success with InternationalUSPSand if any branches of

Jennifer Maas

unread,
Feb 24, 2010, 4:17:27 PM2/24/10
to Spree
I figured it out.

The extension basically parses the array from USPS (or whichever
service provider) and then creates a nice hash with all of the
services the service provider offers and the price for each based on
the origin address and the shipping address. It then tries to match
the name of the service to a calculator. If it can't find one, it
just returns 0. This is questionable behavior, but that's another
issue. I was able to see what USPS was sending back when I sent it an
international address by logging the returned hash:

USPS Priority Mail International Flat Rate Envelope: 1345
USPS First-Class Mail International Large Envelope: 1056
USPS USPS GXG Envelopes: 6400
USPS Express Mail International Flat Rate Envelope: 2895
USPS First-Class Mail International Package: 1076
USPS Priority Mail International Medium Flat Rate Box: 4345
USPS Priority Mail International: 2800
USPS Global Express Guaranteed Non-Document Non-Rectangular: 6400
USPS Global Express Guaranteed Non-Document Rectangular: 6400
USPS Priority Mail International Large Flat Rate Box: 5595
USPS Global Express Guaranteed (GXG): 6400
USPS Express Mail International: 3350
USPS Priority Mail International Small Flat Rate Box: 1345

I wanted to do USPS Priority Mail International, so I created a file
called

/vendor/extensions/active_shipping/app/models/usps/
priority_mail_international.rb

class Calculator::Usps::PriorityMailInternational <
Calculator::Usps::Base
def self.description
"USPS Priority Mail International"
end
end


and then added a line to the activate method in
active_shipping_extension.rb

Calculator::Usps::PriorityMailInternational

I'm still having a problem with using UPS and USPS calculators at the
same time in a sale (it only queries UPS and so USPS services don't
match a calculator and return $0), but this first problem is solved.

shahzeb...@gmail.com

unread,
Mar 8, 2017, 6:05:18 AM3/8/17
to Spree
can you please tell hoe you logged the response of the api
Reply all
Reply to author
Forward
0 new messages