Class: ActiveMerchant::Billing::CyberSourceRestGateway

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

Constant Summary collapse

CREDIT_CARD_CODES =
{
  american_express: '003',
  cartes_bancaires: '036',
  dankort: '034',
  diners_club: '005',
  discover: '004',
  elo: '054',
  jcb: '007',
  maestro: '042',
  master: '002',
  unionpay: '062',
  visa: '001'
}

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 included from CyberSourceCommon

#address_names, #check_billing_field_value, #lookup_country_code

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

Returns a new instance of CyberSourceRestGateway.



34
35
36
37
# File 'lib/active_merchant/billing/gateways/cyber_source_rest.rb', line 34

def initialize(options = {})
  requires!(options, :merchant_id, :public_key, :private_key)
  super
end

Instance Method Details

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



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

def authorize(money, payment, options = {}, capture = false)
  post = build_auth_request(money, payment, options)
  post[:processingInformation] = { capture: true } if capture

  commit('payments', post)
end

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



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

def credit(money, payment, options = {})
  post = build_credit_request(money, payment, options)
  commit('credits', post)
end

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



39
40
41
# File 'lib/active_merchant/billing/gateways/cyber_source_rest.rb', line 39

def purchase(money, payment, options = {})
  authorize(money, payment, options, true)
end

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



50
51
52
53
# File 'lib/active_merchant/billing/gateways/cyber_source_rest.rb', line 50

def refund(money, authorization, options = {})
  post = build_refund_request(money, options)
  commit("payments/#{authorization}/refunds", post)
end

#scrub(transcript) ⇒ Object



64
65
66
67
68
69
70
71
# File 'lib/active_merchant/billing/gateways/cyber_source_rest.rb', line 64

def scrub(transcript)
  transcript.
    gsub(/(\\?"number\\?":\\?")\d+/, '\1[FILTERED]').
    gsub(/(\\?"securityCode\\?":\\?")\d+/, '\1[FILTERED]').
    gsub(/(signature=")[^"]*/, '\1[FILTERED]').
    gsub(/(keyid=")[^"]*/, '\1[FILTERED]').
    gsub(/(Digest: SHA-256=)[\w\/\+=]*/, '\1[FILTERED]')
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


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

def supports_scrubbing?
  true
end