lib/active_merchant/billing/gateways/wirecard.rb in activemerchant-1.40.0 vs lib/active_merchant/billing/gateways/wirecard.rb in activemerchant-1.41.0

- old
+ new

@@ -1,14 +1,11 @@ require 'base64' module ActiveMerchant #:nodoc: module Billing #:nodoc: class WirecardGateway < Gateway - # Test server location self.test_url = 'https://c3-test.wirecard.com/secure/ssl-gateway' - - # Live server location self.live_url = 'https://c3.wirecard.com/secure/ssl-gateway' # 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. ENVELOPE_NAMESPACES = { @@ -27,61 +24,55 @@ # 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). VALID_PHONE_FORMAT = /\+\d{1,3}(\(?\d{3}\)?)?\d{3}-\d{4}-\d{3}/ - # The countries the gateway supports merchants from as 2 digit ISO country codes + self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :jcb, :switch ] self.supported_countries = %w(AD CY GI IM MT RO CH AT DK GR IT MC SM TR BE EE HU LV NL SK GB BG FI IS LI NO SI VA FR IL LT PL ES CZ DE IE LU PT SE) - - # Wirecard supports all major credit and debit cards: - # Visa, Mastercard, American Express, Diners Club, - # JCB, Switch, VISA Carte Bancaire, Visa Electron and UATP cards. - # They also support the latest anti-fraud systems such as Verified by Visa or Master Secure Code. - self.supported_cardtypes = [ - :visa, :master, :american_express, :diners_club, :jcb, :switch - ] - - # The homepage URL of the gateway self.homepage_url = 'http://www.wirecard.com' - - # The name of the gateway self.display_name = 'Wirecard' - - # The currency should normally be EUROs self.default_currency = 'EUR' - - # 100 is 1.00 Euro self.money_format = :cents + # Public: Create a new Wirecard gateway. + # + # options - A hash of options: + # :login - The username + # :password - The password + # :signature - The BusinessCaseSignature def initialize(options = {}) - # verify that username and password are supplied - requires!(options, :login, :password) - # unfortunately Wirecard also requires a BusinessCaseSignature in the XML request - requires!(options, :signature) + requires!(options, :login, :password, :signature) super end - # Authorization def authorize(money, creditcard, options = {}) options[:credit_card] = creditcard commit(:preauthorization, money, options) end - # Capture Authorization def capture(money, authorization, options = {}) options[:preauthorization] = authorization commit(:capture, money, options) end - # Purchase def purchase(money, creditcard, options = {}) options[:credit_card] = creditcard commit(:purchase, money, options) end - private + def void(identification, options = {}) + options[:preauthorization] = identification + commit(:reversal, nil, options) + end + def refund(money, identification, options = {}) + options[:preauthorization] = identification + commit(:bookback, money, options) + end + + + private def prepare_options_hash(options) result = @options.merge(options) setup_address_hash!(result) result end @@ -154,12 +145,14 @@ case options[:action] when :preauthorization, :purchase add_invoice(xml, money, options) add_creditcard(xml, options[:credit_card]) add_address(xml, options[:billing_address]) - when :capture + when :capture, :bookback xml.tag! 'GuWID', options[:preauthorization] add_amount(xml, money) + when :reversal + xml.tag! 'GuWID', options[:preauthorization] end end end end