当前位置: 首页>>代码示例>>PHP>>正文


PHP SoapClient::processShipment方法代码示例

本文整理汇总了PHP中SoapClient::processShipment方法的典型用法代码示例。如果您正苦于以下问题:PHP SoapClient::processShipment方法的具体用法?PHP SoapClient::processShipment怎么用?PHP SoapClient::processShipment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SoapClient的用法示例。


在下文中一共展示了SoapClient::processShipment方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ship

 /**
  * Confirm a shipment
  *
  * @param bool $verifyPeer
  *
  * @throws \Exception
  *
  * @return array label file format, label image data
  */
 public function ship($verifyPeer = true)
 {
     $request = [];
     $request['Version'] = array('ServiceId' => 'ship', 'Major' => '17', 'Intermediate' => '0', 'Minor' => '0');
     $serviceType = isset($this->shippingInfo->serviceType) ? $this->shippingInfo->serviceType : 'STANDARD_OVERNIGHT';
     $packageType = isset($this->shippingInfo->PackagingType) ? $this->shippingInfo->PackagingType : 'YOUR_PACKAGING';
     $request['RequestedShipment'] = array('ShipTimestamp' => date('c'), 'DropoffType' => $this->dropOfType, 'ServiceType' => $serviceType, 'PackagingType' => $packageType, 'Shipper' => $this->shipFrom, 'Recipient' => $this->shipTo, 'ShippingChargesPayment' => $this->addShippingChargesPayment(), 'LabelSpecification' => $this->addLabelSpecification(), 'CustomerSpecifiedDetail' => array('MaskedData' => 'SHIPPER_ACCOUNT_NUMBER'), 'PackageCount' => 1, 'RequestedPackageLineItems' => array('0' => $this->addPackageLineItem1()));
     $request = array_merge($this->requestHeader, $request);
     $this->client = new \SoapClient($this->wsdl['shipping'], ['trace' => 1]);
     $this->response = $this->client->processShipment($request);
     if ($this->response->HighestSeverity === 'ERROR') {
         $errors = $this->response->Notifications;
         if (is_object($errors)) {
             $errors = [$errors];
         }
         foreach ($errors as $error) {
             if ($error->Severity === 'ERROR') {
                 $errorMsg[] = $error->Message;
             }
         }
         throw new \Exception(implode("\n", $errorMsg), $errors[0]->Code);
     }
     $label = $this->response->CompletedShipmentDetail->CompletedPackageDetails->Label->Parts->Image;
     return ['png', base64_decode($label)];
 }
开发者ID:jfquestiaux,项目名称:fabrik,代码行数:34,代码来源:Fedex.php

示例2: generate_label

 public function generate_label($order)
 {
     set_time_limit(30);
     // prevent timeout in batch processing
     ini_set("soap.wsdl_cache_enabled", "0");
     try {
         $client = new SoapClient($this->wsdl_path());
         // creating request object for this item
         $request = $this->create_request($order);
         // send request object to FedEx web service
         $response = $client->processShipment($request);
         // was request successful?
         if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR') {
             return array('label_data' => $response->CompletedShipmentDetail->CompletedPackageDetails->Label->Parts->Image, 'tracking_number' => $this->get_ground_tracking_number($response->CompletedShipmentDetail->CompletedPackageDetails->TrackingIds));
         } else {
             $this->write_to_log('Unable to generate label: ' . "\n" . print_r($response->Notifications, true));
             return array('error' => $this->get_error_messages($response->Notifications));
         }
     } catch (SoapFault $exception) {
         $this->write_to_log('SoapFault: ' . $exception->getMessage());
         return array('error' => 'SoapFault: ' . $exception->getMessage());
     } catch (Exception $exception) {
         $this->write_to_log($exception->getMessage());
         return array('error' => 'Exception: ' . $exception->getMessage());
     }
 }
开发者ID:whatthefork,项目名称:woocommerce-fedex-shipping-labels,代码行数:26,代码来源:fedex-shipping-label-service.php

示例3: SoapClient

