Class: ActiveMerchant::Billing::PaysafeGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::PaysafeGateway
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
-
#authorize(money, payment, options = {}) ⇒ Object
-
#capture(money, authorization, options = {}) ⇒ Object
-
#credit(money, payment, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ PaysafeGateway
constructor
A new instance of PaysafeGateway.
-
#purchase(money, payment, options = {}) ⇒ Object
-
#refund(money, authorization, options = {}) ⇒ Object
-
#scrub(transcript) ⇒ Object
-
#store(payment, options = {}) ⇒ Object
-
#supports_scrubbing? ⇒ Boolean
-
#unstore(pm_profile_id) ⇒ Object
-
#verify(payment, options = {}) ⇒ Object
This is a ‘$0 auth’ done at a specific verification endpoint at the gateway.
-
#void(authorization, options = {}) ⇒ Object
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?
#fetch_version, included
#expdate, #format, #strftime_yyyymm, #strftime_yyyymmdd_last_day
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
Returns a new instance of PaysafeGateway.
15
16
17
18
|
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 15
def initialize(options = {})
requires!(options, :username, :password, :account_id)
super
end
|
Instance Method Details
#authorize(money, payment, options = {}) ⇒ Object
30
31
32
33
34
35
|
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 30
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
37
38
39
40
41
42
|
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 37
def capture(money, authorization, options = {})
post = {}
add_invoice(post, money, options)
commit(:post, "auths/#{authorization}/settlements", post, options)
end
|
#credit(money, payment, options = {}) ⇒ Object
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 59
def credit(money, payment, options = {})
post = {}
add_invoice(post, money, options)
add_payment(post, payment)
add_customer_data(post, payment, options) unless payment.is_a?(String)
add_merchant_details(post, options)
add_billing_address(post, options)
commit(:post, 'standalonecredits', post, options)
end
|
#purchase(money, payment, options = {}) ⇒ Object
20
21
22
23
24
25
26
27
28
|
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 20
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
44
45
46
47
48
49
|
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 44
def refund(money, authorization, options = {})
post = {}
add_invoice(post, money, options)
commit(:post, "settlements/#{authorization}/refunds", post, options)
end
|
#scrub(transcript) ⇒ Object
114
115
116
117
118
119
|
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 114
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 80
def store(payment, options = {})
post = {}
if options[:profile_id]
post[:cardNum] = payment.number
post[:cardExpiry] = {
month: payment.month,
year: payment.year
}
post[:accountId] = options[:account_id] if options[:account_id]
post[:nickName] = options[:nickname] if options[:nickname]
post[:holderName] = payment.name
post[:billingAddressId] = options[:billing_address_id] if options[:billing_address_id]
post[:defaultCardIndicator] = normalize(options[:default_card_indicator]) if options[:default_card_indicator]
else
add_payment(post, payment)
add_address_for_vaulting(post, options)
add_profile_data(post, payment, options)
add_store_data(post, payment, options)
end
endpoint = options[:profile_id] ? "profiles/#{options[:profile_id]}/cards" : 'profiles'
commit(:post, endpoint, post, options)
end
|
#supports_scrubbing? ⇒ Boolean
110
111
112
|
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 110
def supports_scrubbing?
true
end
|
#unstore(pm_profile_id) ⇒ Object
106
107
108
|
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 106
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
71
72
73
74
75
76
77
78
|
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 71
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
51
52
53
54
55
56
57
|
# File 'lib/active_merchant/billing/gateways/paysafe.rb', line 51
def void(authorization, options = {})
post = {}
money = options[:amount]
add_invoice(post, money, options)
commit(:post, "auths/#{authorization}/voidauths", post, options)
end
|