예제 #1
0
use Distantia\CanadaPostWs\Type\Shipment\SenderType;
use Distantia\CanadaPostWs\Type\Shipment\SettlementInfoType;
use Distantia\CanadaPostWs\Type\Shipment\ShipmentInfoType;
use Distantia\CanadaPostWs\Type\Shipment\ShipmentType;
use Distantia\CanadaPostWs\WebService;
require_once __DIR__ . '/../../vendor/autoload.php';
// Config
define('CANADA_POST_API_CUSTOMER_NUMBER', '2004381');
define('CANADA_POST_API_CONTRACT_ID', '42708517');
define('CANADA_POST_API_KEY', '6e93d53968881714:0bfa9fcb9853d1f51ee57a');
// Shipment object to create
$Shipment = new ShipmentType();
$Shipment->setGroupId('4326432');
$Shipment->setRequestedShippingPoint('H2B1A0');
$Shipment->setCpcPickupIndicator(true);
$Shipment->setExpectedMailingDate(new \DateTime('2016-10-24'));
$DeliverySpec = new DeliverySpecType();
$DeliverySpec->setServiceCode(WebService::$serviceCodes[WebService::SHIPPING_CODE_DOMESTIC_EXPEDITED]);
$Sender = new SenderType();
$Sender->setName('Bulma');
$Sender->setCompany('Capsule Corp.');
$Sender->setContactPhone('1 (514) 820 5879');
$AddressDetails = new AddressDetailsType();
$AddressDetails->setAddressLine1('502 MAIN ST N');
$AddressDetails->setCity('Montréal');
$AddressDetails->setProvState('QC');
$AddressDetails->setCountryCode('CA');
$AddressDetails->setPostalZipCode('H2B1A0');
$Sender->setAddressDetails($AddressDetails);
$DeliverySpec->setSender($Sender);
$Destination = new DestinationType();