Class: ActiveMerchant::Billing::BarclaycardSmartpayGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::BarclaycardSmartpayGateway
show all
- Defined in:
- lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
Constant Summary
collapse
- API_VERSION =
'v40'
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, creditcard, options = {}) ⇒ Object
-
#capture(money, authorization, options = {}) ⇒ Object
-
#credit(money, creditcard, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ BarclaycardSmartpayGateway
constructor
A new instance of BarclaycardSmartpayGateway.
-
#purchase(money, creditcard, options = {}) ⇒ Object
-
#refund(money, authorization, options = {}) ⇒ Object
-
#scrub(transcript) ⇒ Object
-
#store(creditcard, options = {}) ⇒ Object
-
#supports_scrubbing? ⇒ Boolean
-
#verify(creditcard, options = {}) ⇒ Object
-
#void(identification, 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?
#expdate, #format
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
Returns a new instance of BarclaycardSmartpayGateway.
[View source]
18
19
20
21
|
# File 'lib/active_merchant/billing/gateways/barclaycard_smartpay.rb', line 18
def initialize(options = {})
requires!(options, :company, :merchant, :password)
super
end
|
Instance Method Details
#authorize(money, creditcard, options = {}) ⇒ Object
[View source]
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/active_merchant/billing/gateways/barclaycard_smartpay.rb', line 32
def authorize(money, creditcard, options = {})
requires!(options, :order_id)
post = payment_request(money, options)
post[:amount] = amount_hash(money, options[:currency])
post[:card] = credit_card_hash(creditcard)
post[:billingAddress] = billing_address_hash(options) if options[:billing_address]
post[:deliveryAddress] = shipping_address_hash(options) if options[:shipping_address]
post[:shopperStatement] = options[:shopper_statement] if options[:shopper_statement]
add_3ds(post, options)
commit('authorise', post)
end
|
#capture(money, authorization, options = {}) ⇒ Object
[View source]
46
47
48
49
50
51
52
53
|
# File 'lib/active_merchant/billing/gateways/barclaycard_smartpay.rb', line 46
def capture(money, authorization, options = {})
requires!(options, :order_id)
post = modification_request(authorization, options)
post[:modificationAmount] = amount_hash(money, options[:currency])
commit('capture', post)
end
|
#credit(money, creditcard, options = {}) ⇒ Object
[View source]
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/active_merchant/billing/gateways/barclaycard_smartpay.rb', line 64
def credit(money, creditcard, options = {})
post = payment_request(money, options)
post[:amount] = amount_hash(money, options[:currency])
post[:card] = credit_card_hash(creditcard)
post[:dateOfBirth] = options[:date_of_birth] if options[:date_of_birth]
post[:entityType] = options[:entity_type] if options[:entity_type]
post[:nationality] = options[:nationality] if options[:nationality]
post[:shopperName] = options[:shopper_name] if options[:shopper_name]
if options[:third_party_payout]
post[:recurring] = options[:recurring_contract] || { contract: 'PAYOUT' }
MultiResponse.run do |r|
r.process {
commit(
'storeDetailAndSubmitThirdParty',
post,
@options[:store_payout_account],
@options[:store_payout_password]
)
}
r.process {
commit(
'confirmThirdParty',
modification_request(r.authorization, @options),
@options[:review_payout_account],
@options[:review_payout_password]
)
}
end
else
commit('refundWithData', post)
end
end
|
#purchase(money, creditcard, options = {}) ⇒ Object
[View source]
23
24
25
26
27
28
29
30
|
# File 'lib/active_merchant/billing/gateways/barclaycard_smartpay.rb', line 23
def purchase(money, creditcard, options = {})
requires!(options, :order_id)
MultiResponse.run do |r|
r.process { authorize(money, creditcard, options) }
r.process { capture(money, r.authorization, options) }
end
end
|
#refund(money, authorization, options = {}) ⇒ Object
[View source]
55
56
57
58
59
60
61
62
|
# File 'lib/active_merchant/billing/gateways/barclaycard_smartpay.rb', line 55
def refund(money, authorization, options = {})
requires!(options, :order_id)
post = modification_request(authorization, options)
post[:modificationAmount] = amount_hash(money, options[:currency])
commit('refund', post)
end
|
#scrub(transcript) ⇒ Object
[View source]
122
123
124
125
126
127
|
# File 'lib/active_merchant/billing/gateways/barclaycard_smartpay.rb', line 122
def scrub(transcript)
transcript.
gsub(%r(((?:\r\n)?Authorization: Basic )[^\r\n]+(\r\n)?), '\1[FILTERED]').
gsub(%r((card.number=)\d+), '\1[FILTERED]').
gsub(%r((card.cvc=)\d+), '\1[FILTERED]')
end
|
#store(creditcard, options = {}) ⇒ Object
[View source]
110
111
112
113
114
115
116
|
# File 'lib/active_merchant/billing/gateways/barclaycard_smartpay.rb', line 110
def store(creditcard, options = {})
post = store_request(options)
post[:card] = credit_card_hash(creditcard)
post[:recurring] = { contract: 'RECURRING' }
commit('store', post)
end
|
#supports_scrubbing? ⇒ Boolean
[View source]
118
119
120
|
# File 'lib/active_merchant/billing/gateways/barclaycard_smartpay.rb', line 118
def supports_scrubbing?
true
end
|
#verify(creditcard, options = {}) ⇒ Object
[View source]
106
107
108
|
# File 'lib/active_merchant/billing/gateways/barclaycard_smartpay.rb', line 106
def verify(creditcard, options = {})
authorize(0, creditcard, options)
end
|
#void(identification, options = {}) ⇒ Object
[View source]
98
99
100
101
102
103
104
|
# File 'lib/active_merchant/billing/gateways/barclaycard_smartpay.rb', line 98
def void(identification, options = {})
requires!(options, :order_id)
post = modification_request(identification, options)
commit('cancel', post)
end
|