class AlphaCard::Sale
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.
Constants
- ORIGIN_TRANSACTION_VARIABLES
Original
AlphaCard
transaction variables names
Public Instance Methods
payment()
click to toggle source
Payment type. Values: 'creditcard' or 'check'
# File lib/alpha_card/transactions/sale.rb, line 28 attribute :payment, default: 'creditcard', values: %w(creditcard check).freeze
process(order, credentials = Account.credentials)
click to toggle source
Creates the sale transaction for the specified AlphaCard::Order
.
@param order [AlphaCard::Order]
An <code>AlphaCard::Order</code> object.
@param credentials [Hash]
Alpha Card merchant account credentials.
@return [AlphaCard::Response]
AlphaCard Gateway response with all the information about transaction.
@raise [AlphaCard::InvalidObjectError]
Exception if one of required attributes doesn't specified.
@example
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 ...>
# 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
Also aliased as: create
type()
click to toggle source
Transaction
type (default is 'sale')
@attribute [r] type
# File lib/alpha_card/transactions/sale.rb, line 34 attribute :type, default: 'sale', writeable: false
Private Instance Methods
params_for_sale(order)
click to toggle source
Returns all the necessary attributes with it's original names that must be passed with Sale
transaction.
@param order [AlphaCard::Order]
An <code>AlphaCard::Order</code> object.
@return [Hash]
Params of *self* object merged with params of another object (<code>AlphaCard::Order</code>)
# File lib/alpha_card/transactions/sale.rb, line 87 def params_for_sale(order) attributes_for_request.merge(order.attributes_for_request) end