Class: ActiveMerchant::Billing::MollieGateway

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

Constant Summary collapse

SOFT_DECLINE_REASONS =
%w[
  insufficient_funds
  card_expired
  card_declined
  temporary_failure
  verification_required
].freeze
AUTHORIZATION_PREFIX =
'Bearer '.freeze
CONTENT_TYPE =
'application/json'.freeze

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, #scrub, #supported_countries, supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #supports_scrubbing?, #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 = {}) ⇒ MollieGateway

Returns a new instance of MollieGateway.



26
27
28
29
30
# File 'lib/active_merchant/billing/gateways/mollie.rb', line 26

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

Instance Method Details

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



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/active_merchant/billing/gateways/mollie.rb', line 32

def purchase(amount, payment_method, options = {})
  return recurring(amount, payment_method, options) if recurring_payment?(payment_method, options)

  result = add_customer_to_payment(payment_method, options)
  return result if result.is_a?(Response) && !result.success?

  post = {}
  add_purchase_data(post, amount, payment_method, options)
  add_customer_data(post, result, options)
  add_payment_token(post, payment_method, options)
  add_addresses(post, options)

  commit('payments', post, options)
end

#recurring(amount, payment_method, options = {}) ⇒ Object



47
48
49
50
51
52
# File 'lib/active_merchant/billing/gateways/mollie.rb', line 47

def recurring(amount, payment_method, options = {})
  post = {}
  add_recurring_data(post, amount, payment_method, options)

  commit('payments', post, options)
end

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



54
55
56
57
58
59
# File 'lib/active_merchant/billing/gateways/mollie.rb', line 54

def refund(amount, authorization, options = {})
  post = {}
  add_refund_data(post, amount, authorization, options)

  commit("payments/#{authorization}/refunds", post, options)
end

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



61
62
63
# File 'lib/active_merchant/billing/gateways/mollie.rb', line 61

def void(authorization, options = {})
  commit("payments/#{authorization}/cancel", {}, options)
end