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 apikey),

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

    :refund    => %w(protocol msgtype merchant amount transaction 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 apikey),

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

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

  5 => {
    :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 apikey),

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

    :refund    => %w(protocol msgtype merchant amount transaction 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 apikey),

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

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

  6 => {
    :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
                     apikey),

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

    :refund    => %w(protocol msgtype merchant amount transaction 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 apikey),

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

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

  7 => {
    :authorize => %w(protocol msgtype merchant ordernumber amount
                     currency autocapture cardnumber expirationdate cvd
                     acquirers 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
                     apikey),

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

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

    :subscribe => %w(protocol msgtype merchant ordernumber amount currency
                     cardnumber expirationdate cvd acquirers 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 apikey),

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

    :chstatus  => %w(protocol msgtype merchant apikey)
  }
}
APPROVED =
'000'

Constants inherited from Gateway

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

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#card_brand, card_brand, #generate_unique_id, inherited, supported_countries, #supported_countries, supported_countries=, 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/5/6/7 in options.



161
162
163
164
165
# File 'lib/active_merchant/billing/gateways/quickpay.rb', line 161

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

Instance Method Details

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



167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/active_merchant/billing/gateways/quickpay.rb', line 167

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

  action = recurring_or_authorize(credit_card_or_reference)

  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) if action.eql?(:authorize)
  add_testmode(post)

  commit(action, post)
end

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



196
197
198
199
200
201
202
# File 'lib/active_merchant/billing/gateways/quickpay.rb', line 196

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

  add_reference(post, authorization)
  add_amount_without_currency(post, money)
  commit(:capture, post)
end

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



221
222
223
224
# File 'lib/active_merchant/billing/gateways/quickpay.rb', line 221

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

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



182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/active_merchant/billing/gateways/quickpay.rb', line 182

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

  action = recurring_or_authorize(credit_card_or_reference)

  add_amount(post, money, options)
  add_creditcard_or_reference(post, credit_card_or_reference, options)
  add_invoice(post, options)
  add_fraud_parameters(post, options) if action.eql?(:authorize)
  add_autocapture(post, true)

  commit(action, post)
end

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



212
213
214
215
216
217
218
219
# File 'lib/active_merchant/billing/gateways/quickpay.rb', line 212

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

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

  commit(:refund, post)
end

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



226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/active_merchant/billing/gateways/quickpay.rb', line 226

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

  add_creditcard(post, creditcard, options)
  add_amount(post, 0, options) if @protocol >= 7
  add_invoice(post, options)
  add_description(post, options)
  add_fraud_parameters(post, options)
  add_testmode(post)

  commit(:subscribe, post)
end

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



204
205
206
207
208
209
210
# File 'lib/active_merchant/billing/gateways/quickpay.rb', line 204

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

  add_reference(post, identification)

  commit(:cancel, post)
end