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 => 'jack@yahoo.com'

)

Constant Summary

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

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

- (PsigateGateway) initialize(options = {})

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

- (Object) authorize(money, creditcard, options = {})



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

- (Object) capture(money, authorization, options = {})



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

- (Object) credit(money, authorization, options = {})



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

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

- (Object) purchase(money, creditcard, options = {})



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

- (Object) refund(money, authorization, options = {})



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

- (Object) void(authorization, options = {})



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