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
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
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
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
router.get("/callback", (req, res) => { | |
const tokenURL = "https://connect.squareup.com/oauth2/token"; | |
const redirectURI = "https://square-oauth-example.glitch.me/auth/callback"; | |
if (req.query.state === req.auth.state) { | |
axios | |
.post(tokenURL, { | |
client_id: CLIENT_ID, | |
client_secret: SECRET, | |
code: req.query.code, |
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
<!-- start product --> | |
<div class='product'> | |
<div class='imageContainer'> | |
<img class='productImage' src="/0.jpeg" /> | |
<!-- insert product image url here --> | |
<div class='imageOverlay'> | |
<button>View Details</button> | |
</div> | |
</div> | |
<div class='modal clearfix'> |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Square Swag Shop</title> | |
<meta name="description" content="A Simple eCommerce Store"> | |
<link id="favicon" rel="icon" href="/favicon.ico" type="image/x-icon"> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name='viewport' content='width=device-width, initial-scale=1'> |
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
'use strict'; | |
const SquareConnect = require('square-connect'); | |
module.exports.checkout = (event, context, callback) => { | |
let response = "Success! Our function is running!"; | |
callback(null, response); | |
}; |
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
service: serverless-checkout # NOTE: update this with your service name | |
provider: | |
name: aws | |
runtime: nodejs8.10 | |
stage: prod | |
memorySize: 256 | |
package: | |
include: |