2017-01-11 66 views
0

我在我的節點項目中有UPS運輸服務。現在我想集成下面使用的「創建運輸標籤」代碼。從這段代碼我收到一個base64編碼的圖像,並顯示一條錯誤消息。我試圖搜索這個錯誤,但我沒有發現任何東西。通過UPS爲節點創建運輸標籤

var upsAPI = require('shipping-ups'); 
    const fs = require('fs'); 
    var util = require('util'); 

    var ups = new upsAPI({ 
     environment: Constants.UPS_ENVIROMENT, // or live 
     username: Constants.UPS_USERNAME, 
     password: Constants.UPS_PASSWORD, 
     access_key: Constants.UPS_ACCESSKEY, 
     imperial: true, // set to false for metric 
     debug: false 
    }); 

    ups.confirm({ 
      shipper: { 
      name: 'Type Foo', 
      shipper_number: 'MY_6_ALPHA_NUMERIC_CODE', 
      address: { 
       address_line_1: '1439 S RIMHURST AVE', 
       city: 'GLENDORA', 
       state_code: 'CA', 
       country_code: 'US', 
       postal_code: '91740' 
      } 
      }, 
      ship_to: { 
      company_name: 'Uhsem Blee', 
      address: { 
       address_line_1: '3456 Fake Address', // optional 
       city: 'Barstow', // optional 
       state_code: 'CA', // optional, required for negotiated rates 
       country_code: 'US', 
       postal_code: '92311' 
      } 
      }, 
      packages: [ 
      { 
       description: 'My Package', 
       weight: 1 
      } 
      ] 
     }, function(err, res) { 

      if(err) { 
      return console.log(err); 
      } 
      //console.log(util.inspect(res, {depth: null})); 
      ups.accept(res.ShipmentDigest, function(err, res) { 
      if(err) { 
       return console.log(err); 
      } 
      console.log(res.ShipmentResults.PackageResults.LabelImage); 
      fs.writeFile('/label.gif', new Buffer(res.ShipmentResults.PackageResults.LabelImage.GraphicImage, "base64"), function(err) { 

       ups.void(res.ShipmentResults.ShipmentIdentificationNumber, function(err, res) { 
       // {shipment_identification_number: '1Z648616E192760718'} 
       if(err) { 
        return console.log(err); 
       } 
       console.log(util.inspect(res, {depth: null})); 
       }) 
      }); 
      }); 
     }); 

錯誤:

A Large ENCODE STRING with this message. 
{ ErrorSeverity: 'Hard', 
    ErrorCode: '190102', 
    ErrorDescription: 'No shipment found within the allowed void period' } 

如何創建裝運標籤? enter image description here

+0

只需註釋掉ups.void代碼行 – Shobby

回答

1

也許它只是不能使其無效,但它已經通過。嘗試檢入UPS儀表板。

相關問題