示例#1
1
 public function __construct()
 {
     EasyPost::setApiKey(env('EASYPOST'));
     $this->slacker = new SlackHandler();
 }
示例#2
0
 protected function _processShipping()
 {
     // Required Values
     $requiredValues = array('Length', 'Width', 'Height', 'Weight', 'Packer', 'NumTrees', 'ShipName', 'ShipAddress', 'ShipCity', 'ShipState', 'ShipZip', 'Phone');
     // All variables passed
     $request = Request::all();
     // Array of missing fields
     $return['errorFields'] = array();
     foreach ($requiredValues as $val) {
         if (empty($request[$val])) {
             $return['errorFields'][] = $val;
         }
     }
     // IF fields are missing
     if (!empty($return['errorFields'])) {
         return $return;
     }
     // Connect to API
     \EasyPost\EasyPost::setApiKey(config('app.easyPostAPIKey'));
     $toData = array("name" => $request['ShipName'], "street1" => $request['ShipAddress'], "street2" => $request['ShipAddress2'], "city" => $request['ShipCity'], "state" => $request['ShipState'], "zip" => $request['ShipZip'], "phone" => $request['Phone']);
     $toAddress = \EasyPost\Address::create($toData);
     // Build from address object
     $fromData = array("company" => config('app.fromCompany'), "street1" => config('app.fromStreet1'), "city" => config('app.fromCity'), "state" => config('app.fromState'), "zip" => config('app.fromZip'));
     $fromAddress = \EasyPost\Address::create($fromData);
     // Build parcel object
     $parcelData = array("length" => $request['Length'], "width" => $request['Width'], "height" => $request['Height'], "weight" => $request['Weight']);
     $parcel = \EasyPost\Parcel::create($parcelData);
     // Create shipment object
     $shipment = \EasyPost\Shipment::create(array("to_address" => $toAddress, "from_address" => $fromAddress, "parcel" => $parcel));
     return $shipment->lowest_rate();
 }
 /**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot()
 {
     $this->package('mandofever78/laravel-easypost');
     /*
      * Load Stripe configuration
      *
      * API keys should be utilizing Laravel's "dot files" to keep them out of source
      * control and making them easily overridable on dev environments
      *
      * Read more: http://laravel.com/docs/configuration#environment-configuration
      */
     $api_key = isset($_ENV['easypost.api_key']) ? $_ENV['easypost.api_key'] : $this->app['config']->get('laravel-easypost::easypost.api_key');
     \EasyPost\EasyPost::setApiKey($api_key);
 }
 /**
  * @return mixed
  */
 private function _getQuotes()
 {
     $api_key = Mage::helper('core')->decrypt($this->getConfigData('api_key'));
     \EasyPost\EasyPost::setApiKey($api_key);
     $r = $this->_rawRequest;
     $to_address = \EasyPost\Address::create(array("name" => "", "street1" => "", "street2" => "", "city" => $r->getOrigCountry(), "state" => $r->getOrigRegionCode(), "zip" => $r->getOrigPostal(), "phone" => "", "country" => $r->getOrigCountry()));
     $from_address = \EasyPost\Address::create(array("company" => "", "street1" => "", "city" => "", "state" => $r->getDestRegionCode(), "zip" => $r->getDestPostal(), "phone" => '', "country" => $r->getDestCountry()));
     $parcel = \EasyPost\Parcel::create(array("weight" => $r->getWeight()));
     $shipment = $this->_createShipment($to_address, $from_address, $parcel);
     try {
         if (self::ONLY_LOWEST_RATE == $this->getConfigData('only_lowest_option')) {
             $rates = $shipment->lowest_rate();
             return $this->_paserSingleResponse($rates);
         } else {
             $rates = $shipment->rates;
             return $this->_paserMutiResponse($rates);
         }
     } catch (Exception $e) {
         return null;
     }
 }
示例#5
0
 public function template_admin($template_name, $vars = array(), $return = FALSE)
 {
     define("BASE_URL", base_url());
     define("RES_URL", base_url() . "dhl_asset/");
     $router =& load_class('Router', 'core');
     $CI =& get_instance();
     \EasyPost\EasyPost::setApiKey('MA4XauyRM4TW3UOkSWHXmQ');
     $vars['admin_info'] = $CI->session->userdata('admin_info');
     $vars['current_page'] = $router->fetch_class();
     $vars['current_action'] = $router->fetch_method();
     if ($return) {
         $content = $this->view('admin/header', $vars, $return);
         $content = $this->view('nav', $vars, $return);
         $content .= $this->view($template_name, $vars, $return);
         $content .= $this->view('admin/footer', $vars, $return);
         return $content;
     } else {
         $this->view('admin/header', $vars);
         $this->view('nav', $vars);
         $this->view($template_name, $vars);
         $this->view('admin/footer', $vars);
     }
 }
示例#6
0
<?php

require_once "../vendor/autoload.php";
\EasyPost\EasyPost::setApiKey('cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi');
// Parcel: create
$params = array("length" => 20.2, "width" => 10.9, "height" => 5, "weight" => 14.8);
$parcel = \EasyPost\Parcel::create($params);
$params = array("predefined_package" => 'SmallFlatRateBox', "weight" => 38.1);
$parcel = \EasyPost\Parcel::create($params);
// retrieve
$retrieved = \EasyPost\Parcel::retrieve($parcel->id);
print_r($retrieved);
// all
$all = \EasyPost\Parcel::all();
//print_r($all);
/*
for($i = 0, $k = count($all); $i < $k; $i++) {
  print_r(\EasyPost\Parcel::retrieve($all[$i]->id));
}
*/
          <div class="inner-box category-content">
            <h2 class="title-2 uppercase"><strong> <i class="icon-docs"></i> Shipping Label</strong> </h2>
            <div class="row">
              <div class="col-sm-12">
			  
			 
			  
			  
			  
			  
			  
			  
			  
			  <?php 
require_once 'includes/plugins/easypost-php-master/lib/easypost.php';
\EasyPost\EasyPost::setApiKey('kZvkSRX4nEqTN3ju6ybPmg');
$shipping_rate = $_POST['shipping_rate'];
$shipment_id = $_POST['shipment_id'];
$shipment = \EasyPost\Shipment::retrieve($shipment_id);
$shipment->buy(array('rate' => array('id' => $shipping_rate)));
$shipment->label(array('file_format' => 'pdf'));
?>
<div class="row">
<div class="col-xs-12 col-md-6">
 <p>Print your shipping label.</p>
<h2>Tracking Code</h2>
<p><?php 
echo $shipment->tracking_code;
?>
</p>
</br>
 /**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot()
 {
     \EasyPost\EasyPost::setApiKey(env('EASYPOST_API_KEY'));
 }
示例#9
0
 /**
  * constructor
  */
 public function __construct()
 {
     //set easypost api key
     EasyPost::setApiKey(config('shipping.api_key'));
 }
示例#10
0
<?php

require_once "../lib/easypost.php";
\EasyPost\EasyPost::setApiKey('PROD_MODE_KEY');
define("ECHO_ME", true);
define("CREATE_CHILD", false);
define("GET_CHILD", false);
define("EDIT_ME", false);
define("EDIT_CHILD", false);
// Retrieve your user record
if (ECHO_ME) {
    $me = \EasyPost\User::retrieve_me();
    print_r($me);
}
// Create a new child account. Children are used to logically group transactions
// and settings (such as carrier accounts) where all payments flow through the
// parent account. They should not be used in situations where you intend for
// an end user to log into the child account.
if (CREATE_CHILD) {
    try {
        $new_child = \EasyPost\User::create();
        $child_keys = $new_child->api_keys();
        // SAVE CHILD_KEYS TO MAKE REQUESTS AS THE CHILD ACCOUNT LATER
        print_r($new_child);
    } catch (Exception $e) {
        $e->prettyPrint();
    }
}
if (GET_CHILD) {
    $me = \EasyPost\User::retrieve_me();
    $child = \EasyPost\User::retrieve($me->children[0]->id);
示例#11
0
 /**
  * @param string $apiKey
  * @param OrderAddressDTO $fromAddress
  */
 public function __construct($apiKey, OrderAddressDTO $fromAddress)
 {
     $this->fromAddress = $fromAddress;
     EasyPost\EasyPost::setApiKey($apiKey);
 }
示例#12
0
<?php

require_once "../lib/easypost.php";
\EasyPost\EasyPost::setApiKey('cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi');
\EasyPost\EasyPost::setApiBase('http://*****:*****@example.com");
$order = \EasyPost\Order::create(array("from_address" => $sf, "to_address" => $maryland, "shipments" => array(array("parcel" => array("length" => 12.0, "width" => 10.5, "height" => 6.8, "weight" => 12), "options" => array("cod_amount" => 14.99)), array("parcel" => array("length" => 11.9, "width" => 10.0, "height" => 7.3, "weight" => 18), "options" => array("cod_amount" => 9.56)))));
$order->buy(array("carrier" => "UPS", "service" => "Ground"));
print_r($order);
示例#13
0
 public function __construct()
 {
     \EasyPost\EasyPost::setApiKey('MA4XauyRM4TW3UOkSWHXmQ');
 }