Ups Could not obtain shipping label. Missing or invalid shipper name.
Hey guys, i'm not sure if i'm doing everything properly but every time I try to create shipment i got Runtime Error Could not obtain shipping label. Missing or invalid shipper name.. In order to reproduce this problem:
packages = [
ActiveMerchant::Shipping::Package.new( 100, [93,10]),
ActiveMerchant::Shipping::Package.new( 100, [93,10])
]
origin = ActiveMerchant::Shipping::Location.new( :country => 'US', :state => 'CA', :city => 'Beverly Hills', :zip => '90210', :name => 'random name')
destination = ActiveMerchant::Shipping::Location.new( :country => 'CA', :province => 'ON', :city => 'Ottawa', :postal_code => 'K1P 1J1')
ups = ActiveMerchant::Shipping::UPS.new(:login => 'my-working-login', :password => 'my-working-password', :key => 'my-working-ups-key')
ups.create_shipment(origin, destination, packages)
Am I missing any parameter? Or perhaps creating shippment via UPS is unsupported?
I too ran into issues with this error and after perusing the source I came up with this:
ups = ActiveMerchant::Shipping::UPS.new(:login => 'my-working-login', :password => 'my-working-password', :key => 'my-working-ups-key', :origin_name => 'random name for origin', :origin_account => 'Your UPS Account Number goes here')
Can confirm that @carter's fix works. The real bug here is the error messages not at all describing the problem.
@trishume what do you think about adding more explicit error message which would be shown just before sending data to ups? Something like missing parameter :origin_account?
I would really like to do that, but first I will have to dig to make sure that there aren't any cases where these parameters aren't required.
I don't want to add logic that throws an error when it is missing and break someone's code where they don't use that parameter, but in some situation where that is fine.
Given the current state of things I feel semi-confident that origin_account is required, because you need to pay for the shipment somehow and the only implemented payment source is the "BillShipper" option.
The UPS API does have an option to pass credit card info into the API. So I guess maybe you don't need the origin_account if you're doing that, but seeing as that is not implemented I feel like it would make sense to require origin_account explicitly.
origin_name however shouldn't be required, cause if you search the code you can see that it's only used in 2 situations where some other field is nil.
The logic around origin_name is sad, it just doesn't really make sense, like the way that it just gets stuck in as the name in any location node that doesn't have a name or company_name. It could definitely use a cleanup.
Thanks for the insight @eboswort! In my testing I did find that origin_account is needed in at least some cases or else I get the error from #251. For example the remote tests won't pass without that field.
We should definitely make these error messages more friendly.
If this is not a problem I will try to create a PR fixing this issue tomorrow