Last active
May 1, 2016 20:00
-
-
Save jb41/ca6ac22d5578389fbcfb6945b923e5d6 to your computer and use it in GitHub Desktop.
copyfixes.com
This file contains 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 'json' | |
require 'httparty' | |
def add_email_to_spreadsheet(email) | |
HTTParty.post( | |
'https://sheetsu.com/apis/v1.0/c12aec61', | |
body: { email: email }.to_json, | |
headers: { 'Content-Type' => 'application/json', 'Accept' => 'application/json'} | |
).body | |
end |
This file contains 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 'pry' | |
require 'json' | |
require 'httparty' | |
require 'stripe' | |
class ChargeApp < Sinatra::Base | |
AMOUNT = 300 | |
Stripe.api_key = "SECRET_STRIPE_KEY" | |
post '/charge' do | |
status = charge_customer(stripe_token, stripe_email) | |
add_email_to_spreadsheet(stripe_email) if status == 'succeeded' | |
content_type :json | |
{ transaction_status: status }.to_json | |
end | |
not_found do | |
status 404 | |
'<h1 style="text-align: center;">404<br>No such page.</h1>' | |
end | |
protected | |
def charge_customer(token, customer_email) | |
begin | |
customer = create_customer(token, customer_email) | |
payment = create_payment(customer.id) | |
rescue Exception => e | |
end | |
payment.status | |
end | |
def create_customer(token, email) | |
Stripe::Customer.create( | |
source: token, | |
description: "#{email}" | |
) | |
end | |
def create_payment(customer_id) | |
Stripe::Charge.create( | |
amount: AMOUNT, | |
currency: 'usd', | |
customer: customer_id | |
) | |
end | |
def stripe_token | |
params[:stripeToken] | |
end | |
def stripe_email | |
params[:stripeEmail] | |
end | |
def add_email_to_spreadsheet(email) | |
HTTParty.post( | |
'https://sheetsu.com/apis/v1.0/1521d646', | |
body: { email: email }.to_json, | |
headers: { 'Content-Type' => 'application/json', 'Accept' => 'application/json'} | |
).body | |
end | |
end |
This file contains 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 'json' | |
require 'stripe' | |
class ChargeApp < Sinatra::Base | |
AMOUNT = 300 | |
Stripe.api_key = "SECRET_STRIPE_API_KEY" | |
post '/charge' do | |
status = charge_customer(params[:stripeToken, params[:stripeEmail]) | |
content_type :json | |
{ transaction_status: status }.to_json | |
end | |
protected | |
def charge_customer(token, customer_email) | |
begin | |
customer = create_customer(token, customer_email) | |
payment = create_payment(customer.id) | |
rescue Exception => e | |
end | |
payment.status | |
end | |
def create_customer(token, email) | |
Stripe::Customer.create( | |
source: token, | |
description: "#{email}" | |
) | |
end | |
def create_payment(customer_id) | |
Stripe::Charge.create( | |
amount: AMOUNT, | |
currency: 'usd', | |
customer: customer_id | |
) | |
end | |
end |
This file contains 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
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>CopyFixes.com - Quick fixes of your copywriting from professionals</title> | |
</head> | |
<body> | |
<section> | |
<h1>CopyFixes.com</h1> | |
<h2>Quick fixes of your copywriting by professionals</h2> | |
<ul class="steps"> | |
<li>1. Send an email to <a href="mailto:ineed@copyfixes.com">ineed@copyfixes.com</a></li> | |
<li>2. Get offers from professionals with prices</li> | |
<li>3. Pick any and contact them</li> | |
<li>4. Publish your awesome copy!</li> | |
</ul> | |
</section> | |
<section> | |
<h2 class="question">Are you a copywriter?</h2> | |
<a href="requests.html" class="show-reqs-button">Check requests!</a> | |
</section> | |
<section> | |
<h2>About this website</h2> | |
</section> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment