Class: ActiveMerchant::Billing::QuickpayGateway

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

Constant Summary collapse

MD5_CHECK_FIELDS =
{
  3 => {
    :authorize => %w(protocol msgtype merchant ordernumber amount
                     currency autocapture cardnumber expirationdate
                     cvd cardtypelock testmode),

    :capture   => %w(protocol msgtype merchant amount transaction),

    :cancel    => %w(protocol msgtype merchant transaction),

    :refund    => %w(protocol msgtype merchant amount transaction),

    :subscribe => %w(protocol msgtype merchant ordernumber cardnumber
                     expirationdate cvd cardtypelock description testmode),

    :recurring => %w(protocol msgtype merchant ordernumber amount
                     currency autocapture transaction),

    :status    => %w(protocol msgtype merchant transaction),

    :chstatus  => %w(protocol msgtype merchant)
  },

  4 => {
    :authorize => %w(protocol msgtype merchant ordernumber amount
                     currency autocapture cardnumber expirationdate cvd
                     cardtypelock testmode fraud_remote_addr
                     fraud_http_accept fraud_http_accept_language
                     fraud_http_accept_encoding fraud_http_accept_charset
                     fraud_http_referer fraud_http_user_agent apikey),

    :capture   => %w(protocol msgtype merchant amount transaction
                     fraud_remote_addr fraud_http_accept
                     fraud_http_accept_language fraud_http_accept_encoding
                     fraud_http_accept_charset fraud_http_referer
                     fraud_http_user_agent apikey),

    :cancel    => %w(protocol msgtype merchant transaction fraud_remote_addr
                     fraud_http_accept fraud_http_accept_language
                     fraud_http_accept_encoding fraud_http_accept_charset
                     fraud_http_referer fraud_http_user_agent apikey),

    :refund    => %w(protocol msgtype merchant amount transaction
                     fraud_remote_addr fraud_http_accept fraud_http_accept_language
                     fraud_http_accept_encoding fraud_http_accept_charset
                     fraud_http_referer fraud_http_user_agent apikey),

    :subscribe => %w(protocol msgtype merchant ordernumber cardnumber
                     expirationdate cvd cardtypelock description testmode
                     fraud_remote_addr fraud_http_accept fraud_http_accept_language
                     fraud_http_accept_encoding fraud_http_accept_charset
                     fraud_http_referer fraud_http_user_agent apikey),

    :recurring => %w(protocol msgtype merchant ordernumber amount currency
                     autocapture transaction fraud_remote_addr fraud_http_accept
                     fraud_http_accept_language fraud_http_accept_encoding
                     fraud_http_accept_charset fraud_http_referer
                     fraud_http_user_agent apikey),

    :status    => %w(protocol msgtype merchant transaction fraud_remote_addr
                     fraud_http_accept fraud_http_accept_language
                     fraud_http_accept_encoding fraud_http_accept_charset
                     fraud_http_referer fraud_http_user_agent apikey),

    :chstatus  => %w(protocol msgtype merchant fraud_remote_addr fraud_http_accept
                     fraud_http_accept_language fraud_http_accept_encoding
                     fraud_http_accept_charset fraud_http_referer
                     fraud_http_user_agent apikey)
  }
}
APPROVED =
'000'

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

#initialize(options = {}) ⇒ QuickpayGateway

The login is the QuickpayId The password is the md5checkword from the Quickpay manager To use the API-key from the Quickpay manager, specify :api-key Using the API-key, requires that you use version 4. Specify :version => 4 in options.



93
94
95
96
97
98
# File 'lib/active_merchant/billing/gateways/quickpay.rb', line 93

def initialize(options = {})
  requires!(options, :login, :password)
  @protocol = options.delete(:version) || 3 # default to protocol version 3
  @options = options
  super
end

Instance Method Details

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



100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/active_merchant/billing/gateways/quickpay.rb', line 100

def authorize(money, credit_card_or_reference, options = {})
  post = {}

  add_amount(post, money, options)
  add_invoice(post, options)
  add_creditcard_or_reference(post, credit_card_or_reference, options)
  add_autocapture(post, false)
  add_fraud_parameters(post, options)
  add_testmode(post)

  commit(recurring_or_authorize(credit_card_or_reference), post)
end

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



125
126
127
128
129
130
131
132
133
# File 'lib/active_merchant/billing/gateways/quickpay.rb', line 125

def capture(money, authorization, options = {})
  post = {}

  add_reference(post, authorization)
  add_amount_without_currency(post, money)
  add_fraud_parameters(post, options)

  commit(:capture, post)
end

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



154
155
156
157
# File 'lib/active_merchant/billing/gateways/quickpay.rb', line 154

def credit(money, identification, options = {})
  deprecated CREDIT_DEPRECATION_MESSAGE
  refund(money, identification, options)
end

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



113
114
115
116
117
118
119
120
121
122
123
# File 'lib/active_merchant/billing/gateways/quickpay.rb', line 113

def purchase(money, credit_card_or_reference, options = {})
  post = {}

  add_amount(post, money, options)
  add_creditcard_or_reference(post, credit_card_or_reference, options)
  add_invoice(post, options)
  add_fraud_parameters(post, options)
  add_autocapture(post, true)

  commit(recurring_or_authorize(credit_card_or_reference), post)
end

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



144
145
146
147
148
149
150
151
152
# File 'lib/active_merchant/billing/gateways/quickpay.rb', line 144

def refund(money, identification, options = {})
  post = {}

  add_amount_without_currency(post, money)
  add_reference(post, identification)
  add_fraud_parameters(post, options)

  commit(:refund, post)
end

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



159
160
161
162
163
164
165
166
167
168
169
# File 'lib/active_merchant/billing/gateways/quickpay.rb', line 159

def store(creditcard, options = {})
  post = {}

  add_creditcard(post, creditcard, options)
  add_invoice(post, options)
  add_description(post, options)
  add_fraud_parameters(post, options)
  add_testmode(post)

  commit(:subscribe, post)
end

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



135
136
137
138
139
140
141
142
# File 'lib/active_merchant/billing/gateways/quickpay.rb', line 135

def void(identification, options = {})
  post = {}

  add_reference(post, identification)
  add_fraud_parameters(post, options)

  commit(:cancel, post)
end