Ask A Question

Notifications

You’re not receiving notifications from this thread.

How do I add the amount stored in my database to Braintree::Transaction.Sale?

RicePad asked in Ruby

Hi all, I'm new to this community and also new to Ruby on Rails. I recently watched the Braintree integration screencast by Chris and I've been playing around with its Sand box integration.

I was able to make a successful check out with a hard coded amount i.e:

        def checkout
            nonce = params[:payment_method_nonce]
            result = Braintree::Transaction.sale(
             ** :amount => "15.00",**
            :payment_method_nonce => nonce,
            :options => {
            :submit_for_settlement => true} )
     end

Let's say I want a current_user to be able to purchase access to my portofolio for a specific "price" which has been stored in the database. Is there a way to set the amount by pulling it from an a object's attributes from the database i.e: "<=@portofolio_item.price>" ?? I've tried multiple attempts and didn't have any luck. I feel like I'm not understanding how Braintree really works.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 87,400+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.