Module: AstroPay

Defined in:
lib/astro_pay/card.rb,
lib/astro_pay.rb,
lib/astro_pay/curl.rb,
lib/astro_pay/model.rb,
lib/astro_pay/direct.rb,
lib/astro_pay/version.rb,
lib/astro_pay/configuration.rb

Overview

Class of AstroPay Direct

@author Luis Galaviz ([email protected])

Defined Under Namespace

Classes: Card, Configuration, Curl, Direct, Model

Constant Summary collapse

VERSION =
"0.0.3"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationAstroPay::Configuration

Gets the configuration attribute.

Returns:



29
30
31
# File 'lib/astro_pay.rb', line 29

def self.configuration
  @configuration ||= Configuration.new
end

Class Method Details

.card(*args) ⇒ AstroPay::Card

Gets a new [AstroPay::Card] instance with the given arguments.

Returns:



50
51
52
# File 'lib/astro_pay.rb', line 50

def self.card(*args)
  Card.new(*args)
end

.configure {|configuration| ... } ⇒ Object

Allows to set the configuration passing a block where the values are set.

Yields:



34
35
36
# File 'lib/astro_pay.rb', line 34

def self.configure
  yield(configuration)
end

.create_card(number, ccv, exp_date, amount, unique_id, invoice_num, additional_params = {}) ⇒ AstroPay::Card

Gets a new [AstroPay::Card] instance with the given arguments and some optional values. See the AstroPay Card Manual.

Parameters:

  • number (String)

    AstroPay Card number.

  • ccv (Int)

    AstroPay Card security code.

  • exp_date (String)

    expiration date of AstroPay Card. Format: MM/YYYY

  • amount (Float)

    transaction amount.

  • bank (String)

    bank code.

  • unique_id (String)

    unique, anonymized identifier of users in the merchant system.

  • invoice_num (String)

    unique identifier of merchant transaction.

  • additional_params (Hash) (defaults to: {})

    other arguments.

Returns:



91
92
93
94
95
96
97
98
99
100
101
# File 'lib/astro_pay.rb', line 91

def self.create_card(number, ccv, exp_date, amount, unique_id, invoice_num, additional_params={})
  card(
    number: number,
    ccv: ccv,
    exp_date: exp_date,
    amount: amount,
    unique_id: unique_id,
    invoice_num: invoice_num,
    additional_params: additional_params
  ).auth_capture_transaction
end

.create_direct(invoice, amount, iduser, country, bank = '', sub_code = 1, args = {}) ⇒ AstroPay::Direct

Gets a new [AstroPay::Direct] instance with the given arguments and some optional values. See the AstroPay Direct Manual.

Parameters:

  • invoice (String)

    unique transaction ID number at the merchant.

  • amount (Float)

    the amount of the payment.

  • iduser (String)

    user’s unique ID at the merchant / account number.

  • country (String)

    country code.

  • bank (String) (defaults to: '')

    bank code.

  • sub_code (Int) (defaults to: 1)

    mandatory parameter for PSPs.

  • args (Hash) (defaults to: {})

    Other arguments.

Returns:



65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/astro_pay.rb', line 65

def self.create_direct(invoice, amount, iduser, country, bank='', sub_code=1, args={})
  direct(
    args.merge(
      invoice: invoice,
      amount: amount,
      iduser: iduser,
      bank: bank,
      country: country,
      sub_code: sub_code
    )
  ).create
end

.direct(*args) ⇒ AstroPay::Direct

Gets a new [AstroPay::Direct] instance with the given arguments.

Parameters:

  • args (Array)

    (See AstroPay::Direct#initialize).

Returns:



42
43
44
# File 'lib/astro_pay.rb', line 42

def self.direct(*args)
  Direct.new(*args)
end