$path_to_wsdl = "../../../wsdl/beta/ShipService_v17.wsdl";
define('SHIP_LABEL', 'shipexpresslabel.pdf');
// PDF label file. Change to file-extension .pdf for creating a PDF label (e.g. shiplabel.pdf)
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient($path_to_wsdl, array('trace' => 1));
// Refer to http://us3.php.net/manual/en/ref.soap.php for more information
$request['WebAuthenticationDetail'] = array('ParentCredential' => array('Key' => getProperty('parentkey'), 'Password' => getProperty('parentpassword')), 'UserCredential' => array('Key' => getProperty('key'), 'Password' => getProperty('password')));
$request['ClientDetail'] = array('AccountNumber' => getProperty('shipaccount'), 'MeterNumber' => getProperty('meter'));
$request['TransactionDetail'] = array('CustomerTransactionId' => '*** Express International Shipping Request using PHP ***');
$request['Version'] = array('ServiceId' => 'ship', 'Major' => '17', 'Intermediate' => '0', 'Minor' => '0');
$request['RequestedShipment'] = array('ShipTimestamp' => date('c'), 'DropoffType' => 'REGULAR_PICKUP', 'ServiceType' => 'INTERNATIONAL_PRIORITY', 'PackagingType' => 'YOUR_PACKAGING', 'Shipper' => addShipper(), 'Recipient' => addRecipient(), 'ShippingChargesPayment' => addShippingChargesPayment(), 'CustomsClearanceDetail' => addCustomClearanceDetail(), 'LabelSpecification' => addLabelSpecification(), 'CustomerSpecifiedDetail' => array('MaskedData' => 'SHIPPER_ACCOUNT_NUMBER'), 'PackageCount' => 1, 'RequestedPackageLineItems' => array('0' => addPackageLineItem1()), 'CustomerReferences' => array('0' => array('CustomerReferenceType' => 'CUSTOMER_REFERENCE', 'Value' => 'TC007_07_PT1_ST01_PK01_SNDUS_RCPCA_POS')));
try {
    if (setEndpoint('changeEndpoint')) {
        $newLocation = $client->__setLocation(setEndpoint('endpoint'));
    }
    $response = $client->processShipment($request);
    // FedEx web service invocation
    if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR') {
        printSuccess($client, $response);
        // Create PNG or PDF label
        // Set LabelSpecification.ImageType to 'PDF' for generating a PDF label
        $fp = fopen(SHIP_LABEL, 'wb');
        fwrite($fp, $response->CompletedShipmentDetail->CompletedPackageDetails->Label->Parts->Image);
        fclose($fp);
        echo 'Label <a href="./' . SHIP_LABEL . '">' . SHIP_LABEL . '</a> was generated.';
    } else {
        printError($client, $response);
    }
    writeToLog($client);
    // Write to log file
} catch (SoapFault $exception) {
开发者ID:rubaiet,项目名称:fedex,代码行数:31,代码来源:ShipWebServiceClient.php

示例4: addShippingChargesPayment

	'ShippingChargesPayment' => addShippingChargesPayment(),
	'LabelSpecification' => addLabelSpecification(), 
	'PackageCount' => 2,
	'RequestedPackageLineItems' => array(
		'0' => addPackageLineItem1()
	)
);



