Class: NMIGateway::Transaction

Inherits:
Api
  • Object
show all
Defined in:
lib/nmi_gateway/transaction.rb

Constant Summary

Constants inherited from Api

Api::QUERY_URL, Api::TRANSACTION_URL

Instance Attribute Summary

Attributes inherited from Api

#query, #security_key

Instance Method Summary collapse

Methods inherited from Api

#get, #initialize, #post

Constructor Details

This class inherits a constructor from NMIGateway::Api

Instance Method Details

#authorize(options = {}) ⇒ Object

NMIGateway::Transaction.new.authorize ccnumber: ‘4111111111111111’, ccexp: “0219”, first_name: “John”, last_name: “Doe”, amount: 22.25, email: “[email protected]”, country: “US” NMIGateway::Transaction.new.authorize payment_token: ‘abc123’, first_name: “John”, last_name: “Doe”, amount: 22.25, email: “[email protected]”, country: “US” NMIGateway::Transaction.new.authorize customer_vault_id: ‘123456789’, amount: 22.25



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/nmi_gateway/transaction.rb', line 23

def authorize(options = {})
  query = set_query(options)
  query[:type] = 'auth'
  if query[:customer_vault_id]
    require_fields(:customer_vault_id, :amount)
  elsif query[:payment_token]
    require_fields(:payment_token, :first_name, :last_name, :email, :amount)
  else
    require_fields(:ccnumber, :ccexp, :first_name, :last_name, :email, :amount)
  end
  post query
end

#capture(options = {}) ⇒ Object

NMIGateway::Transaction.new.capture transactionid: 3261830498, amount: 22.30



37
38
39
40
41
42
# File 'lib/nmi_gateway/transaction.rb', line 37

def capture(options = {})
  query = set_query(options)
  query[:type] = 'capture'
  require_fields(:transactionid, :amount )
  post query
end

#credit(options = {}) ⇒ Object

Disabled for our merchant account NMIGateway::Transaction.new.credit ccnumber: ‘4111111111111111’, ccexp: “0219”, first_name: “John”, last_name: “Doe”, amount: 22.30, email: “[email protected]”, country: “US” NMIGateway::Transaction.new.credit payment_token: ‘abc123’, first_name: “John”, last_name: “Doe”, amount: 22.30, email: “[email protected]”, country: “US” NMIGateway::Transaction.new.credit customer_vault_id: ‘123456789’, amount: 22.30



79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/nmi_gateway/transaction.rb', line 79

def credit(options = {})
  query = set_query(options)
  query[:type] = 'credit'
  if query[:customer_vault_id]
    require_fields(:customer_vault_id, :amount)
  elsif query[:payment_token]
    require_fields(:payment_token, :first_name, :last_name, :email, :amount)
  else
    require_fields(:ccnumber, :ccexp, :first_name, :last_name, :email, :amount)
  end
  post query
end

#find(options = {}) ⇒ Object

NMIGateway::Transaction.new.find transaction_id: 3261844010



69
70
71
72
73
# File 'lib/nmi_gateway/transaction.rb', line 69

def find(options = {})
  query = set_query(options)
  query[:report_type] ||= 'transaction'
  get query
end

#refund(options = {}) ⇒ Object

NMIGateway::Transaction.new.refund transactionid: 3261844010, amount: 5



53
54
55
56
57
58
# File 'lib/nmi_gateway/transaction.rb', line 53

def refund(options = {})
  query = set_query(options)
  query[:type] = 'refund'
  require_fields(:transactionid) # amount
  post query
end

#sale(options = {}) ⇒ Object

NMIGateway::Transaction.new.sale ccnumber: ‘4111111111111111’, ccexp: “0219”, first_name: “John”, last_name: “Doe”, amount: 22.30, email: “[email protected]”, country: “US” NMIGateway::Transaction.new.sale payment_token: ‘abc123’, first_name: “John”, last_name: “Doe”, amount: 22.30, email: “[email protected]”, country: “US” NMIGateway::Transaction.new.sale customer_vault_id: ‘123456789’, amount: 22.30



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/nmi_gateway/transaction.rb', line 7

def sale(options = {})
  query = set_query(options)
  query[:type] = 'sale'
  if query[:customer_vault_id]
    require_fields(:customer_vault_id, :amount)
  elsif query[:payment_token]
    require_fields(:payment_token, :first_name, :last_name, :email, :amount)
  else
    require_fields(:ccnumber, :ccexp, :first_name, :last_name, :email, :amount)
  end
  post query
end

#update(options = {}) ⇒ Object

NMIGateway::Transaction.new.update transactionid: 3261844010, first_name: “joe”



61
62
63
64
65
66
# File 'lib/nmi_gateway/transaction.rb', line 61

def update(options = {})
  query = set_query(options)
  query[:type] = 'update'
  require_fields(:transactionid)
  post query
end

#validate(options = {}) ⇒ Object

Disabled for our merchant account NMIGateway::Transaction.new.validate ccnumber: ‘4111111111111111’, ccexp: “0219”, first_name: “John”, last_name: “Doe”, email: “[email protected]”, country: “US” NMIGateway::Transaction.new.validate payment_token: ‘abc123’, first_name: “John”, last_name: “Doe”, email: “[email protected]”, country: “US” NMIGateway::Transaction.new.validate customer_vault_id: ‘123456789’



96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/nmi_gateway/transaction.rb', line 96

def validate(options = {})
  query = set_query(options)
  query[:type] = 'validate'
  if query[:customer_vault_id]
    require_fields(:customer_vault_id)
  elsif query[:payment_token]
    require_fields(:payment_token, :first_name, :last_name, :email)
  else
    require_fields(:ccnumber, :ccexp, :first_name, :last_name, :email)
  end
  post query
end

#void(options = {}) ⇒ Object

NMIGateway::Transaction.new.void transactionid: 3261830498, amount: 22.30



45
46
47
48
49
50
# File 'lib/nmi_gateway/transaction.rb', line 45

def void(options = {})
  query = set_query(options)
  query[:type] = 'void'
  require_fields(:transactionid)
  post query
end