- Go to
c9.ioand log in - Create a new workspace
Workspace name=hello-stripeClone from Git or Mercurial URL=https://gist.github.com/f71ef966f488ab8fd984e0791cf96c07.git- (everything else at defaults)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT | |
| pickup_polyId, | |
| SUM(fare_amount)/COUNT(*) AS average_fare, | |
| COUNT(*) AS no_of_trips | |
| FROM | |
| [nyctaximap:dataflow.nyc_output_join_fare_distinct] | |
| WHERE | |
| fare_amount!=0 | |
| GROUP BY | |
| pickup_polyId |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT | |
| pickup_polyId, | |
| COUNT(*) AS no_of_trips | |
| FROM | |
| [nyctaximap:dataflow.nyc_output_join_fare_distinct] | |
| GROUP BY | |
| pickup_polyId | |
| ORDER BY | |
| no_of_trips DESC; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT | |
| pickup_polyId, | |
| SUM(fare_amount)/COUNT(*) AS average_fare, | |
| COUNT(*) AS no_of_trips | |
| FROM | |
| [nyctaximap:dataflow.nyc_output_join_fare_distinct] | |
| WHERE | |
| fare_amount!=0 | |
| GROUP BY | |
| pickup_polyId |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div id="log"></div> | |
| <script type="text/javascript" src="https://dl.dropboxusercontent.com/sh/oexkzj4z2zzs02d/AADB02b-GUnvoxDr9EvD61yZa/adyen.encrypt.nodom.min.js"></script> | |
| <script src="https://js.braintreegateway.com/js/braintree-2.22.2.min.js"></script> | |
| <script type="text/javascript" src="https://js.stripe.com/v2/"></script> | |
| <script type="text/javascript"> | |
| (function() { | |
| //Copy your public keys here | |
| var stripePK = "pk_test_jg6c4WIhuzDD7kcYW0Nu7T6r"; | |
| var adyenPK = "10001|B01FDAF7CD9B73F094906C5B078963FAAE57AFC619D561EFC784EA505EC6CCA94AF0CA3F97CA9CFC04E2151F39A461BF45DE7CB7DEA46C56EB3420502DA69BF4A6FFA21464D46861051367A26422EF3A9E6288F821CB47E8F88B4C2D9BEEF96AF0686E6F1C4171C5B5BD1C80E23A112BE57B990389E783B8F614F07CDBBBB68D7175F0282C7E0FA985D881E2A9EB6B54BE231D5733912A217F92D5952C6AA1ECF1765F11337441502FFCDD9B9DD3F2A40F98E96DDF51E60B06D8987D3622EB119AF7360055626DC99E6555724FBBFC1F985DB506E16E6A9B040959799C3C6ADD7F21C97493D7823CE7A234491377165815CE075ED55375F772F101DA0335D70D"; | |
| var brainTreePK |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <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="https://js.stripe.com/v2/"></script> | |
| </head> | |
| <body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'sinatra' | |
| require 'sinatra/reloader' if development? | |
| require "stripe" | |
| Stripe.api_key = "sk_test_***" | |
| get '/' do | |
| # Output index.erb template to user | |
| erb :index | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <form action="/charge" method="POST"> | |
| <script | |
| src="https://checkout.stripe.com/checkout.js" class="stripe-button" | |
| data-key="pk_test_****" | |
| data-amount="2000" | |
| data-name="schaeffonline.de" | |
| data-description="2 widgets" | |
| data-image="https://cdn.shopify.com/s/files/1/0302/2969/products/great-cookie-m_and_m-cookie-03_1024x1024.jpg" | |
| data-locale="auto" | |
| data-zip-code="true" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| get '/customers' do | |
| # Get a list of ten customers | |
| customers = Stripe::Customer.all(:limit => 10) | |
| # Store customer list in an instance variable | |
| @c = customers.data | |
| #Output customers.erb template to user | |
| erb :customers | |
| end |