try {
	if(setEndpoint('changeEndpoint')){
		$newLocation = $client->__setLocation(setEndpoint('endpoint'));
	}
		
	$masterResponse = $client->processShipment($masterRequest); // FedEx web service invocation  
	
	writeToLog($client);    // Write to log file

	if ($masterResponse->HighestSeverity != 'FAILURE' && $masterResponse->HighestSeverity != 'ERROR'){
	    printSuccess($client, $masterResponse);
	
	    $fp = fopen(SHIP_CODMASTERLABEL, 'wb');   
	    fwrite($fp, $masterResponse->CompletedShipmentDetail->CompletedPackageDetails->CodReturnDetail->Label->Parts->Image); //Create COD Return PNG or PDF file
	    fclose($fp);
	    echo '<a href="./'.SHIP_CODMASTERLABEL.'">'.SHIP_CODMASTERLABEL.'</a> was generated.'.Newline;
	
	    // Create PNG or PDF label
	    // Set LabelSpecification.ImageType to 'PDF' for generating a PDF label
	    $fp = fopen(SHIP_MASTERLABEL, 'wb');   
	    fwrite($fp, ($masterResponse->CompletedShipmentDetail->CompletedPackageDetails->Label->Parts->Image));
开发者ID:rubaiet,项目名称:fedex,代码行数:31,代码来源:ShipWebServiceClient.php5

示例5: getProcessShipmentReply

 /**
  * Sends the ProcessShipmentRequest and returns the response
  *
  * @param ComplexType\ProcessShipmentRequest $processShipmentRequest 
  * @return stdClass
  */
 public function getProcessShipmentReply(ComplexType\ProcessShipmentRequest $processShipmentRequest)
 {
     return $this->_soapClient->processShipment($processShipmentRequest->toArray());
 }
开发者ID:chefsplate,项目名称:php-fedex-api-wrapper,代码行数:10,代码来源:Request.php

示例6: retrieveLabel

 function retrieveLabel($sInfo)
 {
     global $messageStack;
     $fedex_results = array();
     if (in_array($sInfo->ship_method, array('I2DEam', 'I2Dam', 'I3D'))) {
         // unsupported ship methods
         $messageStack->add('The ship method requested is not supported by this tool presently. Please ship the package via a different tool.', 'error');
         return false;
     }
     if (MODULE_SHIPPING_FEDEX_V7_TEST_MODE == 'Test') {
         $client = new SoapClient(PATH_TO_TEST_SHIP_WSDL, array('trace' => 1));
     } else {
         $client = new SoapClient(PATH_TO_SHIP_WSDL, array('trace' => 1));
     }
     for ($key = 0; $key < count($sInfo->package); $key++) {
         $labels = array();
         $request = $this->FormatFedExShipRequest($sInfo, $key);
         //echo 'FedEx Express XML Label Submit String:'; print_r($request); echo '<br />';
         try {
             $response = $client->processShipment($request);
             //echo 'Request <pre>' . htmlspecialchars($client->__getLastRequest()) . '</pre>';
             //echo 'Response <pre>' . htmlspecialchars($client->__getLastResponse()) . '</pre>';
             //echo 'label response array = '; print_r($response); echo '<br />';
             if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR') {
                 if ($key == 0) {
                     $sInfo->master_tracking = $response->CompletedShipmentDetail->MasterTrackingId;
                 }
                 $net_cost = 0;
                 $book_cost = 0;
                 $del_date = '';
                 if (isset($response->CompletedShipmentDetail->OperationalDetail->DeliveryDate)) {
                     $del_code = $response->CompletedShipmentDetail->OperationalDetail->DestinationServiceArea;
                     $guar_time = $this->calculateDeliveryTime($sInfo->ship_method, $del_code, $sInfo->residential_address);
                     $del_date = $response->CompletedShipmentDetail->OperationalDetail->DeliveryDate . ' ' . $guar_time;
                 } elseif (isset($response->CompletedShipmentDetail->OperationalDetail->MaximumTransitTime)) {
                     $del_date = $this->calculateDelivery($response->CompletedShipmentDetail->OperationalDetail->MaximumTransitTime, $sInfo->residential_address);
                 } elseif (isset($response->CompletedShipmentDetail->OperationalDetail->TransitTime)) {
                     $del_date = $this->calculateDelivery($response->CompletedShipmentDetail->OperationalDetail->TransitTime, $sInfo->residential_address);
                 }
                 if (is_array($response->CompletedShipmentDetail->CompletedPackageDetails->PackageRating->PackageRateDetails)) {
                     foreach ($response->CompletedShipmentDetail->CompletedPackageDetails->PackageRating->PackageRateDetails as $rate) {
                         switch ($rate->RateType) {
                             case 'PAYOR_ACCOUNT_PACKAGE':
                             case 'PAYOR_ACCOUNT_SHIPMENT':
                                 $net_cost = $rate->NetCharge->Amount;
                                 break;
                             case 'PAYOR_LIST_SHIPMENT':
                             case 'PAYOR_LIST_PACKAGE':
                                 $book_cost = $rate->NetCharge->Amount;
                                 break;
                         }
                     }
                 }
                 if ($response->CompletedShipmentDetail->CarrierCode == 'FXFR') {
                     // LTL Freight
                     //echo 'Request <pre>' . htmlspecialchars($client->__getLastRequest()) . '</pre>';
                     $is_ltl = true;
                     // special handling for freight, hard coded label types for now
                     $tracking = $response->CompletedShipmentDetail->MasterTrackingId->TrackingNumber;
                     $zone = '';
                     foreach ($response->CompletedShipmentDetail->ShipmentDocuments as $document) {
                         $labels[] = $document->Parts->Image;
                     }
                 } else {
                     $is_ltl = false;
                     $zone = $response->CompletedShipmentDetail->ShipmentRating->ShipmentRateDetails->RateZone;
                     $labels[] = $response->CompletedShipmentDetail->CompletedPackageDetails->Label->Parts->Image;
                     if (is_array($response->CompletedShipmentDetail->CompletedPackageDetails->TrackingIds)) {
                         // Smart Post
                         foreach ($response->CompletedShipmentDetail->CompletedPackageDetails->TrackingIds as $track_num) {
                             if ($track_num->TrackingIdType == 'GROUND') {
                                 $tracking = $track_num->TrackingNumber;
                             }
                         }
                     } else {
                         $tracking = $response->CompletedShipmentDetail->CompletedPackageDetails->TrackingIds->TrackingNumber;
                     }
                 }
                 if (!$tracking) {
                     $messageStack->add('Error - No tracking found in return string.', 'error');
                     //echo 'label response array = '; print_r($response); echo '<br />';
                     return false;
                 }
                 $fedex_results[$key] = array('ref_id' => $sInfo->purchase_invoice_id . '-' . ($key + 1), 'tracking' => $tracking, 'zone' => $zone, 'book_cost' => $book_cost, 'net_cost' => $net_cost, 'delivery_date' => $del_date);
                 if (sizeof($labels) > 0) {
                     $cnt = 0;
                     $date = explode('-', $sInfo->ship_date);
                     $file_path = SHIPPING_DEFAULT_LABEL_DIR . $this->code . '/' . $date[0] . '/' . $date[1] . '/' . $date[2] . '/';
                     validate_path($file_path);
                     foreach ($labels as $label) {
                         $this->returned_label = $label;
                         // check for label to be for thermal printer or plain paper
                         if (MODULE_SHIPPING_FEDEX_V7_PRINTER_TYPE == 'Thermal') {
                             // keep the thermal label encoded for now
                             $file_name = $tracking . ($cnt > 0 ? '-' . $cnt : '') . '.lpt';
                             // thermal printer
                             if ($is_ltl && $cnt > 0) {
                                 $file_name = $tracking . '-' . $cnt . '.pdf';
                             }
                             // BOL must be PDF
//.........这里部分代码省略.........
开发者ID:siwiwit,项目名称:PhreeBooksERP,代码行数:101,代码来源:fedex_v7.php


注:本文中的SoapClient::processShipment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。