douqingzhi0980 2017-04-30 07:09
浏览 123

Laravel - FedEx货件请求API响应错误

I have faced the following error when I integrate FedEx shipment API with Laravel. I use this package for it - https://github.com/JeremyDunn/php-fedex-api-wrapper

If anyone knows how to create shipment request with FedEx API, so please help me to resolve this issues, I have sow this type error message "Action type TRANSFER is not allowed for this request." with error code 3630.

I have also added my response output code so you all are understood very well

my Laravel Code

$userCredential = new \FedEx\ShipService\ComplexType\WebAuthenticationCredential();
    $userCredential
        ->setKey('NCimB3Bq5GtxAQx7')
        ->setPassword('Zr1Bb3P1pjYtz0miXdIjut2OW');

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

    $clientDetail = new \FedEx\ShipService\ComplexType\ClientDetail();
    $clientDetail
        ->setAccountNumber('510087160')
        ->setMeterNumber('118814986');

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

    $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('test@example.com')
        ->setPersonName('Person Name')
        ->setPhoneNumber(('123-123-1234'));

    $shipper = new \FedEx\ShipService\ComplexType\Party();
    $shipper
        ->setAccountNumber('510087020')
        ->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::_FEDEX_BOX));
    $requestedShipment->setShipper($shipper);
    $requestedShipment->setRecipient($recipient);
    $requestedShipment->setLabelSpecification($labelSpecification);
    $requestedShipment->setRateRequestTypes(array(new \FedEx\ShipService\SimpleType\RateRequestType(\FedEx\ShipService\SimpleType\RateRequestType::_ACCOUNT)));
    $requestedShipment->setPackageCount(2);




    $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://wsbeta.fedex.com/web-services/ship');
    $result = $shipService->getCreatePendingShipmentReply($createPendingShipmentRequest);
    dd($result);

My Responce output

{#389 ▼
  +"HighestSeverity": "ERROR"
  +"Notifications": array:2 [▼
    0 => {#390 ▼
      +"Severity": "ERROR"
      +"Source": "ship"
      +"Code": "3630"
      +"Message": "Action type TRANSFER is not allowed for this request."
      +"LocalizedMessage": "Action type TRANSFER is not allowed for this request."
      +"MessageParameters": {#391 ▼
        +"Id": "ACTION"
        +"Value": "TRANSFER"
      }
    }
    1 => {#392 ▼
      +"Severity": "ERROR"
      +"Source": "ship"
      +"Code": "2021"
      +"Message": "Invalid package count or invalid package sequence number."
      +"LocalizedMessage": "Invalid package count or invalid package sequence number."
    }
  ]
  +"Version": {#393 ▼
    +"ServiceId": "ship"
    +"Major": 12
    +"Intermediate": 1
    +"Minor": 0
  }
}
  • 写回答

1条回答 默认 最新

  • dsk920417 2017-06-14 05:49
    关注

    add this code:

    $pendingShipmentDetail = new ComplexType\PendingShipmentDetail();
        $pendingShipmentDetail
            ->setType(SimpleType\PendingShipmentType::_EMAIL)
            ->setExpirationDate('06/12/2017')
            ->setEmailLabelDetail(new ShipComplexType\EMailLabelDetail(array(
                'NotificationEMailAddress' => 'test@gmail.com',
                'NotificationMessage' => 'pending shipment notification message'
            )));
        $specialServicesRequested = new ComplexType\ShipmentSpecialServicesRequested();
        $specialServicesRequested
            ->setSpecialServiceTypes(array(SimpleType\ShipmentSpecialServiceType::_PENDING_SHIPMENT))
            ->setPendingShipmentDetail($pendingShipmentDetail);
    
    
    $requestedShipment->setSpecialServicesRequested($specialServicesRequested);
    
    评论

报告相同问题?

悬赏问题

  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)