Skip to content

Instantly share code, notes, and snippets.

@mootrichard
mootrichard / handler.js
Last active August 10, 2018 21:57
Our final Serverless function for creating checkouts
const SquareConnect = require('square-connect');
const crypto = require('crypto');
const querystring = require('querystring');
module.exports.checkout = (event, context, callback) => {
(SquareConnect.ApiClient.instance).authentications["oauth2"].accessToken = process.env.ACCESS_TOKEN;
const formData = querystring.parse(event.body);
const locationId = process.env.LOCATION_ID;
const checkoutRequest = {
idempotency_key: crypto.randomBytes(48).toString('base64'),
@mootrichard
mootrichard / process.py
Last active July 22, 2018 12:17 — forked from jorgesancha/python_code_test_carto.md
Python code test - CARTO
#!/usr/local/bin/python3
line_count = 1
tip_amount_sum = 0
def process_line(lines):
global line_count
global tip_amount_sum
line_count += 1
tip_amount_sum += float(line.split(",")[15])
@mootrichard
mootrichard / App.jsx
Created October 24, 2018 21:30
Parent component for Square React Payment Form
import React, { Component } from 'react';
import './App.css';
import PaymentForm from './components/PaymentForm';
class App extends Component {
constructor(props){
super(props)
this.state = {
loaded: false
}
@mootrichard
mootrichard / index.d.ts
Created October 8, 2019 20:30
Enums into Types
// Type definitions for square-connect 2.20190814
// Project: https://docs.connect.squareup.com/
// Definitions by: Dmitri Dimitrioglo <https://github.com/ddimitrioglo>
// Richard Moot <https://github.com/mootrichard>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
export type CountryEnum =
'ZZ' |
'AD' |