You are seeing this error, well, because there is no method or local variable basket
in your model. So, either:
a) Define a method that returns the basket object:
def basket
# some logic here to return basket.
end
b) Pass in the basket to your method:
def purchase(basket)
response = GATEWAY.purchase(Product.total_basket_price(basket), credit_card, purchase_options)
end
c) Or, if you are working within an instance of Basket
, pass in the instance as self
instead of basket
.
response = GATEWAY.purchase(Product.total_basket_price(self), credit_card, purchase_options)