0

I'm using the Shippo API to try and set my rate/parcel to USPS priority. Per the docs I feel like I need to add/edit the $rate array, but I can't seem to figure it out.

// Select the rate you want to purchase.
// We simply select the first rate in this example.

// $rate = $shipment["rates_list"][0];
$rate = array(
    'object_state'          => 'VALID',
    'provider'              => 'USPS',
    'servicelevel_name'     => 'Priority Mail',
    'servicelevel_token'    => 'usps_priority'
    );

// Purchase the desired rate
$transaction = Shippo_Transaction::create(array(
    'rate'=> $rate["object_id"],
    //'rate' => $rate["usps_priority"],
    'async'=> false
));
Daniel Widdis
  • 8,424
  • 13
  • 41
  • 63
vytfla
  • 549
  • 2
  • 9
  • 29

1 Answers1

2

Looks like our InstaLabel feature is perfect for you https://goshippo.com/shipping-api/instalabel

There is a complete PHP example on that link but here's the bit of code you specified:

$transaction = Shippo_Transaction::create( array(
    'shipment' => $shipment,
    'carrier_account' => 'b741b99f95e841639b54272834bc478c',
    'servicelevel_token' => 'usps_priority',
);
);
  • Thanks. Do I replace everything above with the code you provided, or do I keep `$rate = $shipment["rates_list"][0];` and just swap the `$transaction` array? – vytfla May 05 '16 at 21:59
  • Also the carrier account # you posted is for fedex (from the docs). How would I get one for USPS? – vytfla May 05 '16 at 22:07