从 Shippo 接收运费 - Eclipse
Receiving shipping rates from Shippo - Eclipse
经过一番努力,我终于能够让 Shippo 连接到我的 eclipse IDE。但是,在尝试了他们的示例之后,我意识到您从他们的代码中获取费率的方式是不一样的。将 getRates 更改为 getRateList 后,我的费率列表中的 return 为空。即使打印出货件 return 也没有给我任何 USPS 费率,只有 DHL、UPS 和 LPS,所有这些都不是费率,但打印出不同的问题,说明为什么他们不能给我费率.我想知道为什么即使使用 Shippo 的示例我也无法获得任何费率(是的,我尝试了我本地的地址)。它只能是 USPS,因为我不想通过其他服务提供商发货,但我想问问题是否出在我的代码上,我是否遗漏了什么或者我的 Shippo 帐户中是否需要更改某些内容。我已经阅读了他们所有的文档并查阅了很多这个问题,但似乎没有人遇到与我相同的问题。我还在我的 shippo 帐户提供的测试令牌和实时令牌上进行了尝试。同样在我的运营商帐户中,我将 USPS 设置为允许使用我的测试 API.
的测试标签
这是我在 Eclipse Scout 中的代码 IDE:
// TEST API NO CHARGE
Shippo.setApiKey("shippo_test_XXXXXXXXXXXXXXXXXXXXXXXXXX");
// Shippo.setDEBUG(true);
Map<String, Object> toAddressMap = new HashMap<String, Object>();
toAddressMap.put("name", "Mr Hippo");
toAddressMap.put("company", "Shippo");
toAddressMap.put("street1", "215 Clayton St.");
toAddressMap.put("city", "San Francisco");
toAddressMap.put("state", "CA");
toAddressMap.put("zip", "94117");
toAddressMap.put("country", "US");
toAddressMap.put("phone", "+1 555 341 9393");
toAddressMap.put("email", "mrhippo@goshipppo.com");
// toAddressMap.put("is_residential", true);
// from address
Map<String, Object> fromAddressMap = new HashMap<String, Object>();
fromAddressMap.put("name", "Ms Hippo");
fromAddressMap.put("company", "San Diego Zoo");
fromAddressMap.put("street1", "2920 Zoo Drive");
fromAddressMap.put("city", "San Diego");
fromAddressMap.put("state", "CA");
fromAddressMap.put("zip", "92101");
fromAddressMap.put("country", "US");
fromAddressMap.put("email", "mshippo@goshipppo.com");
fromAddressMap.put("phone", "+1 619 231 1515");
fromAddressMap.put("metadata", "Customer ID 123456");
// fromAddressMap.put("is_residential", true);
// parcel
Map<String, Object> parcelMap = new HashMap<String, Object>();
parcelMap.put("length", "5");
parcelMap.put("width", "5");
parcelMap.put("height", "5");
parcelMap.put("distance_unit", "in");
parcelMap.put("weight", "2");
parcelMap.put("mass_unit", "lb");
List<Map<String, Object>> parcels = new ArrayList<Map<String, Object>>();
parcels.add(parcelMap);
Map<String, Object> shipmentMap = new HashMap<String, Object>();
shipmentMap.put("address_to", toAddressMap);
shipmentMap.put("address_from", fromAddressMap);
shipmentMap.put("parcels", parcels);
shipmentMap.put("async", false);
try {
Shipment shipment = Shipment.create(shipmentMap);
System.out.println(shipment);
} catch (AuthenticationException | InvalidRequestException | APIConnectionException | APIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
在 运行 之后我的代码是 JSON return 我回来了:
"object_state": null,
"object_status": null,
"object_purpose": null,
"object_id": "b4c380bbe17d4b0d9a468e91ddc247a3",
"object_owner": "reeseohouseknecht@gmail.com",
"object_created": "2022-03-20T09:19:28.505Z",
"object_updated": "2022-03-20T09:19:28.649Z",
"address_from": {
"object_id": "311925ff01fe4514b9229d9145227a09",
"is_complete": true,
"name": "Ms Hippo",
"company": "San Diego Zoo",
"street_no": "",
"street1": "2920 Zoo Drive",
"validation_results": {},
"street2": "",
"street3": "",
"city": "San Diego",
"state": "CA",
"zip": "92101",
"country": "US",
"phone": "0016192311515",
"email": "mshippo@goshipppo.com",
"is_residential": null,
"test": true
},
"address_to": {
"object_id": "c0fe7b3cc2684fa9bef7177259aba099",
"is_complete": true,
"name": "Mr Hippo",
"company": "Shippo",
"street_no": "",
"street1": "215 Clayton St.",
"validation_results": {},
"street2": "",
"street3": "",
"city": "San Francisco",
"state": "CA",
"zip": "94117",
"country": "US",
"phone": "0015553419393",
"email": "mrhippo@goshipppo.com",
"is_residential": null,
"test": true
},
"address_return": {
"object_id": "311925ff01fe4514b9229d9145227a09",
"is_complete": true,
"name": "Ms Hippo",
"company": "San Diego Zoo",
"street_no": "",
"street1": "2920 Zoo Drive",
"validation_results": {},
"street2": "",
"street3": "",
"city": "San Diego",
"state": "CA",
"zip": "92101",
"country": "US",
"phone": "0016192311515",
"email": "mshippo@goshipppo.com",
"is_residential": null,
"test": true
},
"parcel": null,
"submission_type": null,
"submission_date": null,
"insurance_amount": null,
"insurance_currency": null,
"extra": {},
"customs_declaration": null,
"reference_1": null,
"reference_2": null,
"rates_url": null,
"metadata": "",
"messages": [
{
"source": "UPS",
"code": "110920",
"text": "RatedShipmentAlert: Ship To Address Classification is changed from Commercial to Residential"
},
{
"source": "UPS",
"code": "110971",
"text": "RatedShipmentAlert: Your invoice may vary from the displayed reference rates"
},
{
"source": "ShippoCommon",
"code": "",
"text": "Shipment origin or destination state is out of the service area for LSO."
},
{
"source": "DHLExpress",
"code": "",
"text": "Shippo\u0027s DHL Express master account doesn\u0027t support shipments to inside of the US"
}
],
"rates_list": null
}
查看在 JSON 中发回的结果集并将它们粘贴到 JSON 到字符串转换器中表明我正在接收费率,尽管我实际上无法对它们做任何事情。将 Maven 更新到 3.1.0 允许我使用相同的代码并获得回报。
经过一番努力,我终于能够让 Shippo 连接到我的 eclipse IDE。但是,在尝试了他们的示例之后,我意识到您从他们的代码中获取费率的方式是不一样的。将 getRates 更改为 getRateList 后,我的费率列表中的 return 为空。即使打印出货件 return 也没有给我任何 USPS 费率,只有 DHL、UPS 和 LPS,所有这些都不是费率,但打印出不同的问题,说明为什么他们不能给我费率.我想知道为什么即使使用 Shippo 的示例我也无法获得任何费率(是的,我尝试了我本地的地址)。它只能是 USPS,因为我不想通过其他服务提供商发货,但我想问问题是否出在我的代码上,我是否遗漏了什么或者我的 Shippo 帐户中是否需要更改某些内容。我已经阅读了他们所有的文档并查阅了很多这个问题,但似乎没有人遇到与我相同的问题。我还在我的 shippo 帐户提供的测试令牌和实时令牌上进行了尝试。同样在我的运营商帐户中,我将 USPS 设置为允许使用我的测试 API.
的测试标签这是我在 Eclipse Scout 中的代码 IDE:
// TEST API NO CHARGE
Shippo.setApiKey("shippo_test_XXXXXXXXXXXXXXXXXXXXXXXXXX");
// Shippo.setDEBUG(true);
Map<String, Object> toAddressMap = new HashMap<String, Object>();
toAddressMap.put("name", "Mr Hippo");
toAddressMap.put("company", "Shippo");
toAddressMap.put("street1", "215 Clayton St.");
toAddressMap.put("city", "San Francisco");
toAddressMap.put("state", "CA");
toAddressMap.put("zip", "94117");
toAddressMap.put("country", "US");
toAddressMap.put("phone", "+1 555 341 9393");
toAddressMap.put("email", "mrhippo@goshipppo.com");
// toAddressMap.put("is_residential", true);
// from address
Map<String, Object> fromAddressMap = new HashMap<String, Object>();
fromAddressMap.put("name", "Ms Hippo");
fromAddressMap.put("company", "San Diego Zoo");
fromAddressMap.put("street1", "2920 Zoo Drive");
fromAddressMap.put("city", "San Diego");
fromAddressMap.put("state", "CA");
fromAddressMap.put("zip", "92101");
fromAddressMap.put("country", "US");
fromAddressMap.put("email", "mshippo@goshipppo.com");
fromAddressMap.put("phone", "+1 619 231 1515");
fromAddressMap.put("metadata", "Customer ID 123456");
// fromAddressMap.put("is_residential", true);
// parcel
Map<String, Object> parcelMap = new HashMap<String, Object>();
parcelMap.put("length", "5");
parcelMap.put("width", "5");
parcelMap.put("height", "5");
parcelMap.put("distance_unit", "in");
parcelMap.put("weight", "2");
parcelMap.put("mass_unit", "lb");
List<Map<String, Object>> parcels = new ArrayList<Map<String, Object>>();
parcels.add(parcelMap);
Map<String, Object> shipmentMap = new HashMap<String, Object>();
shipmentMap.put("address_to", toAddressMap);
shipmentMap.put("address_from", fromAddressMap);
shipmentMap.put("parcels", parcels);
shipmentMap.put("async", false);
try {
Shipment shipment = Shipment.create(shipmentMap);
System.out.println(shipment);
} catch (AuthenticationException | InvalidRequestException | APIConnectionException | APIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
在 运行 之后我的代码是 JSON return 我回来了:
"object_state": null,
"object_status": null,
"object_purpose": null,
"object_id": "b4c380bbe17d4b0d9a468e91ddc247a3",
"object_owner": "reeseohouseknecht@gmail.com",
"object_created": "2022-03-20T09:19:28.505Z",
"object_updated": "2022-03-20T09:19:28.649Z",
"address_from": {
"object_id": "311925ff01fe4514b9229d9145227a09",
"is_complete": true,
"name": "Ms Hippo",
"company": "San Diego Zoo",
"street_no": "",
"street1": "2920 Zoo Drive",
"validation_results": {},
"street2": "",
"street3": "",
"city": "San Diego",
"state": "CA",
"zip": "92101",
"country": "US",
"phone": "0016192311515",
"email": "mshippo@goshipppo.com",
"is_residential": null,
"test": true
},
"address_to": {
"object_id": "c0fe7b3cc2684fa9bef7177259aba099",
"is_complete": true,
"name": "Mr Hippo",
"company": "Shippo",
"street_no": "",
"street1": "215 Clayton St.",
"validation_results": {},
"street2": "",
"street3": "",
"city": "San Francisco",
"state": "CA",
"zip": "94117",
"country": "US",
"phone": "0015553419393",
"email": "mrhippo@goshipppo.com",
"is_residential": null,
"test": true
},
"address_return": {
"object_id": "311925ff01fe4514b9229d9145227a09",
"is_complete": true,
"name": "Ms Hippo",
"company": "San Diego Zoo",
"street_no": "",
"street1": "2920 Zoo Drive",
"validation_results": {},
"street2": "",
"street3": "",
"city": "San Diego",
"state": "CA",
"zip": "92101",
"country": "US",
"phone": "0016192311515",
"email": "mshippo@goshipppo.com",
"is_residential": null,
"test": true
},
"parcel": null,
"submission_type": null,
"submission_date": null,
"insurance_amount": null,
"insurance_currency": null,
"extra": {},
"customs_declaration": null,
"reference_1": null,
"reference_2": null,
"rates_url": null,
"metadata": "",
"messages": [
{
"source": "UPS",
"code": "110920",
"text": "RatedShipmentAlert: Ship To Address Classification is changed from Commercial to Residential"
},
{
"source": "UPS",
"code": "110971",
"text": "RatedShipmentAlert: Your invoice may vary from the displayed reference rates"
},
{
"source": "ShippoCommon",
"code": "",
"text": "Shipment origin or destination state is out of the service area for LSO."
},
{
"source": "DHLExpress",
"code": "",
"text": "Shippo\u0027s DHL Express master account doesn\u0027t support shipments to inside of the US"
}
],
"rates_list": null
}
查看在 JSON 中发回的结果集并将它们粘贴到 JSON 到字符串转换器中表明我正在接收费率,尽管我实际上无法对它们做任何事情。将 Maven 更新到 3.1.0 允许我使用相同的代码并获得回报。