Coder Social home page Coder Social logo

php-fedex-api-wrapper's Introduction

PHP FedEx API Wrapper

Latest Stable Version Total Downloads

This library provides a fluid interface for constructing requests to the FedEx web service API.

General Information

All of the code under the FedEx namespace is generated using the generate-classes-from-wsdls.php script. Each web service has it's own class namespace. See the official FedEx web service API documentation for a description of these services.

Installation

composer require jeremy-dunn/php-fedex-api-wrapper

Using the library

The easiest way to get started constructing a web service request is to create an new Request object for the particular service you wish to use and then work backward by injecting the objects necessary to complete the request.

For example if we wish to get shipping rates, we'll create a new instance of FedEx\RateService\Request and call the getGetRatesReply() method. This method requires an instance of FedEx\RateService\ComplexType\RateRequest which itself requires instances of FedEx\RateService\ComplexType\RequestedShipment, FedEx\RateService\ComplexType\TransactionDetail, FedEx\RateService\ComplexType\WebAuthenticationDetail, FedEx\RateService\ComplexType\ClientDetail, and so on. See below for an example.

Rate Service request example

This assumes the FEDEX_KEY, FEDEX_PASSWORD, FEDEX_ACCOUNT_NUMBER, and FEDEX_METER_NUMBER are previously defined in your application. Also note that by default, the library will use the beta/testing server (wsbeta.fedex.com). To use the production server (ws.fedex.com), set the location on the \SoapClient returned from the Request. See below for an example of how to do this.

use FedEx\RateService\Request;
use FedEx\RateService\ComplexType;
use FedEx\RateService\SimpleType;

$rateRequest = new ComplexType\RateRequest();

//authentication & client details
$rateRequest->WebAuthenticationDetail->UserCredential->Key = FEDEX_KEY;
$rateRequest->WebAuthenticationDetail->UserCredential->Password = FEDEX_PASSWORD;
$rateRequest->ClientDetail->AccountNumber = FEDEX_ACCOUNT_NUMBER;
$rateRequest->ClientDetail->MeterNumber = FEDEX_METER_NUMBER;

$rateRequest->TransactionDetail->CustomerTransactionId = 'testing rate service request';

//version
$rateRequest->Version->ServiceId = 'crs';
$rateRequest->Version->Major = 24;
$rateRequest->Version->Minor = 0;
$rateRequest->Version->Intermediate = 0;

$rateRequest->ReturnTransitAndCommit = true;

//shipper
$rateRequest->RequestedShipment->PreferredCurrency = 'USD';
$rateRequest->RequestedShipment->Shipper->Address->StreetLines = ['10 Fed Ex Pkwy'];
$rateRequest->RequestedShipment->Shipper->Address->City = 'Memphis';
$rateRequest->RequestedShipment->Shipper->Address->StateOrProvinceCode = 'TN';
$rateRequest->RequestedShipment->Shipper->Address->PostalCode = 38115;
$rateRequest->RequestedShipment->Shipper->Address->CountryCode = 'US';

//recipient
$rateRequest->RequestedShipment->Recipient->Address->StreetLines = ['13450 Farmcrest Ct'];
$rateRequest->RequestedShipment->Recipient->Address->City = 'Herndon';
$rateRequest->RequestedShipment->Recipient->Address->StateOrProvinceCode = 'VA';
$rateRequest->RequestedShipment->Recipient->Address->PostalCode = 20171;
$rateRequest->RequestedShipment->Recipient->Address->CountryCode = 'US';

//shipping charges payment
$rateRequest->RequestedShipment->ShippingChargesPayment->PaymentType = SimpleType\PaymentType::_SENDER;

//rate request types
$rateRequest->RequestedShipment->RateRequestTypes = [SimpleType\RateRequestType::_PREFERRED, SimpleType\RateRequestType::_LIST];

$rateRequest->RequestedShipment->PackageCount = 2;

//create package line items
$rateRequest->RequestedShipment->RequestedPackageLineItems = [new ComplexType\RequestedPackageLineItem(), new ComplexType\RequestedPackageLineItem()];

//package 1
$rateRequest->RequestedShipment->RequestedPackageLineItems[0]->Weight->Value = 2;
$rateRequest->RequestedShipment->RequestedPackageLineItems[0]->Weight->Units = SimpleType\WeightUnits::_LB;
$rateRequest->RequestedShipment->RequestedPackageLineItems[0]->Dimensions->Length = 10;
$rateRequest->RequestedShipment->RequestedPackageLineItems[0]->Dimensions->Width = 10;
$rateRequest->RequestedShipment->RequestedPackageLineItems[0]->Dimensions->Height = 3;
$rateRequest->RequestedShipment->RequestedPackageLineItems[0]->Dimensions->Units = SimpleType\LinearUnits::_IN;
$rateRequest->RequestedShipment->RequestedPackageLineItems[0]->GroupPackageCount = 1;

//package 2
$rateRequest->RequestedShipment->RequestedPackageLineItems[1]->Weight->Value = 5;
$rateRequest->RequestedShipment->RequestedPackageLineItems[1]->Weight->Units = SimpleType\WeightUnits::_LB;
$rateRequest->RequestedShipment->RequestedPackageLineItems[1]->Dimensions->Length = 20;
$rateRequest->RequestedShipment->RequestedPackageLineItems[1]->Dimensions->Width = 20;
$rateRequest->RequestedShipment->RequestedPackageLineItems[1]->Dimensions->Height = 10;
$rateRequest->RequestedShipment->RequestedPackageLineItems[1]->Dimensions->Units = SimpleType\LinearUnits::_IN;
$rateRequest->RequestedShipment->RequestedPackageLineItems[1]->GroupPackageCount = 1;

$rateServiceRequest = new Request();
//$rateServiceRequest->getSoapClient()->__setLocation(Request::PRODUCTION_URL); //use production URL

$rateReply = $rateServiceRequest->getGetRatesReply($rateRequest); // send true as the 2nd argument to return the SoapClient's stdClass response.


if (!empty($rateReply->RateReplyDetails)) {
    foreach ($rateReply->RateReplyDetails as $rateReplyDetail) {
        var_dump($rateReplyDetail->ServiceType);
        if (!empty($rateReplyDetail->RatedShipmentDetails)) {
            foreach ($rateReplyDetail->RatedShipmentDetails as $ratedShipmentDetail) {
                var_dump($ratedShipmentDetail->ShipmentRateDetail->RateType . ": " . $ratedShipmentDetail->ShipmentRateDetail->TotalNetCharge->Amount);
            }
        }
        echo "<hr />";
    }
}

var_dump($rateReply);

More examples can be found in the examples folder.

php-fedex-api-wrapper's People

Contributors

aegirleet avatar ajohnson6494 avatar alexankit avatar arseniyshestakov avatar bilalyilmax avatar codacy-badger avatar colinodell avatar destronom avatar glendemon avatar jeremydunn avatar mixislv avatar runningrandall avatar shrimpwagon avatar stef686 avatar tomashe avatar umpirsky avatar vladreshet avatar wow-apps avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-fedex-api-wrapper's Issues

Update all WSDL files and regenerate code

https://www.fedex.com/us/developer/web-services/process.html?tab=tab1#app-tab2

Standard Services:

  • ValidationAndCommitmentService (v8)
  • TrackService (v14)
  • RateService (v22)
  • LocationsService (v7)
  • CountryService (v6)

Advanced Services:

  • AddressValidationService (v4)
  • CloseService (v5)
  • DGDS - Upload Dangerous Goods Commodities Data (v3)
  • DGLD - Retrieve Dangerous Goods Shipments (v1)
  • InFlightShipmentService (v1)
  • OpenShipService (v11)
  • PickupService (v15)
  • ShipService (v21)
  • UploadDocumentService (v11)
  • ASYNC Transaction Service (v4)

Array config

Hello,

in the latest version I'm not able to config request with array as I did previously:

$raterequest = new RateRequest([
            'WebAuthenticationDetail' => new WebAuthenticationDetail([
                'UserCredential'    => new WebAuthenticationCredential([
                    'Key'      => '***',
                    'Password' => '***',
                ])
            ]),
...
]);

new syntax expects I'll be doing something like this:

$userCredential
    ->setKey(FEDEX_KEY)
    ->setPassword(FEDEX_PASSWORD);

Can you please return ability to config with arrays or say me what I'm doing wrong now?

Under 1LB Smartpost

Hello,
How do you submit a shipment for SmartPost under 1LB?

Current receive this error: "Error occurred while processing FDX package.: Reason Package 1 - YOUR_PACKAGING cannot exceed the limit of 0.99 LB.

Weight is set to .5 with LB UOM

Thanks!

When request Create Shipment error SoapFault fault

public function getCreatePendingShipmentReply(ComplexType\CreatePendingShipmentRequest $createPendingShipmentRequest)
    {
        return $this->getSoapClient()->createPendingShipment($createPendingShipmentRequest->toArray());
    }

AddressValidationResult is null

I don't know if this is an issue or user error. Feels more like user error...

I always get a NULL in AddressValidationResult returned data from FedEx.

Maybe there is an Option I am not setting, I did set "->setReturnParsedElements(true)" thinking that would help, but that did not seem to do anything.

This is what I get back:

AddressValidationReply::__set_state(array(
'name' => 'AddressValidationReply',
'values' =>
array (
'HighestSeverity' => 'SUCCESS',
'Notifications' =>
array (
0 =>
Notification::__set_state(array(
'name' => 'Notification',
'values' =>
array (
'Severity' => 'SUCCESS',
'Source' => 'wsi',
'Code' => '0',
'Message' => 'Success',
),
)),
),
'TransactionDetail' =>
TransactionDetail::__set_state(array(
'name' => 'TransactionDetail',
'values' =>
array (
'CustomerTransactionId' => 'Drop Ship PHP version 4',
),
)),
'Version' =>
VersionId::__set_state(array(
'name' => 'VersionId',
'values' =>
array (
'ServiceId' => 'aval',
'Major' => 4,
'Intermediate' => 0,
'Minor' => 0,
),
)),
'ReplyTimestamp' => '2017-10-10T14:31:54-05:00',
'AddressResults' =>
array (
0 =>
AddressValidationResult::__set_state(array(
'name' => 'AddressValidationResult',
'values' => NULL,
)),
),
),
))

I need to get back Score, and corrected address values.

Hope this is the proper place to put this.

Sending a single product

How do I send a single package?

        $rateRequest->RequestedShipment->PackageCount = 1;

        //create package line items
        $rateRequest->RequestedShipment->RequestedPackageLineItems = [new ComplexType\RequestedPackageLineItem(), new ComplexType\RequestedPackageLineItem()];

        //package 1
        $rateRequest->RequestedShipment->RequestedPackageLineItems[0]->Weight->Value = 2;
        $rateRequest->RequestedShipment->RequestedPackageLineItems[0]->Weight->Units = SimpleType\WeightUnits::_KG;
        $rateRequest->RequestedShipment->RequestedPackageLineItems[0]->Dimensions->Length = 10;
        $rateRequest->RequestedShipment->RequestedPackageLineItems[0]->Dimensions->Width = 10;
        $rateRequest->RequestedShipment->RequestedPackageLineItems[0]->Dimensions->Height = 3;
        $rateRequest->RequestedShipment->RequestedPackageLineItems[0]->Dimensions->Units = SimpleType\LinearUnits::_IN;
        $rateRequest->RequestedShipment->RequestedPackageLineItems[0]->GroupPackageCount = 1;

I have the following code and the following error comes out:

 [HighestSeverity] => ERROR
    [Notifications] => stdClass Object
        (
            [Severity] => ERROR
            [Source] => crs
            [Code] => 300
            [Message] => Package 1 - Group package count must be at least a value of 1.
            [LocalizedMessage] => Package 1 - Group package count must be at least a value of 1.
            [MessageParameters] => stdClass Object
                (
                    [Id] => PACKAGE_INDEX
                    [Value] => 1
                )

No RateReplyDetails in response

Hello,
I have updated the file with correct credentials and also getting success response i am unable to get shipping rate details please guide me in this,
image

Attached is the image

How to solve "Invalid language code for event notification 1" ?

I'm trying to add a special service for Fedex API as an email notification . I go through the classes in the wrapper but i face to "Invalid language code for event notification 1" error code . here's my code :

$localization  = new ComplexType\Localization();
$localization->setLocaleCode("CA")->setLanguageCode("EN");

$emailNotif = SimpleType\ShipmentSpecialServiceType::_EMAIL_NOTIFICATION;
$emailRecip = new ComplexType\EMailNotificationRecipient();
$emailRecip->setEMailNotificationRecipientType(SimpleType\EMailNotificationRecipientType::_SHIPPER)
           ->setEMailAddress($to['email'])
           ->setLocalization($localization)
           ->setFormat(SimpleType\EMailNotificationFormatType::_TEXT)
           ->setNotificationEventsRequested([SimpleType\EMailNotificationEventType::_ON_SHIPMENT,SimpleType\EMailNotificationEventType::_ON_DELIVERY]);
$emailNotifDet = new ComplexType\EMailNotificationDetail();
$emailNotifDet->setAggregationType(SimpleType\EMailNotificationAggregationType::_PER_SHIPMENT)
              ->setPersonalMessage($emailNotifCont['PersonalMessage'])
              ->setRecipients([$emailRecip]);
$specialServicesRequested = new ComplexType\ShipmentSpecialServicesRequested();
 $specialServicesRequested->setSpecialServiceTypes([$emailNotif])->setEMailNotificationDetail($emailNotifDet);
$requestedShipment->setSpecialServicesRequested($specialServicesRequested);

But i think localization part doesn't apply to the final codes at All. Any idea would be appreciable .

PHP Fatal error: Uncaught SoapFault exception

Hello,
I'm getting PHP Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Server] Fault in /vendor/jeremy-dunn/php-fedex-api-wrapper/src/FedEx/UploadDocumentService/Request.php:29 when trying to Upload document to Fedex.

I'm doing $this->reply = $this->request->getUploadDocumentsReply($this->upload_request);, the content of $this->upload_request is bellow. Am I missing something?

Thanks!

object(FedEx\UploadDocumentService\ComplexType\UploadDocumentsRequest)#18009 (2) {
  ["name":protected]=>
  string(22) "UploadDocumentsRequest"
  ["values":protected]=>
  array(8) {
    ["WebAuthenticationDetail"]=>
    object(FedEx\UploadDocumentService\ComplexType\WebAuthenticationDetail)#19210 (2) {
      ["name":protected]=>
      string(23) "WebAuthenticationDetail"
      ["values":protected]=>
      array(1) {
        ["UserCredential"]=>
        object(FedEx\UploadDocumentService\ComplexType\WebAuthenticationCredential)#18940 (2) {
          ["name":protected]=>
          string(27) "WebAuthenticationCredential"
          ["values":protected]=>
          array(2) {
            ["Key"]=>
            string(16) "mykey"
            ["Password"]=>
            string(25) "mypass"
          }
        }
      }
    }
    ["ClientDetail"]=>
    object(FedEx\UploadDocumentService\ComplexType\ClientDetail)#18939 (2) {
      ["name":protected]=>
      string(12) "ClientDetail"
      ["values":protected]=>
      array(2) {
        ["AccountNumber"]=>
        string(9) "123456"
        ["MeterNumber"]=>
        string(9) "123456"
      }
    }
    ["TransactionDetail"]=>
    object(FedEx\UploadDocumentService\ComplexType\TransactionDetail)#19211 (2) {
      ["name":protected]=>
      string(17) "TransactionDetail"
      ["values":protected]=>
      array(1) {
        ["CustomerTransactionId"]=>
        string(28) "Testing Rate Service request"
      }
    }
    ["Version"]=>
    object(FedEx\UploadDocumentService\ComplexType\VersionId)#18937 (2) {
      ["name":protected]=>
      string(9) "VersionId"
      ["values":protected]=>
      array(4) {
        ["ServiceId"]=>
        string(4) "cdus"
        ["Major"]=>
        int(11)
        ["Minor"]=>
        int(0)
        ["Intermediate"]=>
        int(0)
      }
    }
    ["OriginCountryCode"]=>
    string(2) "CZ"
    ["DestinationCountryCode"]=>
    string(2) "US"
    ["Usage"]=>
    array(1) {
      [0]=>
      string(26) "ELECTRONIC_TRADE_DOCUMENTS"
    }
    ["Documents"]=>
    array(1) {
      [0]=>
      object(FedEx\UploadDocumentService\ComplexType\UploadDocumentDetail)#18938 (2) {
        ["name":protected]=>
        string(20) "UploadDocumentDetail"
        ["values":protected]=>
        array(4) {
          ["LineNumber"]=>
          int(1)
          ["DocumentType"]=>
          string(18) "COMMERCIAL_INVOICE"
          ["FileName"]=>
          string(5) "5.pdf"
          ["DocumentContent"]=>
          string(53) "/var/www/html/assets/plugins/woo-fedex/includes/5.pdf"
        }
      }
    }
  }
}

Generate bar codes after creating shipment

Hi,

Thank you for creating a beautiful php wrapper for fedex. I was so happy to see this. One question I have is that how I can generate a label with bar codes after creating a new shipment.

Thanks in advance,

Ryan

PNG Label

I'm having trouble retrieving a label as a PNG. PDF and ZPLII work fine but the response is blank when I use PNG.

I'm using the example in:
https://github.com/JeremyDunn/php-fedex-api-wrapper/blob/master/examples/ship.php#L75

<?php
$labelSpecification = new ComplexType\LabelSpecification();
$labelSpecification
    ->setLabelStockType(new SimpleType\LabelStockType(SimpleType\LabelStockType::_PAPER_4X6))
    ->setImageType(new SimpleType\ShippingDocumentImageType(SimpleType\ShippingDocumentImageType::_PNG))
    ->setLabelFormatType(new SimpleType\LabelFormatType(SimpleType\LabelFormatType::_COMMON2D));

Soap Error

Anyone have any thoughts on why I keep getting this?

Error: [SoapFault] SOAP-ERROR: Encoding: Element 'Major' has fixed value '2' (value '4' is not allowed)

I am not 100% on what to do to fix it.

Brian

Lincense

Hello, under what license are you distributing your fedex code? i am working on a GPLv2 extension and i would be glad to use your code for address validation. Any library included inside my extension should be GPL compatible as well (MIT, GPL..)

Thank you, best regards, Stan

Not getting the autoload.php

Hello Jeremy,

It seems a wonderful wrapper but unfortunately didn't overcome the Bootstrap errors as not found the autoload.php.

Working environment Php > 5.3 and ilance architecture

Kindly update to figure out from this situation

Thanks
Mohinder Singh

ReturnTags question

Sorry, got ahead of myself, I think fedex might not allow Return Tags testing in fedex test mode, I'll wait for fedex to get back to me on that so I don't waste anyone's time....

Fedex envelope packaging type example

Hi,

I am having some issue while selecting Packaging Type as "Envelop". Its giving an error "There are no valid services available". Can you please provide me an example for the same so that I can get to know how to use it?

Thanks.

Set Variable options

I am trying to assign variable options in rate request object:

$rateRequest->setVariableOptions( ['SaturdayPickup' => true] );

But it gives me this error: Fatal error:
Uncaught SoapFault exception: [SOAP-ENV:Server] Fault in /fedex-api/vendor/jeremy-dunn/php-fedex-api-wrapper/src/FedEx/RateService/Request.php:29 Stack trace: #0 /fedex-api/vendor/jeremy-dunn/php-fedex-api-wrapper/src/FedEx/RateService/Request.php(29): SoapClient->__call('getRates', Array) #1 /fedex-api/mjs.php(108): FedEx\RateService\Request->getGetRatesReply(Object(FedEx\RateService\ComplexType\RateRequest)) #2 {main} thrown in /fedex-api/vendor/jeremy-dunn/php-fedex-api-wrapper/src/FedEx/RateService/Request.php on line 29

Please help how to set special services from this source: http://freegento.com/doc/d0/d44/_fedex_8php-source.html Line 00297.

How to resolve - Error::Customs Clearance Detail is required

Hi,
I am from India and trying to use your fedex api service class - ShipService\Request()
But facing error like ::

[Severity] => ERROR
[Source] => ship
[Code] => 2449
[Message] => Customs Clearance Detail is required
[LocalizedMessage] => Customs Clearance Detail is required

I am trying to generate shipment for local indian address with following parameters:

DropoffType::_REGULAR_PICKUP
ServiceType::_STANDARD_OVERNIGHT
PackagingType::_YOUR_PACKAGING
RateRequestType::_ACCOUNT

I am not sure what extra setting i need to make in class code to overcome this error.
Would you please guide me.

Thanks & Regards

API with Proxy

Greetings.. Im having a bit of an issue. I have to install the API behind a proxy. I have setup the proxy by modifying the code but it appears not to be working as it times out on the gateway. Has anyone used this API behind a proxy? If so, can you cite the code changes made to make it work?

how to get pdf label after ship.php

hello,
i have tested with example/ship.php if i output the result, the object is protected...
how can i output the label?

`[Label] => FedEx\ShipService\ComplexType\ShippingDocument Object
(
[name:protected] => ShippingDocument
[values:protected] => Array
(
[Type] => OUTBOUND_LABEL
[ShippingDocumentDisposition] => RETURNED
[ImageType] => PDF
[Resolution] => 200
[CopiesToPrint] => 1
[Parts] => Array
(
[0] => FedEx\ShipService\ComplexType\ShippingDocumentPart Object
(
[name:protected] => ShippingDocumentPart
[values:protected] => Array
(
[DocumentPartSequenceNumber] => 1
[Image] => %PDF-1.4
1 0 obj
<<
/Type /Catalog
/Pages 3 0 R

endobj
2 0 obj
<<
/Type /Outlines
/Count 0

endobj
3 0 obj
<<
/Type /Pages
/Count 4
/Kids [18 0 R 19 0 R 20 0 R 21 0 R]

endobj
4 0 obj
[/PDF /Text /ImageB /ImageC /ImageI]
endobj
5 0 obj
<<
/Type /Font......`

Authentication Failed

Hello
I'm trying to rate parcels using this example https://github.com/JeremyDunn/php-fedex-api-wrapper/blob/master/examples/rate-service-request.php
I'm using test credentials I got from FedEx + account password for FEDEX_PASSWORD constant
The resulting response object looks like

public HighestSeverity -> string(5) "ERROR"
public Notifications -> stdClass(4)
public Severity -> string(5) "ERROR"
public Source -> string(4) "prof"
public Code -> string(4) "1000"
public Message -> string(21) "Authentication Failed"
public TransactionDetail -> stdClass(1)
public CustomerTransactionId -> string(28) "Testing Rate Service request"
public Version -> stdClass(4)
public ServiceId -> string(3) "crs"
public Major -> integer10
public Intermediate -> integer0
public Minor -> integer0

Any ideas how to fix it please? Do I need to set manually a particular test url via

$rateServiceRequest->getSoapClient()->__setLocation('https://wsbeta.fedex.com:443/web-services');

or test mode is enabled by default?

Shipping services for Testing.

I would just like to know which shipping services example can be used for testing the api.

For example can I use the ship,php or the create-pending-shipment or cancel-pending-shipment examples for fedex beta testing?

how to create test shipment request

Hi,
how to create test shipment request in fexed.
i mean how to pass beta envirentment variable in our shipmet request, because i have authentication fail error and right now i use test FEDEX_API_KEY, FEDEX_API_PASSWORD, FEDEX_ACCOUNT_NO, FEDEX_METER_NO for create shipment request but it show me authentication fail error

Here My Code

            $userCredential = new \FedEx\ShipService\ComplexType\WebAuthenticationCredential();
	$userCredential
	    ->setKey(config('fedex.key'))
	    ->setPassword(config('fedex.password'));
	$webAuthenticationDetail = new \FedEx\ShipService\ComplexType\WebAuthenticationDetail();
	$webAuthenticationDetail->setUserCredential($userCredential);

	$clientDetail = new \FedEx\ShipService\ComplexType\ClientDetail();
	$clientDetail
	    ->setAccountNumber(config('fedex.account'))
	    ->setMeterNumber(config('fedex.meter'));

	$version = new \FedEx\ShipService\ComplexType\VersionId();
	$version
	    ->setMajor(12)
	    ->setIntermediate(1)
	    ->setMinor(0)
	    ->setServiceId('ship');

	$shipperAddress = new \FedEx\ShipService\ComplexType\Address();
	$shipperAddress
	    ->setStreetLines(array(
	        '12345 Main Street',
	        'STE 810'
	    ))
	    ->setCity('Anytown')
	    ->setStateOrProvinceCode('NY')
	    ->setPostalCode('12345')
	    ->setCountryCode('US');

	$shipperContact = new \FedEx\ShipService\ComplexType\Contact();
	$shipperContact
	    ->setCompanyName('Company Name')
	    ->setEMailAddress('[email protected]')
	    ->setPersonName('Person Name')
	    ->setPhoneNumber(('123-123-1234'));

	$shipper = new \FedEx\ShipService\ComplexType\Party();
	$shipper
	    ->setAccountNumber(config('fedex.account'))
	    ->setAddress($shipperAddress)
	    ->setContact($shipperContact);

	$recipientAddress = new \FedEx\ShipService\ComplexType\Address();
	$recipientAddress
	    ->setStreetLines(array('54312 1st Ave'))
	    ->setCity('Anytown')
	    ->setStateOrProvinceCode('NY')
	    ->setPostalCode('12345')
	    ->setCountryCode('US');

	$recipientContact = new \FedEx\ShipService\ComplexType\Contact();
	$recipientContact
	    ->setPersonName('Contact Name');

	$recipient = new \FedEx\ShipService\ComplexType\Party();
	$recipient
	    ->setAddress($recipientAddress)
	    ->setContact($recipientContact);

	$labelSpecification = new \FedEx\ShipService\ComplexType\LabelSpecification();
	$labelSpecification
	    ->setLabelStockType(new \FedEx\ShipService\SimpleType\LabelStockType(\FedEx\ShipService\SimpleType\LabelStockType::_PAPER_7X4point75))
	    ->setImageType(new \FedEx\ShipService\SimpleType\ShippingDocumentImageType(\FedEx\ShipService\SimpleType\ShippingDocumentImageType::_PDF))
	    ->setLabelFormatType(new \FedEx\ShipService\SimpleType\LabelFormatType(\FedEx\ShipService\SimpleType\LabelFormatType::_COMMON2D));


	$requestedShipment = new \FedEx\ShipService\ComplexType\RequestedShipment();
	$requestedShipment->setShipTimestamp(date('c'));
	$requestedShipment->setDropoffType(new \FedEx\ShipService\SimpleType\DropoffType(\FedEx\ShipService\SimpleType\DropoffType::_REGULAR_PICKUP));
	$requestedShipment->setServiceType(new \FedEx\ShipService\SimpleType\ServiceType(\FedEx\ShipService\SimpleType\ServiceType::_FEDEX_GROUND));
	$requestedShipment->setPackagingType(new \FedEx\ShipService\SimpleType\PackagingType(\FedEx\ShipService\SimpleType\PackagingType::_YOUR_PACKAGING));
	$requestedShipment->setShipper($shipper);
	$requestedShipment->setRecipient($recipient);
	$requestedShipment->setLabelSpecification($labelSpecification);
	$requestedShipment->setRateRequestTypes(array(new \FedEx\ShipService\SimpleType\RateRequestType(\FedEx\ShipService\SimpleType\RateRequestType::_ACCOUNT)));
	$requestedShipment->setPackageCount(1);




	$createPendingShipmentRequest = new \FedEx\ShipService\ComplexType\CreatePendingShipmentRequest();
	// dd($webAuthenticationDetail::_NAME);
	$createPendingShipmentRequest->setWebAuthenticationDetail($webAuthenticationDetail);
	$createPendingShipmentRequest->setClientDetail($clientDetail);
	$createPendingShipmentRequest->setVersion($version);
	$createPendingShipmentRequest->setRequestedShipment($requestedShipment);
	// dd($createPendingShipmentRequest);




	$shipService = new \FedEx\ShipService\Request();
	$shipService->getSoapClient()->__setLocation('https://ws.fedex.com:443/web-services/ship');
	$result = $shipService->getCreatePendingShipmentReply($createPendingShipmentRequest);
	dd($result);

Please help me

How to retrieve the created open shipment to generate labels

Hi,

I have implemented the 'create open shipment' as we require to create a new shipment. After the shipment is created, in the event that users cannot get the label, how do I retrieve the shipment in order to generate label again?

Thanks,
Ryan

Accessing Fedex

Hello Jeremy,

I've downloaded your fedex api package, really well done. Thanks. I have two questions, I hope you can help:

  1. I was able yesterday to test making a test ship order and making a test rate request using your examples. Lovely. I need to pull this together to get data from my webhook in another app to get the fedex order creation data (which I've done before, so that part is easy), and I can see how to create a 'regular' fedex order. I can see that part of the api can also create 'return' or 'call tag' orders. Do you have an example of that, some of our customers are incapable of printing labels, we've found the best way to handle this is to make Fedex 'return/call tag' orders (been doing it by hand), but I'll want to create those types of orders via the api based on customer checkbox. I know this is not an issue with the api, but I was hoping for a simple example of how to do it.
  2. The fedex Test system has been down all day and part of yesterday. I cannot do any tests or work on any code until it is up. Is this normal? I was on with fedex for 2 hours today, they told us we cannot test creating an order without the test api (obviously), but it is often/sometimes down. I worked previously on FB and Twitter apps which used those APIs and their test servers were never ever down, sounds crazy to me. Any insights? I get Authentication 1000 errors now, yesterday mid-day it all worked (same key, account, meter, password, etc)

thanks,

Mark

example2 - error

I am getting an error:

Fatal error: Class 'FedEx\RateService\SimpleType\RequestedPackageDetailType' not found on line 81

it doesnt look like this class is there: RequestedPackageDetailType

Feature Request - Example for Tracking Notification Request

FedEx's tracking notification feature is really nice, and I have it working, but if I use your updated-services branch I can't figure it out. I can share my example of how I'm using it now, and I was hoping that at some point there will be an example of doing the tracking notification request for the newer services.

For current master branch:

` function notificationSubscription( $trackingNumber, $recipient, $sender )
{
if( ! is_array( $recipient ) OR ! isset( $recipient['email_addr'] ) )
return FALSE;

    if( ! is_array( $sender ) OR ! isset( $sender['email_addr'], $sender['name'] ) )
        return FALSE;

    $userCredential = new ComplexType\WebAuthenticationCredential();
    $userCredential->setKey($this->key)
        ->setPassword($this->passWd);

    $webAuthenticationDetail = new ComplexType\WebAuthenticationDetail();
    $webAuthenticationDetail->setUserCredential($userCredential);

    $clientDetail = new ComplexType\ClientDetail();
    $clientDetail->setAccountNumber($this->acctNo)
        ->setMeterNumber($this->meterNo);

    $version = new ComplexType\VersionId();
    $version->setMajor(5)
        ->setIntermediate(0)
        ->setMinor(0)
        ->setServiceId('trck');

    $localization  = new ComplexType\Localization();
    $localization->setLocaleCode("US")
        ->setLanguageCode("EN");

    $emailRecip = new ComplexType\EMailNotificationRecipient();
    $emailRecip->setEMailNotificationRecipientType(SimpleType\EMailNotificationRecipientType::_SHIPPER)
        ->setEMailAddress( $recipient['email_addr'] )
        ->setLocalization($localization)
        ->setFormat(SimpleType\EMailNotificationFormatType::_TEXT)
        ->setNotificationEventsRequested([
                SimpleType\EMailNotificationEventType::_ON_DELIVERY,
                SimpleType\EMailNotificationEventType::_ON_EXCEPTION
            ]);

    $emailNotificationDetail = new ComplexType\EMailNotificationDetail();
    $emailNotificationDetail->setPersonalMessage('Shipment Status Notification')
        ->setRecipients([$emailRecip]);

    $request = new ComplexType\TrackNotificationRequest();
    $request->setWebAuthenticationDetail($webAuthenticationDetail)
        ->setClientDetail($clientDetail)
        ->setVersion($version)
        ->setTrackingNumber( $trackingNumber )
        ->setSenderEMailAddress( $sender['email_addr'] )
        ->setSenderContactName( $sender['name'] )
        ->setNotificationDetail($emailNotificationDetail);

    $trackServiceRequest = new TrackService\Request();
    if( $this->apiMode == 'production' )
        $trackServiceRequest->getSoapClient()->__setLocation(TrackService\Request::PRODUCTION_URL);
    $response = $trackServiceRequest->getGetTrackNotificationReply($request, TRUE);

    return $response;
}`

"Payor country code must match either Origin or Destination country code"

after editing all the adress data in examples/ship.php so that the package is sent from germany ('DE' countrycode) to germany, i get the errormessage "ShippingChargesPayment - Payor country code must match either Origin or Destination country code". although in the code the paying party is set equal to the shipper e.g. the origin.

Authentication error

Hi Jeremy, thank you very much for this tool, i have installed it with composer, but when i execute by example the track-by-id.php script i get next error:

object(FedEx\RateService\ComplexType\RateReply)#27 (2) { ["name":protected]=> string(9) "RateReply" ["values":protected]=> array(4) { ["HighestSeverity"]=> string(5) "ERROR" ["Notifications"]=> array(1) { [0]=> object(FedEx\RateService\ComplexType\Notification)#39 (2) { ["name":protected]=> string(12) "Notification" ["values":protected]=> array(4) { ["Severity"]=> string(5) "ERROR" ... etc

I have seted my fedex info in credentials.php , but this info is in test mode.

define('FEDEX_ACCOUNT_NUMBER', '510087240');
define('FEDEX_METER_NUMBER', '119024370');
define('FEDEX_KEY', 'o0hwrrN6w0OIseO8');
define('FEDEX_PASSWORD', 'xxxSomePassxxx');

thanks in advance!

Array to string conversion

screen shot 2018-01-31 at 4 29 59 pm

Please help me to fix this. here is my code

setKey(Config::get('app.FEDEX_KEY'))->setPassword(Config::get('app.FEDEX_PASSWORD')); $webAuthenticationDetail = new ComplexType\WebAuthenticationDetail(); $webAuthenticationDetail->setUserCredential($userCredential); $clientDetail = new ComplexType\ClientDetail(); $clientDetail ->setAccountNumber(Config::get('app.FEDEX_ACCOUNT_NUMBER')) ->setMeterNumber(Config::get('FEDEX_METER_NUMBER')); $version = new ComplexType\VersionId(); $version ->setMajor(12) ->setIntermediate(1) ->setMinor(0) ->setServiceId('ship'); $shipperAddress = new ComplexType\Address(); $shipperAddress ->setStreetLines(['Address Line 1']) ->setCity('Austin') ->setStateOrProvinceCode('TX') ->setPostalCode('73301') ->setCountryCode('US'); $shipperContact = new ComplexType\Contact(); $shipperContact ->setCompanyName('Company Name') ->setEMailAddress('[email protected]') ->setPersonName('Person Name') ->setPhoneNumber(('123-123-1234')); $shipper = new ComplexType\Party(); $shipper ->setAccountNumber(Config::get('app.FEDEX_ACCOUNT_NUMBER')) ->setAddress($shipperAddress) ->setContact($shipperContact); $recipientAddress = new ComplexType\Address(); $recipientAddress ->setStreetLines(['Address Line 1']) ->setCity('Herndon') ->setStateOrProvinceCode('VA') ->setPostalCode('20171') ->setCountryCode('US'); $recipientContact = new ComplexType\Contact(); $recipientContact ->setPersonName('Contact Name') ->setPhoneNumber('1234567890'); $recipient = new ComplexType\Party(); $recipient ->setAddress($recipientAddress) ->setContact($recipientContact); $labelSpecification = new ComplexType\LabelSpecification(); $labelSpecification ->setLabelStockType(new SimpleType\LabelStockType(SimpleType\LabelStockType::_PAPER_7X4POINT75)) ->setImageType(new SimpleType\ShippingDocumentImageType(SimpleType\ShippingDocumentImageType::_PDF)) ->setLabelFormatType(new SimpleType\LabelFormatType(SimpleType\LabelFormatType::_COMMON2D)); $packageLineItem1 = new ComplexType\RequestedPackageLineItem(); $packageLineItem1 ->setSequenceNumber(1) ->setItemDescription('Product description') ->setDimensions(new ComplexType\Dimensions(array( 'Width' => 10, 'Height' => 10, 'Length' => 25, 'Units' => SimpleType\LinearUnits::_IN ))) ->setWeight(new ComplexType\Weight(array( 'Value' => 2, 'Units' => SimpleType\WeightUnits::_LB ))); $shippingChargesPayor = new ComplexType\Payor(); $shippingChargesPayor->setResponsibleParty($shipper); $shippingChargesPayment = new ComplexType\Payment(); $shippingChargesPayment ->setPaymentType(SimpleType\PaymentType::_SENDER) ->setPayor($shippingChargesPayor); $requestedShipment = new ComplexType\RequestedShipment(); $requestedShipment->setShipTimestamp(date('c')); $requestedShipment->setDropoffType(new SimpleType\DropoffType(SimpleType\DropoffType::_REGULAR_PICKUP)); $requestedShipment->setServiceType(new SimpleType\ServiceType(SimpleType\ServiceType::_FEDEX_GROUND)); $requestedShipment->setPackagingType(new SimpleType\PackagingType(SimpleType\PackagingType::_YOUR_PACKAGING)); $requestedShipment->setShipper($shipper); $requestedShipment->setRecipient($recipient); $requestedShipment->setLabelSpecification($labelSpecification); $requestedShipment->setRateRequestTypes(array(new SimpleType\RateRequestType(SimpleType\RateRequestType::_ACCOUNT))); $requestedShipment->setPackageCount(1); $requestedShipment->setRequestedPackageLineItems([ $packageLineItem1 ]); $requestedShipment->setShippingChargesPayment($shippingChargesPayment); $processShipmentRequest = new ComplexType\ProcessShipmentRequest(); $processShipmentRequest->setWebAuthenticationDetail($webAuthenticationDetail); $processShipmentRequest->setClientDetail($clientDetail); $processShipmentRequest->setVersion($version); $processShipmentRequest->setRequestedShipment($requestedShipment); $shipService = new ShipService\Request(); $shipService->getSoapClient()->__setLocation('https://wsbeta.fedex.com:443/web-services'); $result = $shipService->getProcessShipmentReply($processShipmentRequest); var_dump($result); } }

How to Send Custom Values Parameters while request shipment?

Hello Guys,
I have implemented it in my project but getting an error message "Custom Values required" when requested for international shipment. How can I pass custom value parameters? I tried by adding this code:
$requestedPackageLineItem1->CustomsValue->Value = $itemdetails['CustomsValue'];
OR
$createOpenShipmentRequest->RequestedShipment->CustomsClearanceDetail = $itemdetails['CustomsValue'];

Please check my controller code here: https://www.screencast.com/t/xFtBwTvj

But both are not working. Please help

Problem with installation

i'm trying to install the package with
composer require JeremyDunn/php-fedex-api-wrapper

and i have this error

[InvalidArgumentException] Could not find package JeremyDunn/php-fedex-api-wrapper at any version for your minimum-stability (stable). Check the package spelling or your minimum -stability

i was trying in composer.json with
"jeremydunn/php-fedex-api-wrapper":"@dev",
or
"JeremyDunn/php-fedex-api-wrapper":"dev"
and show me this error:
`Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- The requested package jeremydunn/php-fedex-api-wrapper could not be found in any version, there may be a typo in the package name.

Potential causes:

Read https://getcomposer.org/doc/articles/troubleshooting.md for further common problems.
`

i have laravel 5.4, thanks

examples/ship.php -> "Action type TRANSFER is not allowed for this request."

when running examples/ship.php with all credentials filled in i get the following error:

object(stdClass)#29 (3) {
["HighestSeverity"]=>
string(5) "ERROR"
["Notifications"]=>
object(stdClass)#30 (6) {
["Severity"]=>
string(5) "ERROR"
["Source"]=>
string(4) "ship"
["Code"]=>
string(4) "3630"
["Message"]=>
string(53) "Action type TRANSFER is not allowed for this request."
["LocalizedMessage"]=>
string(53) "Action type TRANSFER is not allowed for this request."
["MessageParameters"]=>
object(stdClass)#31 (2) {
["Id"]=>
string(6) "ACTION"
["Value"]=>
string(8) "TRANSFER"
}
}
["Version"]=>
object(stdClass)#32 (4) {
["ServiceId"]=>
string(4) "ship"
["Major"]=>
int(12)
["Intermediate"]=>
int(1)
["Minor"]=>
int(0)
}
}

How to find original shipment price?

