Skip to content

Instantly share code, notes, and snippets.

View cjavilla-stripe's full-sized avatar

CJ Avilla cjavilla-stripe

View GitHub Profile
@cjavilla-stripe
cjavilla-stripe / index.php
Created December 11, 2020 19:11
Simple one button Checkout with php
<?php
require_once('vendor/autoload.php');
\Stripe\Stripe::setApiKey('sk_test_...');
$session = \Stripe\Checkout\Session::create([
'payment_method_types' => ['card'],
'line_items' => [[
'price_data' => [
'currency' => 'usd',
{
"Working Directory" : "\/Users\/cjavilla\/",
"Prompt Before Closing 2" : false,
"Selected Text Color" : {
"Red Component" : 0.92941176470588238,
"Color Space" : "sRGB",
"Blue Component" : 1,
"Alpha Component" : 1,
"Green Component" : 0.92941176470588238
},
{
"Working Directory" : "/",
"Prompt Before Closing 2" : false,
"Selected Text Color" : {
"Red Component" : 0.91764705882352937,
"Color Space" : "sRGB",
"Blue Component" : 0.98431372549019602,
"Alpha Component" : 1,
"Green Component" : 0.94117647058823528
},
@cjavilla-stripe
cjavilla-stripe / Dockerfile
Last active August 27, 2020 21:26
Stripe Samples Dokku Dockerfile
# Use Node 14
FROM node:14 AS build
# Create a folder for our app, and it's client.
RUN mkdir /app
RUN mkdir /app/client
# Set up the working directory
WORKDIR /app
const http = require('http');
const hostname = 'localhost';
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World!\n');
});

See the setup.js file below which shows how to create the right kinds of products and prices. The report.js file shows how the periodic usage reporting would work.

In order to use a model where a new invoice is cut every time usage reaches a threshold, but also to support the case where we can handle decreasing usage over time, we have to take a hybrid approach where we keep track of how many images are already paid for in a given period, and only report usage over that amount.

#!/usr/bin/ruby
require 'octokit'
require 'dotenv'
require 'restclient'
require 'json'
Dotenv.load('.env_shortcut')
GITHUB = "https://raw.githubusercontent.com/%s/master/.cli.json"
#!/usr/bin/ruby
require 'octokit'
require 'dotenv'
require 'restclient'
require 'json'
Dotenv.load('.env_shortcut')
GITHUB = "https://raw.githubusercontent.com/%s/master/.cli.json"
package main
import (
"fmt"
)
func a(x chan int) {
fmt.Println("a")
x <- 9
}
// ------ py
class Robot:
# `self` in python is the instance
def move_forward(self, spaces=1):
print('Moving forward %d spaces' % (spaces))
r = Robot()
r.move_forward(2)
// ----- go
type Robot struct {}