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.



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

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

Instance Method Details

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



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 32

def authorize(money, payment, options = {})
  post = {}
  add_invoice(post, money, options)
  add_payment(post, payment)
  add_billing_address(post, options)
  add_merchant_details(post, options)
  add_customer_data(post, payment, options) unless payment.is_a?(String)
  add_three_d_secure(post, payment, options) if options[:three_d_secure]

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

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



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

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

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

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



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

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



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

def purchase(money, payment, options = {})
  post = {}
  add_invoice(post, money, options)
  add_payment(post, payment)
  add_billing_address(post, options)
  add_merchant_details(post, options)
  add_customer_data(post, payment, options) unless payment.is_a?(String)
  add_three_d_secure(post, payment, options) if options[:three_d_secure]
  post[:settleWithAuth] = true

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

#redact(pm_profile_id) ⇒ Object



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

def redact(pm_profile_id)
  commit_for_redact(:delete, "profiles/#{pm_profile_id}", nil, nil)
end

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



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

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

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

#scrub(transcript) ⇒ Object



102
103
104
105
106
107
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 102

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



84
85
86
87
88
89
90
91
92
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 84

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)


98
99
100
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 98

def supports_scrubbing?
  true
end

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

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



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

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



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

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

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