Created
June 20, 2017 17:22
-
-
Save mootrichard/4557ff32ffbf127f6d8449aac7e6020b to your computer and use it in GitHub Desktop.
4 Ways to Improve Post-Purchase Experience
This file contains hidden or 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_API_KEY'); | |
let addressObject = { | |
name: "Shawn Ippotle", | |
company: "Shippo", | |
street1: "218 Claytona St.", | |
city: "San Francisco", | |
state: "CA", | |
zip: "94117", | |
country: "US", | |
phone: "+1 555 341 9393", | |
email: "[email protected]", | |
validate: true | |
}; | |
shippo.address | |
.create(addressObject) | |
.then((response)=>{ | |
// Do actions with the validated address | |
console.log(JSON.stringify(response, null, 2)); | |
}); |
This file contains hidden or 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_API_KEY'); | |
let addressTo = { | |
name: "Shawn Ippotle", | |
company: "Shippo", | |
street1: "218 Claytona St.", | |
city: "San Francisco", | |
state: "CA", | |
zip: "94117", | |
country: "US", | |
phone: "+1 555 341 9393", | |
email: "[email protected]" | |
} | |
let addressFrom = { | |
name: "Mrs Hippo", | |
street1: "1092 Indian Summer Ct", | |
city: "San Jose", | |
state: "CA", | |
zip: "95122", | |
country: "US", | |
phone: "4159876543", | |
email: "[email protected]" | |
} | |
let parcels = [ | |
{ | |
length: "5", | |
width: "5", | |
height: "5", | |
distance_unit: "in", | |
weight: "2", | |
mass_unit: "lb" | |
} | |
] | |
let shipmentObject = { | |
address_from: addressFrom, | |
address_to: addressTo, | |
parcels: parcels, | |
async: false | |
}; | |
shippo.shipment | |
.create(shipmentObject) | |
.then((response)=>{ | |
// You now have an array of all your rates available for that shipment. | |
let rates = response.rates; | |
// You can send those to the front-end to display, filter them, or even | |
// adjust a small inflation on that rate before returning it to the user | |
// to account for handling fees or other costs you might incure from | |
// shipping | |
console.log(JSON.stringify(rates, null, 2)); | |
}); |
This file contains hidden or 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_API_KEY'); | |
var webhookData = { | |
carrier: "usps", | |
tracking_number: "1122334455667788", | |
metadata: "test order" | |
} | |
shippo.track | |
.create(webhookData) | |
.then((response)=>{ | |
// You'll be returned back the initial status of your shipment | |
console.log(JSON.stringify(response,null ,2)); | |
}); |
This file contains hidden or 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_API_KEY'); | |
let addressTo = { | |
name: "Shawn Ippotle", | |
company: "Shippo", | |
street1: "218 Clayton St.", | |
city: "San Francisco", | |
state: "CA", | |
zip: "94117", | |
country: "US", | |
phone: "+1 555 341 9393", | |
email: "[email protected]" | |
} | |
let addressFrom = { | |
name: "Shippo Returns Dept", | |
company: "Shippo Returns", | |
street1: "965 Mission Street", | |
street2: "Suite 480", | |
city: "San Francisco", | |
state: "CA", | |
zip: "94103", | |
country: "US", | |
phone: "+1 555 341 9393", | |
email: "[email protected]" | |
} | |
let parcels = [ | |
{ | |
length: "5", | |
width: "5", | |
height: "5", | |
distance_unit: "in", | |
weight: "2", | |
mass_unit: "lb" | |
} | |
] | |
let shipmentObject = { | |
address_from: addressFrom, | |
address_to: addressTo, | |
parcels: parcels, | |
extra: { | |
is_return: true | |
}, | |
async: false | |
}; | |
shippo.shipment | |
.create(shipmentObject) | |
.then((response)=>{ | |
console.log(JSON.stringify(response, null, 2)); | |
}, (err)=>{ | |
console.error(err); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment