Class: ActiveMerchant::Billing::InspireGateway

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

Constant Summary

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 = {}) ⇒ InspireGateway

Creates a new InspireGateway

The gateway requires that a valid login and password be passed in the options hash.

Options

  • :login – The Inspire Username.

  • :password – The Inspire Password.

See the Inspire Integration Guide for details. (default: false)



22
23
24
25
# File 'lib/active_merchant/billing/gateways/inspire.rb', line 22

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

Instance Method Details

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

Pass :store => true in the options to store the payment info at Inspire Gateway and get a generated customer_vault_id in the response. Pass :store => some_number_or_string to specify the customer_vault_id InspireGateway should use (make sure it’s unique).



33
34
35
36
37
38
39
40
41
# File 'lib/active_merchant/billing/gateways/inspire.rb', line 33

def authorize(money, creditcard, options = {})
  post = {}
  add_invoice(post, options)
  add_payment_source(post, creditcard,options)
  add_address(post, creditcard, options)
  add_customer_data(post, options)

  commit('auth', money, post)
end

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



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

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

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



85
86
87
88
89
90
# File 'lib/active_merchant/billing/gateways/inspire.rb', line 85

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



43
44
45
46
47
48
49
50
51
# File 'lib/active_merchant/billing/gateways/inspire.rb', line 43

def purchase(money, payment_source, options = {})
  post = {}
  add_invoice(post, options)
  add_payment_source(post, payment_source, options)
  add_address(post, payment_source, options)
  add_customer_data(post, options)

  commit('sale', money, post)
end

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



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

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

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

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



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

def store(creditcard, options = {})
  billing_id = options.delete(:billing_id).to_s || true
  authorize(100, creditcard, options.merge(:store => billing_id))
end

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

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



74
75
76
77
78
79
80
81
82
83
# File 'lib/active_merchant/billing/gateways/inspire.rb', line 74

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, creditcard, options)
  add_customer_data(post, options)

  commit(nil, nil, post)
end

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



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

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