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 fs = require('fs'); | |
const Storage = require('@google-cloud/storage'); | |
const BUCKET_NAME = ''; // This would actually have the name of our bucket | |
const storage = new Storage({ | |
projectId: '', // This should be your Google Cloud Project ID where you're deploying your function & have your bucket | |
keyFilename: './keyfile.json' | |
}); | |
exports.webhook = (request, response) => { | |
const data = JSON.stringify(request.body, 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
AutoForm.addHooks("square-payment-form", { | |
onSubmit: function (doc) { | |
submitting = true; | |
const template = this.template; | |
hidePaymentAlert(); | |
const form = { | |
cardNonce: doc.nonce // Here is where we're placing our nonce | |
}; | |
Meteor.subscribe("Packages", Reaction.getShopId()); | |
const packageData = Packages.findOne({ |
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
Template.squarePaymentForm.onRendered(function () { | |
$(document).ready(function () { | |
createPaymentForm(); | |
}); | |
$("#submitCard").on("click", function () { | |
paymentForm.requestCardNonce(); | |
}); | |
}); |
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
$.getScript("https://js.squareup.com/v2/paymentform").done(function () { | |
paymentForm = new SqPaymentForm({ | |
// Setup your SqPaymentForm object, see https://docs.connect.squareup.com/payments/sqpaymentform/sqpaymentform-setup | |
// for more details | |
}); | |
// We're manually building the form here, since the page is already loaded and won't trigger the event SqPaymentForm | |
// is expecting | |
paymentForm.build(); | |
}); |
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
cardNonceResponseReceived: function(errors, nonce, cardData) { | |
if (errors) { | |
// Log errors from nonce generation to the Javascript console | |
console.log("Encountered errors:"); | |
errors.forEach(function(error) { | |
console.log(" " + error.message); | |
}); | |
return; | |
} | |
console.log(cardData); |
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
<script type="text/javascript" src="https://js.squareup.com/v2/paymentform"> | |
</script> |
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", |
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
{ | |
"variables": [], | |
"info": { | |
"name": "Rest API Planning", | |
"_postman_id": "4b9b4065-d319-6f32-bae2-2dd4e0f33d0d", | |
"description": "", | |
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" | |
}, | |
"item": [ | |
{ |
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_TOKEN'); | |
var customsItem = { | |
"description":"T-Shirt", | |
"quantity":20, | |
"net_weight":"1", | |
"mass_unit":"lb", | |
"value_amount":"200", | |
"value_currency":"USD", | |
"origin_country":"US", |
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
{ | |
"carrier": "ups", | |
"tracking_number": "92748931507953573000007541", | |
"address_from": null, | |
"address_to": null, | |
"eta": null, | |
"servicelevel": { | |
"token": null, | |
"name": null | |
}, |