# Unofficial Stripe.JS wrapper for Opal `stripe-opal` provides credit card payment capabilities to opal by wrapping Stripe.js and providing a nice ruby syntax for dealing with card payments. ## Note This is an unofficial Gem and I don't work for Stripe. The gem is maintained, but not officially supported or endorsed by Stripe. ## Getting Started ### Usage Add this to `app/main/config/dependencies.rb` for your **Volt Project**: ```ruby javascript_file "https://js.stripe.com/v2/" ``` OR, if you are writing a **static app that does not use Volt, but uses Opal**: ```html ``` THEN Make this HTML form... ```html
``` And run payments like this: ```ruby StripeOpal::Card .get_token('#payment-form') # Notice the ID on the form above? .then { |token| "Pass the `token.id` to a Volt::Task or AJAX call" } .fail { |error| "Tell the user they put bad info in." } ``` If you are developing a [Volt Framework](http://www.voltframework.com) app, it's best to put the code above in a controller method ``` def pay_from_controller StripeOpal::Card .get_token('#payment-form') # Notice the ID on the form above? .then { |token| "Pass the `token.id` to a Volt::Task or AJAX call" } .fail { |error| "Tell the user they put bad info in." } end ``` and add `e-submit="pay_from_controller"` to the `