Skip to content

how to create test shipment request #30 #220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
hamzajamshed007 opened this issue Mar 11, 2024 · 0 comments
Open

how to create test shipment request #30 #220

hamzajamshed007 opened this issue Mar 11, 2024 · 0 comments

Comments

@hamzajamshed007
Copy link

Hi,

how to create test shipment request in FEDEX.
I am having issues with packagecount i don't understand what i give that it will work ..
Here My Code
//USER CREDENTIALS
$userCredential = new \FedEx\ShipService\ComplexType\WebAuthenticationCredential();
$userCredential
->setKey(config('services.fedex.key'))
->setPassword(config('services.fedex.password'));

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

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

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

    //SHIPPER CONTACT DETAILS
    $shipperAddress = new \FedEx\ShipService\ComplexType\Address();
    $shipperAddress
        ->setStreetLines(array(
            '1202 Chalet Ln',
            'Do Not Delete - Test Account'
        ))
        ->setCity('Harrison')
        ->setStateOrProvinceCode('AR')
        ->setPostalCode('72601')
        ->setCountryCode('US');

    $shipperContact = new \FedEx\ShipService\ComplexType\Contact();
    $shipperContact
        ->setCompanyName('Company Name')
        ->setEMailAddress('[email protected]')
        ->setPersonName('Person Name')
        ->setPhoneNumber(('123-123-1234'));
        
    //SHIPPER ACCOUTN NUMBER
    $shipper = new \FedEx\ShipService\ComplexType\Party();
    $shipper
        ->setAccountNumber('510000000')
        ->setAddress($shipperAddress)
        ->setContact($shipperContact);

    //RECIPENT CONTACT DETAILS
    $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);

    //LABEL SPECS
    $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));

    //REQUESTED SHIPMENT
    $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::_FEDEX_SMALL_BOX));
    $requestedShipment->setShipper($shipper);
    $requestedShipment->setRecipient($recipient);
    $requestedShipment->setLabelSpecification($labelSpecification);
    $requestedShipment->setRateRequestTypes(array(new \FedEx\ShipService\SimpleType\RateRequestType(\FedEx\ShipService\SimpleType\RateRequestType::_CUSTOM)));
    $requestedShipment->setPackageCount(1);
    
    //chatgpt
    $processShipmentRequest = new \FedEx\ShipService\ComplexType\ProcessShipmentRequest();
    $processShipmentRequest->setWebAuthenticationDetail($webAuthenticationDetail);
    $processShipmentRequest->setClientDetail($clientDetail);
    $processShipmentRequest->setVersion($version);
    $processShipmentRequest->setRequestedShipment($requestedShipment);
    
    // Create a request object
    $ship_request = new \FedEx\ShipService\Request();
    $ship_request->getSoapClient()->__setLocation('https://wsbeta.fedex.com/web-services/ship');
    $result = $ship_request->getProcessShipmentReply($processShipmentRequest);
    dd($result);
    
    
    In the response error
    "HighestSeverity" => "ERROR"
"Notifications" => array:1 [
  0 => FedEx\ShipService\ComplexType\Notification {#406
    #name: "Notification"
    #values: array:5 [
      "Severity" => "ERROR"
      "Source" => "ship"
      "Code" => "2021"
      "Message" => "Invalid package count or invalid package sequence number."
      "LocalizedMessage" => "Invalid package count or invalid package sequence number."
    ]
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant