Class: ActiveMerchant::Billing::PsigateGateway

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

Overview

This class implements the Psigate gateway for the ActiveMerchant module.

Modifications by Sean O’Hara ( sohara at sohara dot com )

Usage for a PreAuth (authorize) is as follows:

gateway = PsigateGateway.new(

:login => 'teststore',
:password => 'psigate1234'

)

creditcard = CreditCard.new(

:number => '4242424242424242',
:month => 8,
:year => 2006,
:first_name => 'Longbob',
:last_name => 'Longsen'

)

twenty = 2000 response = @gateway.authorize(twenty, creditcard,

 :order_id =>  1234,
 :billing_address => {
   :address1 => '123 fairweather Lane',
   :address2 => 'Apt B',
   :city => 'New York',
   :state => 'NY',
   :country => 'U.S.A.',
   :zip => '10010'
},
:email => '[email protected]'

)

Constant Summary collapse

SUCCESS_MESSAGE =
'Success'
FAILURE_MESSAGE =
'The transaction was declined'

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::DEBIT_CARDS, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#card_brand, card_brand, #generate_unique_id, inherited, #scrub, 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 = {}) ⇒ PsigateGateway

Returns a new instance of PsigateGateway.



49
50
51
52
# File 'lib/active_merchant/billing/gateways/psigate.rb', line 49

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

Instance Method Details

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



54
55
56
57
58
# File 'lib/active_merchant/billing/gateways/psigate.rb', line 54

def authorize(money, creditcard, options = {})
  requires!(options, :order_id)
  options[:CardAction] = "1"
  commit(money, creditcard, options)
end

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



66
67
68
69
70
# File 'lib/active_merchant/billing/gateways/psigate.rb', line 66

def capture(money, authorization, options = {})
  options[:CardAction] = "2"
  options[:order_id], options[:trans_ref_number] = split_authorization(authorization)
  commit(money, nil, options)
end

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



72
73
74
75
# File 'lib/active_merchant/billing/gateways/psigate.rb', line 72

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

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



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

def purchase(money, creditcard, options = {})
  requires!(options, :order_id)
  options[:CardAction] = "0"
  commit(money, creditcard, options)
end

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



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

def refund(money, authorization, options = {})
  options[:CardAction] = "3"
  options[:order_id], options[:trans_ref_number] = split_authorization(authorization)
  commit(money, nil, options)
end

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



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

def void(authorization, options = {})
  options[:CardAction] = "9"
  options[:order_id], options[:trans_ref_number] = split_authorization(authorization)
  commit(nil, nil, options)
end