forked from JeremyDunn/php-fedex-api-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddress-validation.php
39 lines (30 loc) · 1.7 KB
/
address-validation.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
require_once 'credentials.php';
require_once 'bootstrap.php';
use FedEx\AddressValidationService\Request;
use FedEx\AddressValidationService\ComplexType;
use FedEx\AddressValidationService\SimpleType;
$addressValidationRequest = new ComplexType\AddressValidationRequest();
// User Credentials
$addressValidationRequest->WebAuthenticationDetail->UserCredential->Key = FEDEX_KEY;
$addressValidationRequest->WebAuthenticationDetail->UserCredential->Password = FEDEX_PASSWORD;
// Client Detail
$addressValidationRequest->ClientDetail->AccountNumber = FEDEX_ACCOUNT_NUMBER;
$addressValidationRequest->ClientDetail->MeterNumber = FEDEX_METER_NUMBER;
// Version
$addressValidationRequest->Version->ServiceId = 'aval';
$addressValidationRequest->Version->Major = 4;
$addressValidationRequest->Version->Intermediate = 0;
$addressValidationRequest->Version->Minor = 0;
// Address(es) to validate.
$addressValidationRequest->AddressesToValidate = [new ComplexType\AddressToValidate()]; // just validating 1 address in this example.
$addressValidationRequest->AddressesToValidate[0]->Address->StreetLines = ['12345 Main Street'];
$addressValidationRequest->AddressesToValidate[0]->Address->City = 'Anytown';
$addressValidationRequest->AddressesToValidate[0]->Address->StateOrProvinceCode = 'NY';
$addressValidationRequest->AddressesToValidate[0]->Address->PostalCode = 47711;
$addressValidationRequest->AddressesToValidate[0]->Address->CountryCode = 'US';
$request = new Request();
//$request->getSoapClient()->__setLocation(Request::PRODUCTION_URL);
$request->getSoapClient()->__setLocation(Request::TESTING_URL);
$addressValidationReply = $request->getAddressValidationReply($addressValidationRequest);
var_dump($addressValidationReply);