I was able to make a successful check out with a hard coded amount i.e:
def checkout nonce = params["payment_method_nonce"] if current_user.braintree_id? customer = Braintree::Customer.find(current_user.braintree_id) else @result = Braintree::Customer.create( email: current_user.email, payment_method_nonce: params[:payment_method_nonce] ) customer = result.customer current_user.update(braintree_id: customer.id) end @result = Braintree::Transaction.sale( amount: **"10.00"**, payment_method_nonce: nonce ) if @result.success? redirect_to root_path, notice: "You have successfully checked out" else flash[:alert] = "Something went wrong while processing your transaction" render :new end end
Let's say I want a current_user to be able to purchase access to my portfolio for a specific "price" which has been stored inside my rails 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 lucks. What could I be doing wrong?