public function makePayload(\FS\Components\Order\ShoppingOrder $order)
 {
     $payload = array();
     $settings = $this->getApplicationContext()->getComponent('\\FS\\Components\\Settings');
     $shipment = $order->getFlagShipRaw();
     $service = $order->getShippingService();
     // shipment created
     if ($shipment) {
         $payload['type'] = 'created';
         $payload['shipment'] = $shipment;
         return $payload;
     }
     // quoted but no shipment created
     if (!$shipment && $service['provider'] == $settings['FLAGSHIP_SHIPPING_PLUGIN_ID']) {
         $payload['type'] = 'create';
         $payload['service'] = $service;
         $payload['cod'] = array('currency' => strtoupper(get_woocommerce_currency()));
     }
     // possibly not quoted with FS
     if (!isset($payload['type'])) {
         $payload['type'] = 'unavailable';
     }
     // requotes
     if ($requoteRates = $order->getAttribute('flagship_shipping_requote_rates')) {
         $payload['requote_rates'] = $requoteRates;
     }
     return $payload;
 }
 public function voidPickup(\FS\Components\Order\ShoppingOrder $order)
 {
     $options = $this->getApplicationContext()->getComponent('\\FS\\Components\\Options');
     $client = $this->getApplicationContext()->getComponent('\\FS\\Components\\Http\\Client');
     $notifier = $this->getApplicationContext()->getComponent('\\FS\\Components\\Notifier');
     $shipment = $order->getFlagShipRaw();
     $response = $client->delete('/pickups/' . $shipment['pickup']['id']);
     if (!$response->isSuccessful()) {
         $notifier->warning(sprintf('Unable to void pick-up with FlagShip Pickup ID (%s)', $shipment['pickup']['id']));
         return;
     }
     unset($shipment['pickup']);
     $order->setFlagShipRaw($shipment);
 }