Module: AlphaCard

Defined in:
lib/alpha_card.rb,
lib/alpha_card/sale.rb,
lib/alpha_card/order.rb,
lib/alpha_card/account.rb,
lib/alpha_card/billing.rb,
lib/alpha_card/shipping.rb,
lib/alpha_card/alpha_card_error.rb,
lib/alpha_card/alpha_card_object.rb,
lib/alpha_card/alpha_card_response.rb

Defined Under Namespace

Classes: Account, AlphaCardError, AlphaCardObject, AlphaCardResponse, Billing, Order, Sale, Shipping

Constant Summary collapse

CREDIT_CARD_CODES =

Global Payment Systems (NDC) Credit Card Authorization Codes

YAML.load_file(File.expand_path('../alpha_card/data/codes.yml', __FILE__))

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_baseObject

Returns the value of attribute api_base.



25
26
27
# File 'lib/alpha_card.rb', line 25

def api_base
  @api_base
end

Class Method Details

.request(params = {}, account) ⇒ Object

AlphaCard.request(params, account) -> AlphaCardResponse

Do the POST request to the AlphaCard Gateway with params from specified AlphaCard account.

 = AlphaCard::Account.new('user', 'pass')
params = {amount: '10.00'}
r = AlphaCard.request(params, ) #=> AlphaCardResponse


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/alpha_card.rb', line 36

def self.request(params = {}, )
  unless .filled?
    raise AlphaCardError.new('You must set credentials to create the sale!')
  end

  begin
    response = RestClient.post(@api_base, params.merge(.attributes))
  rescue => e
    handle_connection_errors(e)
  end

  alpha_card_response = AlphaCardResponse.new(response.to_str)
  handle_alpha_card_errors(alpha_card_response)

  alpha_card_response
end