This repository has been archived by the owner on Sep 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#30 - added example for international rate
- Loading branch information
1 parent
06480dd
commit 48655be
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<?php | ||
|
||
require_once('../vendor/autoload.php'); | ||
require_once(dirname(dirname(__FILE__)) . '/vendor/autoload.php'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
require_once('autoload.php'); | ||
|
||
use USPS\RatePackage; | ||
|
||
$rate = new \USPS\Rate('xxxx'); | ||
$rate->setInternationalCall(true); | ||
$rate->addExtraOption('Revision', 2); | ||
|
||
$package = new RatePackage; | ||
$package->setPounds(15.12345678); | ||
$package->setOunces(0); | ||
$package->setField('Machinable', 'True'); | ||
$package->setField('MailType', 'Package'); | ||
$package->setField('GXG', array( | ||
'POBoxFlag' => 'Y', | ||
'GiftFlag' => 'Y' | ||
)); | ||
$package->setField('ValueOfContents', 200); | ||
$package->setField('Country', 'Australia'); | ||
$package->setField('Container', 'RECTANGULAR'); | ||
$package->setField('Size', 'LARGE'); | ||
$package->setField('Width', 10); | ||
$package->setField('Length', 15); | ||
$package->setField('Height', 10); | ||
$package->setField('Girth', 0); | ||
$package->setField('OriginZip', 18701); | ||
$package->setField('CommercialFlag', 'N'); | ||
$package->setField('AcceptanceDateTime', '2016-07-05T13:15:00-06:00'); | ||
$package->setField('DestinationPostalCode', '2046'); | ||
|
||
// add the package to the rate stack | ||
$rate->addPackage($package); | ||
// Perform the request and print out the result | ||
print_r($rate->getRate()); | ||
print_r($rate->getArrayResponse()); | ||
// Was the call successful | ||
if ($rate->isSuccess()) { | ||
echo 'Done'; | ||
} else { | ||
echo 'Error: ' . $rate->getErrorMessage(); | ||
} |