Class: AlphaCard::Sale
- Inherits:
-
AlphaCardObject
- Object
- AlphaCardObject
- AlphaCard::Sale
- Defined in:
- lib/alpha_card/sale.rb
Instance Method Summary collapse
-
#create(order, account) ⇒ Object
create(order, account) -> true create(order, account) -> false create(order, account) -> Exception.
Methods inherited from AlphaCardObject
Instance Method Details
#create(order, account) ⇒ Object
create(order, account) -> true create(order, account) -> false create(order, account) -> Exception
Creates the sale for the order with specified attributes, such as ccexp, ccnumber, amount and cvv.
attrs = {ccexp: '0117', ccnumber: '123', amount: '10.00'}
sale = AlphaCard::Sale.new(attrs)
sale.create(order, account) #=> true or false
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/alpha_card/sale.rb', line 22 def create(order, account) [:ccexp, :ccnumber, :amount].each do |attr| raise Exception.new("No #{attr} information provided") if self[attr].blank? end params = self.filled_attributes || {} [order, order.billing, order.shipping].compact.each { |obj| params.merge!(obj.try(:filled_attributes)) } AlphaCard.request(params, account).success? end |