Class: ActiveMerchant::Billing::MoneiGateway

Inherits:
Gateway
  • Object
show all
Defined in:
lib/active_merchant/billing/gateways/monei.rb

Overview

Monei gateway

This class implements Monei gateway for Active Merchant. For more information about Monei gateway please go to www.monei.com

Setup

In order to set-up the gateway you need only one paramater: the api_key Request that data to Monei.

Constant Summary

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#add_field_to_post_if_present, #add_fields_to_post_if_present, #card_brand, card_brand, #generate_unique_id, inherited, #supported_countries, supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #test?

Methods included from CreditCardFormatting

#expdate, #format

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Constructor Details

#initialize(options = {}) ⇒ MoneiGateway

Constructor

options - Hash containing the gateway credentials, ALL MANDATORY

:api_key      Account's API KEY


29
30
31
32
# File 'lib/active_merchant/billing/gateways/monei.rb', line 29

def initialize(options = {})
  requires!(options, :api_key)
  super
end

Instance Method Details

#authorize(money, payment_method, options = {}) ⇒ Object

Public: Performs authorization operation

money - Amount to authorize payment_method - Credit card options - Hash containing authorization options

:order_id         Merchant created id for the authorization
:billing_address  Hash with billing address information
:description      Merchant created authorization description (optional)
:currency         Sale currency to override money object or default (optional)

Returns Active Merchant response object



60
61
62
# File 'lib/active_merchant/billing/gateways/monei.rb', line 60

def authorize(money, payment_method, options = {})
  execute_new_order(:authorize, money, payment_method, options)
end

#capture(money, authorization, options = {}) ⇒ Object

Public: Performs capture operation on previous authorization

money - Amount to capture authorization - Reference to previous authorization, obtained from response object returned by authorize options - Hash containing capture options

:order_id         Merchant created id for the authorization (optional)
:description      Merchant created authorization description (optional)
:currency         Sale currency to override money object or default (optional)

Note: you should pass either order_id or description

Returns Active Merchant response object



76
77
78
# File 'lib/active_merchant/billing/gateways/monei.rb', line 76

def capture(money, authorization, options = {})
  execute_dependant(:capture, money, authorization, options)
end

#purchase(money, payment_method, options = {}) ⇒ Object

Public: Performs purchase operation

money - Amount of purchase payment_method - Credit card options - Hash containing purchase options

:order_id         Merchant created id for the purchase
:billing_address  Hash with billing address information
:description      Merchant created purchase description (optional)
:currency         Sale currency to override money object or default (optional)

Returns Active Merchant response object



45
46
47
# File 'lib/active_merchant/billing/gateways/monei.rb', line 45

def purchase(money, payment_method, options = {})
  execute_new_order(:purchase, money, payment_method, options)
end

#refund(money, authorization, options = {}) ⇒ Object

Public: Refunds from previous purchase

money - Amount to refund authorization - Reference to previous purchase, obtained from response object returned by purchase options - Hash containing refund options

:order_id         Merchant created id for the authorization (optional)
:description      Merchant created authorization description (optional)
:currency         Sale currency to override money object or default (optional)

Note: you should pass either order_id or description

Returns Active Merchant response object



92
93
94
# File 'lib/active_merchant/billing/gateways/monei.rb', line 92

def refund(money, authorization, options = {})
  execute_dependant(:refund, money, authorization, options)
end

#scrub(transcript) ⇒ Object



132
133
134
135
136
137
138
# File 'lib/active_merchant/billing/gateways/monei.rb', line 132

def scrub(transcript)
  transcript.
    gsub(%r((Authorization: )\w+), '\1[FILTERED]').
    gsub(%r(("number\\?":\\?")[^"]*)i, '\1[FILTERED]').
    gsub(%r(("cvc\\?":\\?")[^"]*)i, '\1[FILTERED]').
    gsub(%r(("cavv\\?":\\?")[^"]*)i, '\1[FILTERED]')
end

#store(payment_method, options = {}) ⇒ Object



124
125
126
# File 'lib/active_merchant/billing/gateways/monei.rb', line 124

def store(payment_method, options = {})
  execute_new_order(:store, 0, payment_method, options)
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


128
129
130
# File 'lib/active_merchant/billing/gateways/monei.rb', line 128

def supports_scrubbing?
  true
end

#verify(payment_method, options = {}) ⇒ Object

Public: Verifies credit card. Does this by doing a authorization of 1.00 Euro and then voiding it.

payment_method - Credit card options - Hash containing authorization options

:order_id         Merchant created id for the authorization
:billing_address  Hash with billing address information
:description      Merchant created authorization description (optional)
:currency         Sale currency to override money object or default (optional)

Returns Active Merchant response object of Authorization operation



117
118
119
120
121
122
# File 'lib/active_merchant/billing/gateways/monei.rb', line 117

def verify(payment_method, options = {})
  MultiResponse.run(:use_first_response) do |r|
    r.process { authorize(100, payment_method, options) }
    r.process(:ignore_result) { void(r.authorization, options) }
  end
end

#void(authorization, options = {}) ⇒ Object

Public: Voids previous authorization

authorization - Reference to previous authorization, obtained from response object returned by authorize options - Hash containing capture options

:order_id         Merchant created id for the authorization (optional)

Returns Active Merchant response object



103
104
105
# File 'lib/active_merchant/billing/gateways/monei.rb', line 103

def void(authorization, options = {})
  execute_dependant(:void, nil, authorization, options)
end