-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubscription.rb
31 lines (22 loc) · 880 Bytes
/
subscription.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'dotenv'
require 'stripe'
Dotenv.load("#{File.dirname(__FILE__)}/.env")
require_relative "config"
Stripe.api_key = ENV['STRIPE_SECRET_KEY']
config = Healp::Config.new(ENV['CLIENT_ID'],ENV['CLIENT_SECRET'],ENV['AUTH_URL'])
client = OAuth2::Client.new(config.client_id, config.client_secret, :site => config.oauth_url)
access_token = client.password.get_token('[email protected]', "}S'+<01o")
puts access_token.token
card = Stripe::Token.create(
:card => {
:number => "4242424242424242",
:exp_month => 12,
:exp_year => 2017,
:cvc => "314"
}
)
stripe_token = card.id
puts "card id: #{stripe_token}"
response = RestClient.post "#{config.oauth_url}/patient/subscriptions", {"access_token" => access_token.token,"stripe_token" => stripe_token, "coupon"=> 'coupon1111'
}, {:content_type => 'application/json', :accept => :json}
p JSON.parse(response.body)