Class: ActiveMerchant::Billing::SimetrikGateway

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

Constant Summary collapse

STANDARD_ERROR_CODE_MAPPING =
{
  'R101' => STANDARD_ERROR_CODE[:incorrect_number],
  'R102' => STANDARD_ERROR_CODE[:invalid_number],
  'R103' => STANDARD_ERROR_CODE[:invalid_expiry_date],
  'R104' => STANDARD_ERROR_CODE[:invalid_cvc],
  'R105' => STANDARD_ERROR_CODE[:expired_card],
  'R106' => STANDARD_ERROR_CODE[:incorrect_cvc],
  'R107' => STANDARD_ERROR_CODE[:incorrect_pin],
  'R201' => STANDARD_ERROR_CODE[:incorrect_zip],
  'R202' => STANDARD_ERROR_CODE[:incorrect_address],
  'R301' => STANDARD_ERROR_CODE[:card_declined],
  'R302' => STANDARD_ERROR_CODE[:processing_error],
  'R303' => STANDARD_ERROR_CODE[:call_issuer],
  'R304' => STANDARD_ERROR_CODE[:pick_up_card],
  'R305' => STANDARD_ERROR_CODE[:processing_error],
  'R306' => STANDARD_ERROR_CODE[:processing_error],
  'R307' => STANDARD_ERROR_CODE[:processing_error],
  'R401' => STANDARD_ERROR_CODE[:config_error],
  'R402' => STANDARD_ERROR_CODE[:test_mode_live_card],
  'R403' => STANDARD_ERROR_CODE[:unsupported_feature]

}

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 = {}) ⇒ SimetrikGateway

Returns a new instance of SimetrikGateway.



44
45
46
47
48
49
# File 'lib/active_merchant/billing/gateways/simetrik.rb', line 44

def initialize(options = {})
  requires!(options, :client_id, :client_secret)
  super
  @access_token = {}
  sign_access_token()
end

Instance Method Details

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



51
52
53
54
55
56
57
58
59
# File 'lib/active_merchant/billing/gateways/simetrik.rb', line 51

def authorize(money, payment, options = {})
  requires!(options, :token_acquirer)

  post = {}
  add_forward_route(post, options)
  add_forward_payload(post, money, payment, options)
  add_stored_credential(post, options)
  commit('authorize', post, { token_acquirer: options[:token_acquirer] })
end

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



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/active_merchant/billing/gateways/simetrik.rb', line 61

def capture(money, authorization, options = {})
  requires!(options, :token_acquirer)
  post = {
    forward_payload: {
      amount: {
        total_amount: amount(money).to_f,
        currency: (options[:currency] || currency(money))
      },
      transaction: {
        id: authorization
      },
      acquire_extra_options: options[:acquire_extra_options] || {}
    }
  }
  post[:forward_payload][:amount][:vat] = options[:vat].to_f / 100 if options[:vat]

  add_forward_route(post, options)
  commit('capture', post, { token_acquirer: options[:token_acquirer] })
end

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



115
116
117
118
119
120
121
122
123
124
# File 'lib/active_merchant/billing/gateways/simetrik.rb', line 115

def purchase(money, payment, options = {})
  requires!(options, :token_acquirer)

  post = {}
  add_forward_route(post, options)
  add_forward_payload(post, money, payment, options)

  add_stored_credential(post, options)
  commit('charge', post, { token_acquirer: options[:token_acquirer] })
end

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



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/active_merchant/billing/gateways/simetrik.rb', line 81

def refund(money, authorization, options = {})
  requires!(options, :token_acquirer)
  post = {
    forward_payload: {
      amount: {
        total_amount: amount(money).to_f,
        currency: (options[:currency] || currency(money))
      },
      transaction: {
        id: authorization
      },
      acquire_extra_options: options[:acquire_extra_options] || {}
    }
  }
  post[:forward_payload][:transaction][:comment] = options[:comment] if options[:comment]

  add_forward_route(post, options)
  commit('refund', post, { token_acquirer: options[:token_acquirer] })
end

#scrub(transcript) ⇒ Object



130
131
132
133
134
135
136
# File 'lib/active_merchant/billing/gateways/simetrik.rb', line 130

def scrub(transcript)
  transcript.
    gsub(%r((Authorization: Bearer ).+), '\1[FILTERED]').
    gsub(%r(("client_secret\\?":\\?")\w+), '\1[FILTERED]').
    gsub(%r(("number\\?":\\?")\d+), '\1[FILTERED]').
    gsub(%r(("security_code\\?":\\?")\d+), '\1[FILTERED]')
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


126
127
128
# File 'lib/active_merchant/billing/gateways/simetrik.rb', line 126

def supports_scrubbing?
  true
end

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



101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/active_merchant/billing/gateways/simetrik.rb', line 101

def void(authorization, options = {})
  requires!(options, :token_acquirer)
  post = {
    forward_payload: {
      transaction: {
        id: authorization
      },
      acquire_extra_options: options[:acquire_extra_options] || {}
    }
  }
  add_forward_route(post, options)
  commit('void', post, { token_acquirer: options[:token_acquirer] })
end