# 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 `
` tag. ## Installation Install stripe-opal from RubyGems: ``` $ gem install stripe-opal ``` Or include it in your Gemfile for Bundler: ```ruby gem 'stripe-opal' ``` ## License (The MIT License) Copyright (C) 2015 by Rick Carlino Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.