Rate request.
this code is response:
`

                                               [RatedShipmentDetails] => Array
                    (
                        [0] => stdClass Object
                            (
                                [EffectiveNetDiscount] => stdClass Object
                                    (
                                        [Currency] => USD
                                        [Amount] => 0.0
                                    )

                                [ShipmentRateDetail] => stdClass Object
                                    (
                                        [RateType] => PAYOR_ACCOUNT_PACKAGE
                                        [RateScale] => 6
                                        [RateZone] => 2
                                        [PricingCode] => PACKAGE
                                        [RatedWeightMethod] => ACTUAL
                                        [DimDivisor] => 0
                                        [FuelSurchargePercent] => 5.75
                                        [TotalBillingWeight] => stdClass Object
                                            (
                                                [Units] => LB
                                                [Value] => 23.0
                                            )

                                        [TotalBaseCharge] => stdClass Object
                                            (
                                                [Currency] => USD
                                                [Amount] => 93.66
                                            )

                                        [TotalFreightDiscounts] => stdClass Object
                                            (
                                                [Currency] => USD
                                                [Amount] => 0.0
                                            )

                                        [TotalNetFreight] => stdClass Object
                                            (
                                                [Currency] => USD
                                                [Amount] => 93.66
                                            )

                                        [TotalSurcharges] => stdClass Object
                                            (
                                                [Currency] => USD
                                                [Amount] => 10.39
                                            )

                                        [TotalNetFedExCharge] => stdClass Object
                                            (
                                                [Currency] => USD
                                                [Amount] => 104.05
                                            )

                                        [TotalTaxes] => stdClass Object
                                            (
                                                [Currency] => USD
                                                [Amount] => 0.0
                                            )

                                        [TotalNetCharge] => stdClass Object
                                            (
                                                [Currency] => USD
                                                [Amount] => 104.05
                                            )

                                        [TotalRebates] => stdClass Object
                                            (
                                                [Currency] => USD
                                                [Amount] => 0.0
                                            )

                                        [TotalDutiesAndTaxes] => stdClass Object
                                            (
                                                [Currency] => USD
                                                [Amount] => 0.0
                                            )

                                        [TotalNetChargeWithDutiesAndTaxes] => stdClass Object
                                            (
                                                [Currency] => USD
                                                [Amount] => 104.05
                                            )

                                        [Surcharges] => Array
                                            (
                                                [0] => stdClass Object
                                                    (
                                                        [SurchargeType] => SIGNATURE_OPTION
                                                        [Description] => Direct signature required
                                                        [Amount] => stdClass Object
                                                            (
                                                                [Currency] => USD
                                                                [Amount] => 0.0
                                                            )

                                                    )

                                                [1] => stdClass Object
                                                    (
                                                        [SurchargeType] => INSURED_VALUE
                                                        [Description] => Insured value
                                                        [Amount] => stdClass Object
                                                            (
                                                                [Currency] => USD
                                                                [Amount] => 5.0
                                                            )

                                                    )

                                                [2] => stdClass Object
                                                    (
                                                        [SurchargeType] => FUEL
                                                        [Description] => Fuel
                                                        [Amount] => stdClass Object
                                                            (
                                                                [Currency] => USD
                                                                [Amount] => 5.39
                                                            )

                                                    )

                                            )

                                    )

                                [RatedPackages] => stdClass Object
                                    (
                                        [GroupNumber] => 0
                                        [EffectiveNetDiscount] => stdClass Object
                                            (
                                                [Currency] => USD
                                                [Amount] => 0.0
                                            )

                                        [PackageRateDetail] => stdClass Object
                                            (
                                                [RateType] => PAYOR_ACCOUNT_PACKAGE
                                                [RatedWeightMethod] => ACTUAL
                                                [BillingWeight] => stdClass Object
                                                    (
                                                        [Units] => LB
                                                        [Value] => 23.0
                                                    )

                                                [BaseCharge] => stdClass Object
                                                    (
                                                        [Currency] => USD
                                                        [Amount] => 93.66
                                                    )

                                                [TotalFreightDiscounts] => stdClass Object
                                                    (
                                                        [Currency] => USD
                                                        [Amount] => 0.0
                                                    )

                                                [NetFreight] => stdClass Object
                                                    (
                                                        [Currency] => USD
                                                        [Amount] => 93.66
                                                    )

                                                [TotalSurcharges] => stdClass Object
                                                    (
                                                        [Currency] => USD
                                                        [Amount] => 10.39
                                                    )

                                                [NetFedExCharge] => stdClass Object
                                                    (
                                                        [Currency] => USD
                                                        [Amount] => 104.05
                                                    )

                                                [TotalTaxes] => stdClass Object
                                                    (
                                                        [Currency] => USD
                                                        [Amount] => 0.0
                                                    )

                                                [NetCharge] => stdClass Object
                                                    (
                                                        [Currency] => USD
                                                        [Amount] => 104.05
                                                    )

                                                [TotalRebates] => stdClass Object
                                                    (
                                                        [Currency] => USD
                                                        [Amount] => 0.0
                                                    )

                                                [Surcharges] => Array
                                                    (
                                                        [0] => stdClass Object
                                                            (
                                                                [SurchargeType] => SIGNATURE_OPTION
                                                                [Description] => Direct signature required
                                                                [Amount] => stdClass Object
                                                                    (
                                                                        [Currency] => USD
                                                                        [Amount] => 0.0
                                                                    )

                                                            )

                                                        [1] => stdClass Object
                                                            (
                                                                [SurchargeType] => INSURED_VALUE
                                                                [Description] => Insured value
                                                                [Amount] => stdClass Object
                                                                    (
                                                                        [Currency] => USD
                                                                        [Amount] => 5.0
                                                                    )

                                                            )

                                                        [2] => stdClass Object
                                                            (
                                                                [SurchargeType] => FUEL
                                                                [Description] => Fuel
                                                                [Amount] => stdClass Object
                                                                    (
                                                                        [Currency] => USD
                                                                        [Amount] => 5.39
                                                                    )

                                                            )

                                                    )

                                            )

                                    )

                            )`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.