Class: ActiveMerchant::Billing::SmartPs

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

Overview

:nodoc:

Direct Known Subclasses

BraintreeOrangeGateway, TransaxGateway

Constant Summary

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 Utils

#deprecated, generate_unique_id

Methods included from CreditCardFormatting

#format

Methods included from RequiresParameters

#requires!

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Constructor Details

#initialize(options = {}) ⇒ SmartPs

This is the base gateway for processors who use the smartPS processing system



10
11
12
13
14
# File 'lib/active_merchant/billing/gateways/smart_ps.rb', line 10

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

Instance Method Details

#amend(auth, options = {}) ⇒ Object

Amend an existing transaction



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

def amend(auth, options = {})
  post = {}
  add_invoice(post, options)
  add_transaction(post, auth)
  commit('update', nil, post)
end

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

Pass :store => true in the options to store the payment info at the gateway and get a generated customer_vault_id in the response.

Pass :store => some_number_or_string to specify the customer_vault_id the gateway should use (make sure it’s unique).



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/active_merchant/billing/gateways/smart_ps.rb', line 22

def authorize(money, creditcard, options = {})
  post = {}
  add_invoice(post, options)
  add_payment_source(post, creditcard,options)
  add_address(post, options[:billing_address] || options[:address])
  add_address(post, options[:shipping_address], "shipping")
  add_customer_data(post, options)
  add_currency(post, money, options)
  add_taxes(post, options)
  add_processor(post, options)
  commit('auth', money, post)
end

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



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

def capture(money, authorization, options = {})
  post ={}
  post[:transactionid] = authorization
  commit('capture', money, post)
end

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



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/active_merchant/billing/gateways/smart_ps.rb', line 60

def credit(money, payment_source, options = {})
  post = {}
  add_invoice(post, options)
  add_payment_source(post, payment_source, options)        
  add_address(post, options[:billing_address] || options[:address])
  add_customer_data(post, options)
  add_sku(post,options)
  add_currency(post, money, options)
  add_processor(post, options)
  commit('credit', money, post)
end

#delete(vault_id) ⇒ Object Also known as: unstore



102
103
104
105
106
107
# File 'lib/active_merchant/billing/gateways/smart_ps.rb', line 102

def delete(vault_id)
  post = {}
  post[:customer_vault] = "delete_customer"
  add_customer_vault_id(post, vault_id)         
  commit(nil, nil, post)
end

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



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/active_merchant/billing/gateways/smart_ps.rb', line 35

def purchase(money, payment_source, options = {})
  post = {}
  add_invoice(post, options)
  add_payment_source(post, payment_source, options)
  add_address(post, options[:billing_address] || options[:address])
  add_address(post, options[:shipping_address], "shipping")
  add_customer_data(post, options)
  add_currency(post, money, options)
  add_taxes(post, options)
  add_processor(post, options)     
  commit('sale', money, post)
end

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



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

def refund(money, auth, options = {})
  post = {}
  add_transaction(post, auth)
  commit('refund', money, post)
end

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

To match the other stored-value gateways, like TrustCommerce, store and unstore need to be defined



111
112
113
114
115
116
117
118
# File 'lib/active_merchant/billing/gateways/smart_ps.rb', line 111

def store(payment_source, options = {})
  post = {}
  billing_id = options.delete(:billing_id).to_s || true
  add_payment_source(post, payment_source, :store => billing_id)
  add_address(post, options[:billing_address] || options[:address])
  add_customer_data(post, options)
  commit(nil, nil, post)
end

#update(vault_id, creditcard, options = {}) ⇒ Object

Update the values (such as CC expiration) stored at the gateway. The CC number must be supplied in the CreditCard object.



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

def update(vault_id, creditcard, options = {})
  post = {}
  post[:customer_vault] = "update_customer"
  add_customer_vault_id(post, vault_id)
  add_creditcard(post, creditcard, options)        
  add_address(post, options[:billing_address] || options[:address])
  add_customer_data(post, options)
       
  commit(nil, nil, post)
end

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



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

def void(authorization, options = {})
  post ={}
  post[:transactionid] = authorization
  commit('void', nil, post)
end