Skip to content

Instantly share code, notes, and snippets.

View cjavilla-stripe's full-sized avatar

CJ Avilla cjavilla-stripe

View GitHub Profile
@app.route('/create-checkout-session', methods=['POST'])
def create_checkout_session():
checkout_session = stripe.checkout.Session.create(
'price': '<hard code your price ID here>',
'quantity': 1,
cjavilla-stripe / tailwind-issuing-elements.html
Created August 12, 2022 21:27
Tailwind CSS to build a visualization for Stripe Issuing Elements
<div class="w-96 h-56 m-auto bg-red-100 rounded-xl relative text-white shadow-2xl transition-transform transform hover:scale-110">
<div class="relative object-cover w-full h-full rounded-xl bg-gradient-to-r from-teal-400 to-blue-400" ></div>
<div class="w-full px-8 absolute top-8">
<div class="flex justify-between">
<span class="font-light">Name</span>
<p id="cardholder-name" class="font-medium tracking-widest">
Jenny Rosen
#card-back {
position: relative;
width: 384px;
height: 244px;
background-image: url("/assets/card-back.png");
background-size: 100%;
background-repeat: no-repeat;
#card-details {
require 'stripe'
Stripe.api_key = ENV['STRIPE_SECRET_KEY']
def date_description(dates)
def next_dates
# some database stuff
[start_date, end_date]
const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);
* Next available dates loaded from some database
const calendar = require('./data/calendar.json');
exports.handler = async (event) => {
const nextDates = getNextDates(calendar)
const { startDate, endDate } = nextDates;
cjavilla-stripe / webhooks.tsx
Created March 25, 2022 13:11
Handle Stripe webhooks in Remix
import Stripe from 'stripe'
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY)
export const action = async ({request}) => {
const secret = 'whsec_...' // process.env.WEBHOOK_SIGNING_SECRET
const sig = request.headers.get('stripe-signature')
let event;
const payload = await request.text()
"_meta": {
"template_version": 0
"fixtures": [
"name": "location",
"path": "/v1/terminal/locations",
"method": "post",
"params": {
cjavilla-stripe / invoicing.ipynb
Last active March 25, 2022 21:10
New simplified invoice creation flow
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
class SubscriptionsController < ApplicationController
def new
@customer = Stripe::Customer.create
@subscription = Stripe::Subscription.create(
items: [{
price: 'price_1KW5LPG3pPSOzbKUr6hQmTAr',
payment_behavior: 'default_incomplete',
expand: ['latest_invoice.payment_intent']
cjavilla-stripe / user.rb
Created February 17, 2022 14:44
Create the connect and financial accounts for the user lazily, any time they are committed to db
# After commit, we always check to make sure each user has both
# a Stripe Account and a Financial Account for that Stripe Account.
after_commit :ensure_stripe_account
after_commit :ensure_stripe_financial_account
def ensure_stripe_account
return if stripe_account_id.present?
# Create the Connected account
# This must be a custom connect account, but for