Class: ActiveMerchant::Billing::XpayGateway

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

Constant Summary collapse

ENDPOINTS_MAPPING =
{
  validation: 'orders/3steps/validation',
  purchase: 'orders/3steps/payment',
  authorize: 'orders/3steps/payment',
  preauth: 'orders/3steps/init',
  capture: 'operations/%s/captures',
  verify: 'orders/card_verification',
  refund: 'operations/%s/refunds'
}
SUCCESS_MESSAGES =
%w(PENDING AUTHORIZED THREEDS_VALIDATED EXECUTED).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, #supported_countries, supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #test?

Methods included from CreditCardFormatting

#expdate, #format, #strftime_yyyymm

Methods included from PostsData

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

Constructor Details

#initialize(options = {}) ⇒ XpayGateway

Returns a new instance of XpayGateway.



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

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

Instance Method Details

#authorize(amount, credit_card, options = {}) ⇒ Object



42
43
44
# File 'lib/active_merchant/billing/gateways/xpay.rb', line 42

def authorize(amount, credit_card, options = {})
  complete_order_request(:authorize, amount, credit_card, options)
end

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



46
47
48
# File 'lib/active_merchant/billing/gateways/xpay.rb', line 46

def capture(amount, authorization, options = {})
  operation_request(:capture, amount, authorization, options)
end

#preauth(amount, credit_card, options = {}) ⇒ Object



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

def preauth(amount, credit_card, options = {})
  order_request(:preauth, amount, {}, credit_card, options)
end

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



38
39
40
# File 'lib/active_merchant/billing/gateways/xpay.rb', line 38

def purchase(amount, credit_card, options = {})
  complete_order_request(:purchase, amount, credit_card, options)
end

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



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

def refund(amount, authorization, options = {})
  operation_request(:refund, amount, authorization, options)
end

#scrub(transcript) ⇒ Object



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

def scrub(transcript)
  transcript.
    gsub(%r((X-Api-Key: )(\w|-)+), '\1[FILTERED]').
    gsub(%r(("pan\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
    gsub(%r(("cvv\\?":\\?")\d+), '\1[FILTERED]')
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/active_merchant/billing/gateways/xpay.rb', line 62

def supports_scrubbing?
  true
end

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



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

def verify(credit_card, options = {})
  post = {}
  add_invoice(post, 0, options)
  add_customer_data(post, credit_card, options)
  add_credit_card(post, credit_card)
  commit(:verify, post, options)
end