verbb / postie

A Craft Commerce shipping calculator plugin.
Other
12 stars 18 forks source link

DestinationPostalCode is required when AcceptanceDateTime is populated. #38

Closed GaryReckard closed 3 years ago

GaryReckard commented 3 years ago

I was using a Hong Kong address, with no postal code set, and got the following error from USPS api in my postie log:

{
  "Package": {
    "Error": {
      "Number": "-2147219041",
      "Source": ";IntlRateV2.ProcessRequest",
      "Description": "DestinationPostalCode is required when AcceptanceDateTime is populated.",
      "HelpFile": "",
      "HelpContext": ""
    },
    "@attributes": {
      "ID": "2"
    }
  }
}

Perhaps this: https://github.com/verbb/postie/blob/f5a51beb4012a33e3746d74fb70fbd3311d2bc3f/src/providers/USPS.php#L229-L230

should be surrounded by a check for the zip code?

if($order->shippingAddress->zipCode) {
    $package->setField('AcceptanceDateTime', DateTimeHelper::toIso8601(time()));
    $package->setField('DestinationPostalCode', $order->shippingAddress->zipCode);
}
engram-design commented 3 years ago

Wasn't aware of this requirement, updated in 2.2.8

GaryReckard commented 3 years ago

Thanks, Josh!