Class: ActiveMerchant::Billing::WirecardGateway

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

Constant Summary collapse

ENVELOPE_NAMESPACES =

The Namespaces are not really needed, because it just tells the System, that there’s actually no namespace used. It’s just specified here for completeness.

{
  'xmlns:xsi' => 'http://www.w3.org/1999/XMLSchema-instance',
  'xsi:noNamespaceSchemaLocation' => 'wirecard.xsd'
}
PERMITTED_TRANSACTIONS =
%w[PREAUTHORIZATION CAPTURE PURCHASE]
RETURN_CODES =
%w[ACK NOK]
VALID_PHONE_FORMAT =

Wirecard only allows phone numbers with a format like this: +xxx(yyy)zzz-zzzz-ppp, where:

xxx = Country code
yyy = Area or city code
zzz-zzzz = Local number
ppp = PBX extension

For example, a typical U.S. or Canadian number would be “+1(202)555-1234-739” indicating PBX extension 739 at phone number 5551234 within area code 202 (country code 1).

/\+\d{1,3}(\(?\d{3}\)?)?\d{3}-\d{4}-\d{3}/

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?, #supports_scrubbing?, #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 = {}) ⇒ WirecardGateway

Public: Create a new Wirecard gateway.

options - A hash of options:

:login         - The username
:password      - The password
:signature     - The BusinessCaseSignature


42
43
44
45
# File 'lib/active_merchant/billing/gateways/wirecard.rb', line 42

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

Instance Method Details

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

Authorization - the second parameter may be a CreditCard or a String which represents a GuWID reference to an earlier transaction. If a GuWID is given, rather than a CreditCard, then then the :recurring option will be forced to “Repeated”



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

def authorize(money, payment_method, options = {})
  if payment_method.respond_to?(:number)
    options[:credit_card] = payment_method
  else
    options[:preauthorization] = payment_method
  end
  commit(:preauthorization, money, options)
end

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



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

def capture(money, authorization, options = {})
  options[:preauthorization] = authorization
  commit(:capture, money, options)
end

#purchase(money, payment_method, options = {}) ⇒ Object

Purchase - the second parameter may be a CreditCard or a String which represents a GuWID reference to an earlier transaction. If a GuWID is given, rather than a CreditCard, then then the :recurring option will be forced to “Repeated”



69
70
71
72
73
74
75
76
# File 'lib/active_merchant/billing/gateways/wirecard.rb', line 69

def purchase(money, payment_method, options = {})
  if payment_method.respond_to?(:number)
    options[:credit_card] = payment_method
  else
    options[:preauthorization] = payment_method
  end
  commit(:purchase, money, options)
end

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



83
84
85
86
# File 'lib/active_merchant/billing/gateways/wirecard.rb', line 83

def refund(money, identification, options = {})
  options[:preauthorization] = identification
  commit(:bookback, money, options)
end

#scrub(transcript) ⇒ Object



133
134
135
136
137
138
# File 'lib/active_merchant/billing/gateways/wirecard.rb', line 133

def scrub(transcript)
  transcript.
    gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
    gsub(%r((<CreditCardNumber>)\d+(</CreditCardNumber>)), '\1[FILTERED]\2').
    gsub(%r((<CVC2>)[^<]+(</CVC2>)), '\1[FILTERED]\2')
end

#store(creditcard, options = {}) ⇒ Object

Store card - Wirecard supports the notion of “Recurring Transactions” by allowing the merchant to provide a reference to an earlier transaction (the GuWID) rather than a credit card. A reusable reference (GuWID) can be obtained by sending a purchase or authorization transaction with the element “RECURRING_TRANSACTION/Type” set to “Initial”. Subsequent transactions can then use the GuWID in place of a credit card by setting “RECURRING_TRANSACTION/Type” to “Repeated”.

This implementation of card store utilizes a Wirecard “Authorization Check” (a Preauthorization that is automatically reversed). It defaults to a check amount of “100” (i.e. $1.00) but this can be overriden (see below).

IMPORTANT: In order to reuse the stored reference, the authorization from the response should be saved by your application code.

Options specific to store

  • :amount – The amount, in cents, that should be “validated” by the Authorization Check. This amount will be reserved and then reversed. Default is 100.

Note: This is not the only way to achieve a card store operation at Wirecard. Any purchase or authorize can be sent with options = ‘Initial’ to make the returned authorization/GuWID usable in later transactions with options = ‘Repeated’.



117
118
119
120
121
122
123
124
125
126
127
# File 'lib/active_merchant/billing/gateways/wirecard.rb', line 117

def store(creditcard, options = {})
  options[:credit_card] = creditcard
  options[:recurring] = 'Initial'
  money = options.delete(:amount) || 100
  # Amex does not support authorization_check
  if creditcard.brand == 'american_express'
    commit(:preauthorization, money, options)
  else
    commit(:authorization_check, money, options)
  end
end

#supports_scrubbingObject



129
130
131
# File 'lib/active_merchant/billing/gateways/wirecard.rb', line 129

def supports_scrubbing
  true
end

#void(identification, options = {}) ⇒ Object



78
79
80
81
# File 'lib/active_merchant/billing/gateways/wirecard.rb', line 78

def void(identification, options = {})
  options[:preauthorization] = identification
  commit(:reversal, nil, options)
end