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.



41
42
43
44
45
46
# File 'lib/active_merchant/billing/gateways/simetrik.rb', line 41

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

Instance Method Details

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



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

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



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

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] if options[:vat]

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

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



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

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



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

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



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

def scrub(transcript)
  transcript.
    gsub(%r((\"number\\\":\\\")\d+), '\1[FILTERED]').
    gsub(%r((\"security_code\\\":\\\")\d+), '\1[FILTERED]').
    gsub(%r((\"exp_month\\\":\\\")\d+), '\1[FILTERED]').
    gsub(%r((\"exp_year\\\":\\\")\d+), '\1[FILTERED]').
    gsub(%r((\"holder_first_name\\\":\\\")"\w+"), '\1[FILTERED]').
    gsub(%r((\"holder_last_name\\\":\\\")"\w+"), '\1[FILTERED]')
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


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

def supports_scrubbing?
  true
end

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



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

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