Search code examples
ruby-on-railsbalanced-payments

Setting up balanced payments with Rails


I'm trying to start using balanced payments as a payment platform. I'm using rails so I did the gem install gem "balanced" but I know I have to also include the balanced.js to send credit card information. My question is does that gem automatically add balanced.js to the asset pipeline and then I simply reference it in the javascript/application.js //= require balaced.js ?

Or must I download balanced.js and include it in the asset pipeline?

Any sort of information would be great as I am new to using API's in rails thanks!


Solution

  • AFAIK the balanced gem is just a ruby wrapper that provides you with convenience methods for hitting their API so that you don't have to make raw HTTP requests.

    If you don't want to download balanced.js, you can just include it in app/views/layout/application.html.erb as they recommend in their documentation:

    <script type="text/javascript" src="https://js.balancedpayments.com/v1/balanced.js"></script>
    

    This jsFiddle, also from the documentation, contains a working demo with all the html and javascript needed for functional credit card tokenization.