Class: ActiveMerchant::Billing::WorldpayGateway

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

Constant Summary

CARD_CODES =
{
  'visa'             => 'VISA-SSL',
  'master'           => 'ECMC-SSL',
  'discover'         => 'DISCOVER-SSL',
  'american_express' => 'AMEX-SSL',
  'jcb'              => 'JCB-SSL',
  'maestro'          => 'MAESTRO-SSL',
  'laser'            => 'LASER-SSL',
  'diners_club'      => 'DINERS-SSL'
}

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary (collapse)

Methods inherited from Gateway

card_brand, #card_brand, inherited, supports?, #test?

Methods included from CreditCardFormatting

#format

Constructor Details

- (WorldpayGateway) initialize(options = {})



25
26
27
28
# File 'lib/active_merchant/billing/gateways/worldpay.rb', line 25

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

Instance Method Details

- (Object) authorize(money, payment_method, options = {})



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

def authorize(money, payment_method, options = {})
  requires!(options, :order_id)
  authorize_request(money, payment_method, options)
end

- (Object) capture(money, authorization, options = {})



42
43
44
45
46
47
48
49
50
51
# File 'lib/active_merchant/billing/gateways/worldpay.rb', line 42

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

- (Object) purchase(money, payment_method, options = {})



30
31
32
33
34
35
# File 'lib/active_merchant/billing/gateways/worldpay.rb', line 30

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

- (Object) refund(money, authorization, options = {})



60
61
62
63
64
65
# File 'lib/active_merchant/billing/gateways/worldpay.rb', line 60

def refund(money, authorization, options = {})
  MultiResponse.run do |r|
    r.process{inquire_request(authorization, options, "CAPTURED", "SETTLED", "SETTLED_BY_MERCHANT")}
    r.process{refund_request(money, authorization, options)}
  end
end

- (Object) void(authorization, options = {})



53
54
55
56
57
58
# File 'lib/active_merchant/billing/gateways/worldpay.rb', line 53

def void(authorization, options = {})
  MultiResponse.run do |r|
    r.process{inquire_request(authorization, options, "AUTHORISED")}
    r.process{cancel_request(authorization, options)}
  end
end