Created
April 24, 2017 18:30
-
-
Save mootrichard/a0deebe88f12122d78d0176027ff0f9b to your computer and use it in GitHub Desktop.
Example International Rates Quote
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const shippo = require('shippo')('YOUR_SHIPPO_TOKEN'); | |
var customsItem = { | |
"description":"T-Shirt", | |
"quantity":20, | |
"net_weight":"1", | |
"mass_unit":"lb", | |
"value_amount":"200", | |
"value_currency":"USD", | |
"origin_country":"US", | |
}; | |
shippo.customsdeclaration.create({ | |
"contents_type": "MERCHANDISE", | |
"contents_explanation": "T-Shirt purchase", | |
"non_delivery_option": "RETURN", | |
"certify": true, | |
"certify_signer": "Simon Kreuz", | |
"items": [customsItem], | |
}).then((customs)=>{ | |
console.log("Success Customs: %s", JSON.stringify(customs,null,2)); | |
shippo.shipment.create({ | |
'object_purpose': 'QUOTE', | |
'address_from': { | |
'object_purpose': 'QUOTE', | |
'street_no': "206", | |
"street1": "41ST ST", | |
"street2": "SUITE 202", | |
'city': "Brooklyn", | |
'state': "NY", | |
'country': "US", | |
'zip': "11232" | |
}, | |
'address_to': { | |
'object_purpose': 'QUOTE', | |
'city': "Berlin", | |
'zip': "10117", | |
'country': "DE" | |
}, | |
'parcels': [{ | |
'weight': "1", | |
'length': "0.1", | |
'width': "0.1", | |
'height': "0.1", | |
'distance_unit': 'in', | |
'mass_unit': "lb" | |
}], | |
'customs_declaration': customs.object_id, | |
'carrier_accounts': ['c36f8a4f37f741fd911a0856bf9163a7'], | |
'async': false | |
}).then((success)=>{ | |
console.log("Success Shipment: %s", JSON.stringify(success,null,2)); | |
}, (error)=>{ | |
console.log("Error Shipment: %s", JSON.stringify(error,null,2)); | |
}) | |
}, (error)=>{ | |
console.log("Error Customs: %s", JSON.stringify(error,null,2)); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment