Skip to content

Instantly share code, notes, and snippets.

/*** PLP ***/
{
"productId": 23573080,
"lineNumber": "BUNDLE_AW15_02S13IBLU_3",
"name": "3 Piece Slim Fit Blue Tipped Suit",
"unitPrice": "155.00",
"assets": [
{
"assetType": "IMAGE_SMALL",
"index": 1,
@alexFaunt
alexFaunt / example-receipt.js
Last active June 17, 2018 11:21
An example of decoded receipt information from Apple
{
/*
The environment this receipt is for - either "Sandbox" or "PROD",
one is abbreviated, the other isnt, one is in caps and one is Sentence case
that is not a mistake, at least, not by me.
*/
"environment": "Sandbox",
/*
The decoded version of the receipt you sent - my advice is to completely ignore this.
@alexFaunt
alexFaunt / transaction-observer.swift
Created June 17, 2018 12:19
Transaction observer example
switch transaction.transactionState {
case .purchased:
if let appStoreReceiptURL = Bundle.main.appStoreReceiptURL,
FileManager.default.fileExists(atPath: appStoreReceiptURL.path) {
let rawReceiptData = Data(contentsOf: appStoreReceiptURL)
let receiptData = rawReceiptData.base64EncodedString(options: ...)
currentUser.processTransaction(receiptData) { isValid in
@alexFaunt
alexFaunt / verify-receipt.js
Last active April 12, 2019 00:44
Example JS to verify an app store receipt
async verifyReceipt(encodedReceipt) {
const body = JSON.stringify({
'receipt-data': encodedReceipt,
// Set in App Store Connect
password: process.env.APP_STORE_SECRET,
// This means Apple only returns the latest receipt info instead of all transactions.
'exclude-old-transactions': true,
@alexFaunt
alexFaunt / cancel-event.js
Last active June 17, 2018 14:23
Example of an Apple cancel event
{
"notification_type": "CANCEL",
"environment": "Sandbox",
"password": "APP_STORE_SECRET",
/* The date in milliseconds at which the user cancelled */
"cancellation_date_ms": "1528309241000",
/* The latest receipt information, now expired, but you should still update it in your DB */
"latest_expired_receipt": "ewoJVEU1nYXhZO...UNhb2LIjsKfQ==",
{
"notification_type": "RENEWAL",
"environment": "Sandbox",
"password": "APP_STORE_SECRET",
/* The latest receipt information, you should update it in your DB */
"latest_receipt": "ewodnNpZ25...iMCI3d37Cn0=",
/* The decoded information form the latest receipt - an object not array in notifications */
"latest_receipt_info": {
@alexFaunt
alexFaunt / SweepstakeTable.js
Created July 21, 2018 10:32
Turn sweepstake teams + results into aggregate table
// Results
const groupStages = [
['Russia', 5, 0, 'Saudi Arabia'],
['Egypt', 0, 1, 'Uruguay'],
['Morocco', 0, 1, 'Iran'],
['Portugal', 3, 3, 'Spain'],
['France', 2, 1, 'Australia'],
['Argentina', 1, 1, 'Iceland'],
['Peru', 0, 1, 'Denmark'],
['Croatia', 2, 0, 'Nigeria'],
const createModelHelpers = (model) => {
const query = (trx) => model.query(trx).withSchema('workout');
const getById = ({ trx, id }) => query(trx).findById(id);
const insert = async ({ trx, input }) => query(trx).insert(input).returning('*');
return {
query,
@alexFaunt
alexFaunt / Query.md
Last active February 28, 2019 16:52

Example mapping

{
  properties: {
    key: { type: 'keyword' },
    title: { type: 'text' },
    
    releases: {
 type: 'nested',
query1 = `
mutation {
startStreamableWorkout(input: { exerciseSchemaVersion: 1.0 }) {
workout {
exerciseSchema {
version
schema
}
}
}