【问题标题】:Create Shipping label by UPS for Node由 UPS 为节点创建运输标签
【发布时间】:2017-01-11 07:51:02
【问题描述】:

我的节点项目中有 UPS 运输服务。现在我想集成下面使用的“创建运输标签”代码。从此代码中,我收到带有错误消息的 base64 编码图像。我试图搜索这个错误,但我没有找到任何东西。

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' }

如何创建货件标签?

【问题讨论】:

  • 只注释掉ups.void这行代码

标签: node.js label shipping ups


【解决方案1】:

也许它只是不能取消它,但它通过了。尝试检查 UPS 仪表板。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-07-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多