Skip to content

Instantly share code, notes, and snippets.

Thorsten Schaeff tschaeff

Block or report user

Report or block tschaeff

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View customer.erb
<h1><%= %> // <%= %></h1>
<h2># Subscriptions: <%= @customer.subscriptions.total_count %></h2>
<% @customer.subscriptions.each do |sub| %>
<li><%= %></li>
View app.rb
get '/customer/:cid' do
# Output params hash in bash
puts params.inspect
# Retrieve customer ID from params hash
cid = params[:cid]
# Retrieve customer object from Stripe API
# Store customer object in an instance variable
@customer = Stripe::Customer.retrieve(cid)
View customers.erb
<% @c.each do |customer| %>
<td><%= %><td>
<td><%= %></td>
<td><a href="../customer/<%= %>">Subscriptions [<%= customer.subscriptions.total_count %>] </a></td>
<% end %>
View app.rb
get '/customers' do
# Get a list of ten customers
customers = Stripe::Customer.all(:limit => 10)
# Store customer list in an instance variable
@c =
#Output customers.erb template to user
erb :customers
View app.rb
post '/charge' do
# Output the params hash with the values from Checkout in the bash
puts params.inspect
# Store Stripe Token and Customer Email Address in local variables
token = params[:stripeToken]
email = params[:stripeEmail]
# Create a new Customer
# Store the Response in a local variable
View index.erb
<form action="/charge" method="POST">
src="" class="stripe-button"
data-description="2 widgets"
tschaeff / app.rb
Last active May 15, 2016
Advanced Stripe Integration Training: Customers + Subscriptions
View app.rb
require 'sinatra'
require 'sinatra/reloader' if development?
require "stripe"
Stripe.api_key = "sk_test_***"
get '/' do
# Output index.erb template to user
erb :index
tschaeff /
Last active May 15, 2016 — forked from caseywatts/Gemfile
Sinatra + Stripe on Cloud9

Cloud 9 - Sinatra + Stripe

Setting Up Cloud9

  • Go to and log in
  • Create a new workspace
    • Workspace name = hello-stripe
    • Clone from Git or Mercurial URL =
    • (everything else at defaults)
tschaeff / stripe_one_time_charge.php
Last active Aug 11, 2019
Best practice example for creating one time charges using Stripe.js and Stripe's PHP bindings without creating customer objects.
View stripe_one_time_charge.php
<!DOCTYPE html>
<html lang="en">
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>One Time Charge</title>
<script type="text/javascript" src=""></script>
You can’t perform that action at this time.