Class: ActiveMerchant::Billing::WorldpayGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::WorldpayGateway
show all
- Defined in:
- lib/active_merchant/billing/gateways/worldpay.rb
Constant Summary
collapse
- CARD_CODES =
{
'visa' => 'VISA-SSL',
'master' => 'ECMC-SSL',
'discover' => 'DISCOVER-SSL',
'american_express' => 'AMEX-SSL',
'jcb' => 'JCB-SSL',
'maestro' => 'MAESTRO-SSL',
'diners_club' => 'DINERS-SSL',
'elo' => 'ELO-SSL'
}
- AVS_CODE_MAP =
{
'A' => 'M',
'B' => 'P',
'C' => 'Z',
'D' => 'B',
'E' => 'I',
'F' => 'A',
'G' => 'C',
'H' => 'I',
'I' => 'C',
'J' => 'C',
}
- CVC_CODE_MAP =
{
'A' => 'M',
'B' => 'P',
'C' => 'P',
'D' => 'N',
}
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_method, options = {}) ⇒ Object
-
#capture(money, authorization, options = {}) ⇒ Object
-
#credit(money, payment_method, options = {}) ⇒ Object
Credits only function on a Merchant ID/login/profile flagged for Payouts aka Credit Fund Transfers (CFT), whereas normal purchases, refunds, and other transactions should be performed on a normal eCom-flagged merchant ID.
-
#initialize(options = {}) ⇒ WorldpayGateway
constructor
A new instance of WorldpayGateway.
-
#purchase(money, payment_method, options = {}) ⇒ Object
-
#refund(money, authorization, options = {}) ⇒ Object
-
#scrub(transcript) ⇒ Object
-
#supports_scrubbing ⇒ Object
-
#verify(credit_card, options = {}) ⇒ Object
-
#void(authorization, options = {}) ⇒ Object
Methods inherited from Gateway
#card_brand, card_brand, #generate_unique_id, inherited, supported_countries, #supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #supports_scrubbing?, #test?
#expdate, #format
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
Returns a new instance of WorldpayGateway.
47
48
49
50
|
# File 'lib/active_merchant/billing/gateways/worldpay.rb', line 47
def initialize(options = {})
requires!(options, :login, :password)
super
end
|
Instance Method Details
#authorize(money, payment_method, options = {}) ⇒ Object
59
60
61
62
|
# File 'lib/active_merchant/billing/gateways/worldpay.rb', line 59
def authorize(money, payment_method, options = {})
requires!(options, :order_id)
authorize_request(money, payment_method, options)
end
|
#capture(money, authorization, options = {}) ⇒ Object
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/active_merchant/billing/gateways/worldpay.rb', line 64
def capture(money, authorization, options = {})
MultiResponse.run do |r|
r.process { inquire_request(authorization, options, 'AUTHORISED') } unless options[:authorization_validated]
if r.params
authorization_currency = r.params['amount_currency_code']
options = options.merge(:currency => authorization_currency) if authorization_currency.present?
end
r.process { capture_request(money, authorization, options) }
end
end
|
#credit(money, payment_method, options = {}) ⇒ Object
Credits only function on a Merchant ID/login/profile flagged for Payouts
aka Credit Fund Transfers (CFT), whereas normal purchases, refunds,
and other transactions should be performed on a normal eCom-flagged
merchant ID.
98
99
100
|
# File 'lib/active_merchant/billing/gateways/worldpay.rb', line 98
def credit(money, payment_method, options = {})
credit_request(money, payment_method, options.merge(:credit => true))
end
|
#purchase(money, payment_method, options = {}) ⇒ Object
52
53
54
55
56
57
|
# File 'lib/active_merchant/billing/gateways/worldpay.rb', line 52
def purchase(money, payment_method, options = {})
MultiResponse.run do |r|
r.process { authorize(money, payment_method, options) }
r.process { capture(money, r.authorization, options.merge(:authorization_validated => true)) }
end
end
|
#refund(money, authorization, options = {}) ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/active_merchant/billing/gateways/worldpay.rb', line 82
def refund(money, authorization, options = {})
response = MultiResponse.run do |r|
r.process { inquire_request(authorization, options, 'CAPTURED', 'SETTLED', 'SETTLED_BY_MERCHANT') }
r.process { refund_request(money, authorization, options) }
end
return response if response.success?
return response unless options[:force_full_refund_if_unsettled]
void(authorization, options) if response.params['last_event'] == 'AUTHORISED'
end
|
#scrub(transcript) ⇒ Object
113
114
115
116
117
118
|
# File 'lib/active_merchant/billing/gateways/worldpay.rb', line 113
def scrub(transcript)
transcript.
gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
gsub(%r((<cardNumber>)\d+(</cardNumber>)), '\1[FILTERED]\2').
gsub(%r((<cvc>)[^<]+(</cvc>)), '\1[FILTERED]\2')
end
|
#supports_scrubbing ⇒ Object
109
110
111
|
# File 'lib/active_merchant/billing/gateways/worldpay.rb', line 109
def supports_scrubbing
true
end
|
#verify(credit_card, options = {}) ⇒ Object
102
103
104
105
106
107
|
# File 'lib/active_merchant/billing/gateways/worldpay.rb', line 102
def verify(credit_card, options={})
MultiResponse.run(:use_first_response) do |r|
r.process { authorize(100, credit_card, options) }
r.process(:ignore_result) { void(r.authorization, options.merge(:authorization_validated => true)) }
end
end
|
#void(authorization, options = {}) ⇒ Object
75
76
77
78
79
80
|
# File 'lib/active_merchant/billing/gateways/worldpay.rb', line 75
def void(authorization, options = {})
MultiResponse.run do |r|
r.process { inquire_request(authorization, options, 'AUTHORISED') } unless options[:authorization_validated]
r.process { cancel_request(authorization, options) }
end
end
|