Class: ActiveMerchant::Billing::PaysafeGateway

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

Constant Summary

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

Returns a new instance of PaysafeGateway.



13
14
15
16
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 13

def initialize(options = {})
  requires!(options, :username, :password, :account_id)
  super
end

Instance Method Details

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



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

def authorize(money, payment, options = {})
  post = {}
  add_auth_purchase_params(post, money, payment, options)

  commit(:post, 'auths', post, options)
end

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



35
36
37
38
39
40
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 35

def capture(money, authorization, options = {})
  post = {}
  add_invoice(post, money, options)

  commit(:post, "auths/#{authorization}/settlements", post, options)
end

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



57
58
59
60
61
62
63
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 57

def credit(money, payment, options = {})
  post = {}
  add_invoice(post, money, options)
  add_payment(post, payment)

  commit(:post, 'standalonecredits', post, options)
end

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



18
19
20
21
22
23
24
25
26
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 18

def purchase(money, payment, options = {})
  post = {}
  add_auth_purchase_params(post, money, payment, options)
  add_airline_travel_details(post, options)
  add_split_pay_details(post, options)
  post[:settleWithAuth] = true

  commit(:post, 'auths', post, options)
end

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



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

def refund(money, authorization, options = {})
  post = {}
  add_invoice(post, money, options)

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

#scrub(transcript) ⇒ Object



93
94
95
96
97
98
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 93

def scrub(transcript)
  transcript.
    gsub(%r((Authorization: Basic )[a-zA-Z0-9:_]+), '\1[FILTERED]').
    gsub(%r(("cardNum\\?":\\?")\d+), '\1[FILTERED]').
    gsub(%r(("cvv\\?":\\?")\d+), '\1[FILTERED]')
end

#store(payment, options = {}) ⇒ Object



75
76
77
78
79
80
81
82
83
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 75

def store(payment, options = {})
  post = {}
  add_payment(post, payment)
  add_address_for_vaulting(post, options)
  add_profile_data(post, payment, options)
  add_store_data(post, payment, options)

  commit(:post, 'profiles', post, options)
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 89

def supports_scrubbing?
  true
end

#unstore(pm_profile_id) ⇒ Object



85
86
87
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 85

def unstore(pm_profile_id)
  commit(:delete, "profiles/#{get_id_from_store_auth(pm_profile_id)}", nil, nil)
end

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

This is a ‘$0 auth’ done at a specific verification endpoint at the gateway



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

def verify(payment, options = {})
  post = {}
  add_payment(post, payment)
  add_billing_address(post, options)
  add_customer_data(post, payment, options) unless payment.is_a?(String)

  commit(:post, 'verifications', post, options)
end

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



49
50
51
52
53
54
55
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 49

def void(authorization, options = {})
  post = {}
  money = options[:amount]
  add_invoice(post, money, options)

  commit(:post, "auths/#{authorization}/voidauths", post, options)
end