Class: AlphaCard::Sale

Inherits:
Transaction show all
Defined in:
lib/alpha_card/transactions/sale.rb

Overview

Implementation of Alpha Card Services Sale transaction. Contains all the information about Customer Credit Card, such as CVV, number, expiration date, etc. Process the Alpha Card Services payment.

Direct Known Subclasses

Auth, Credit, Validate

Constant Summary collapse

ORIGIN_TRANSACTION_VARIABLES =

Original AlphaCard transaction variables names

{
  card_expiration_date: :ccexp,
  card_number: :ccnumber,
  check_name: :checkname,
  check_aba: :checkaba,
  check_account: :checkaccount
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#attributes_for_request

Methods included from Attribute

included

Instance Attribute Details

#typeObject (readonly)

Transaction type (default is ‘sale’)



34
# File 'lib/alpha_card/transactions/sale.rb', line 34

attribute :type, default: 'sale', writeable: false

Instance Method Details

#paymentObject

Payment type. Values: ‘creditcard’ or ‘check’



28
# File 'lib/alpha_card/transactions/sale.rb', line 28

attribute :payment, default: 'creditcard', values: %w(creditcard check).freeze

#process(order, credentials = Account.credentials) ⇒ AlphaCard::Response Also known as: create

Creates the sale transaction for the specified AlphaCard::Order.

Examples:

order = AlphaCard::Order.new(id: 1, description: 'Test order')
sale = AlphaCard::Sale.new(card_expiration_date: '0117', card_number: '4111111111111111', amount: '5.00' )
sale.create(order)

#=> #<AlphaCard::Response:0x1a0fda ...>

Parameters:

  • order (AlphaCard::Order)

    An AlphaCard::Order object.

  • credentials (Hash) (defaults to: Account.credentials)

    Alpha Card merchant account credentials.

Returns:

  • (AlphaCard::Response)

    AlphaCard Gateway response with all the information about transaction.

Raises:

  • (AlphaCard::InvalidObjectError)

    Exception if one of required attributes doesn’t specified.



67
68
69
70
71
# File 'lib/alpha_card/transactions/sale.rb', line 67

def process(order, credentials = Account.credentials)
  validate_required_attributes!

  AlphaCard.request(params_for_sale(order), credentials)
end