Last active
June 2, 2016 21:13
-
-
Save dohoonk/44f268440d1684aada9b42d7e5f32ac5 to your computer and use it in GitHub Desktop.
Stripe Integration
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
After setting up stripe account | |
grab the api key | |
1. | |
In your secrets.yml | |
stripe_secret_key: dsfadasfsadfsadfdsa | |
stripe_publishable_key: sdafdsafdsafdsafdsafsdaf | |
publishable_key is key needed to decode and can be displayed in javascript code | |
2. | |
go to stripe javascript api | |
-Custom Forms | |
grab the javascript code under collecting credit card infoand paste in the erb file | |
3. | |
Set the publishable key | |
copy the key under stripe api code | |
```ruby | |
<%= Rails.application.secrets.stripe_publishable_key%> | |
``` | |
4. | |
Create a single use token | |
use form_tag as the token does not need to be sent to rails server | |
``` ruby | |
<%= form_tag "", id: "payment-form" do %> | |
<div class="form-group"> | |
<%= label_tag :card_number %> | |
<%= text_field :card_number, nil, data: {stripe: :number}, class: "form-control" %> | |
</div> | |
<div class="form-group"> | |
<%= label_tag :expiration %> | |
<%= select_month Date.today, {use_month_numbers: true}, {data: {stripe :exp_month}, class: "form-control"} %> | |
<%= select_year Date.today, {start_year: Date.today.year, end_year: Date.today.year + 15}{use_year_numbers: true}, {data: {stripe :exp_year}, class: "form-control"} %> | |
</div> | |
<div class="form-group"> | |
<%= label_tag :cvc_number %> | |
<%= text_field :cvc, nil, data: {stripe: :cvc}, class: "form-control" %> | |
</div> | |
<div class="form-group"> | |
<%= submit_tag "Make a payment", class: "btn btn-primary" %> | |
</div> | |
<% end %> | |
``` | |
5. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment