Class: ActiveMerchant::Billing::QuickpayGateway

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

Constant Summary collapse

URL =
'https://secure.quickpay.dk/transaction.php'
TRANSACTIONS =
{
  :authorization => '1100',
  :capture       => '1220',
  :void          => '1420',
  :credit        => 'credit'
}
POS_CODES =
{
  :mail               => '100020100110',
  :phone              => '100030100110',
  :internet           => 'L00500L00130',
  :internet_secure    => 'K00500K00130',
  :internet_edankort  => 'KM0500R00130',
  :internet_recurring => 'K00540K00130' 
}
MD5_CHECK_FIELDS =
{
  :authorization    => [:msgtype, :cardnumber, :amount, :expirationdate, :posc, :ordernum, :currency, :cvd, :merchant, :authtype, :reference, :transaction],
  :capture => [:msgtype, :amount, :merchant, :transaction],
  :void    => [:msgtype, :merchant, :transaction],
  :credit  => [:msgtype, :amount, :merchant, :transaction]
}
CURRENCIES =
[ 'DKK', 'EUR', 'NOK', 'GBP', 'USD' ]
APPROVED =
'000'

Constants inherited from Gateway

Gateway::DEBIT_CARDS

Constants included from PostsData

PostsData::MAX_RETRIES, PostsData::OPEN_TIMEOUT, PostsData::READ_TIMEOUT

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

inherited, supports?, #test?

Methods included from Utils

generate_unique_id

Methods included from CreditCardFormatting

#format

Methods included from RequiresParameters

#requires!

Methods included from PostsData

included, #retry_exceptions, #ssl_post

Constructor Details

#initialize(options = {}) ⇒ QuickpayGateway

The login is the QuickpayId The password is the md5checkword from the Quickpay admin interface



45
46
47
48
49
# File 'lib/active_merchant/billing/gateways/quickpay.rb', line 45

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

Instance Method Details

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



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

def authorize(money, creditcard, options = {})
  post = {}
  
  add_amount(post, money, options)
  add_creditcard(post, creditcard)        
  add_invoice(post, options)

  commit(:authorization, post)
end

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



66
67
68
69
70
71
72
73
# File 'lib/active_merchant/billing/gateways/quickpay.rb', line 66

def capture(money, authorization, options = {})
  post = {}
  
  add_reference(post, authorization)
  add_amount(post, money)
  
  commit(:capture, post)
end

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



83
84
85
86
87
88
89
90
# File 'lib/active_merchant/billing/gateways/quickpay.rb', line 83

def credit(money, identification, options = {})
  post = {}
  
  add_amount(post, money)
  add_reference(post, identification)
  
  commit(:credit, post)
end

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



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

def purchase(money, creditcard, options = {})
  auth = authorize(money, creditcard, options)
  auth.success? ? capture(money, auth.authorization) : auth
end

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



75
76
77
78
79
80
81
# File 'lib/active_merchant/billing/gateways/quickpay.rb', line 75

def void(identification, options = {})
  post = {}
  
  add_reference(post, identification)
  
  commit(:void, post)
end