Class: ProcessOut::Transaction

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Transaction

Initializes the Transaction object Params:

client

ProcessOut client instance



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/processout/transaction.rb', line 136

def initialize(client)
  @client = client

  @id = ""
  @project = nil
  @subscription = nil
  @customer = nil
  @token = nil
  @card = nil
  @name = ""
  @authorized_amount = ""
  @captured_amount = ""
  @currency = ""
  @status = ""
  @authorized = false
  @captured = false
  @processout_fee = ""
   = Hash.new
  @sandbox = false
  @created_at = ""
  
end

Instance Attribute Details

#authorizedObject

Returns the value of attribute authorized.



21
22
23
# File 'lib/processout/transaction.rb', line 21

def authorized
  @authorized
end

#authorized_amountObject

Returns the value of attribute authorized_amount.



17
18
19
# File 'lib/processout/transaction.rb', line 17

def authorized_amount
  @authorized_amount
end

#capturedObject

Returns the value of attribute captured.



22
23
24
# File 'lib/processout/transaction.rb', line 22

def captured
  @captured
end

#captured_amountObject

Returns the value of attribute captured_amount.



18
19
20
# File 'lib/processout/transaction.rb', line 18

def captured_amount
  @captured_amount
end

#cardObject

Returns the value of attribute card.



15
16
17
# File 'lib/processout/transaction.rb', line 15

def card
  @card
end

#created_atObject

Returns the value of attribute created_at.



26
27
28
# File 'lib/processout/transaction.rb', line 26

def created_at
  @created_at
end

#currencyObject

Returns the value of attribute currency.



19
20
21
# File 'lib/processout/transaction.rb', line 19

def currency
  @currency
end

#customerObject

Returns the value of attribute customer.



13
14
15
# File 'lib/processout/transaction.rb', line 13

def customer
  @customer
end

#idObject

Returns the value of attribute id.



10
11
12
# File 'lib/processout/transaction.rb', line 10

def id
  @id
end

#metadataObject

Returns the value of attribute metadata.



24
25
26
# File 'lib/processout/transaction.rb', line 24

def 
  
end

#nameObject

Returns the value of attribute name.



16
17
18
# File 'lib/processout/transaction.rb', line 16

def name
  @name
end

#processout_feeObject

Returns the value of attribute processout_fee.



23
24
25
# File 'lib/processout/transaction.rb', line 23

def processout_fee
  @processout_fee
end

#projectObject

Returns the value of attribute project.



11
12
13
# File 'lib/processout/transaction.rb', line 11

def project
  @project
end

#sandboxObject

Returns the value of attribute sandbox.



25
26
27
# File 'lib/processout/transaction.rb', line 25

def sandbox
  @sandbox
end

#statusObject

Returns the value of attribute status.



20
21
22
# File 'lib/processout/transaction.rb', line 20

def status
  @status
end

#subscriptionObject

Returns the value of attribute subscription.



12
13
14
# File 'lib/processout/transaction.rb', line 12

def subscription
  @subscription
end

#tokenObject

Returns the value of attribute token.



14
15
16
# File 'lib/processout/transaction.rb', line 14

def token
  @token
end

Instance Method Details

#all(options = nil) ⇒ Object

Get all the transactions. Params:

options

Hash of options



249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/processout/transaction.rb', line 249

def all(options = nil)
  request = Request.new(@client)
  path    = "/transactions"
  data    = {

  }

  response = Response.new(request.get(path, data, options))
  return_values = Array.new
  
  a    = Array.new
  body = response.body
  for v in body['transactions']
    tmp = Transaction(@client)
    tmp.fill_with_data(v)
    a.push(tmp)
  end

  return_values.push(a)
  

  
  return_values[0]
end

#fill_with_data(data) ⇒ Object

Fills the object with data coming from the API Params:

data

Hash of data coming from the API



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/processout/transaction.rb', line 162

def fill_with_data(data)
  if data.include? "id"
    @id = data["id"]
  end
  if data.include? "project"
    @project = data["project"]
  end
  if data.include? "subscription"
    @subscription = data["subscription"]
  end
  if data.include? "customer"
    @customer = data["customer"]
  end
  if data.include? "token"
    @token = data["token"]
  end
  if data.include? "card"
    @card = data["card"]
  end
  if data.include? "name"
    @name = data["name"]
  end
  if data.include? "authorized_amount"
    @authorized_amount = data["authorized_amount"]
  end
  if data.include? "captured_amount"
    @captured_amount = data["captured_amount"]
  end
  if data.include? "currency"
    @currency = data["currency"]
  end
  if data.include? "status"
    @status = data["status"]
  end
  if data.include? "authorized"
    @authorized = data["authorized"]
  end
  if data.include? "captured"
    @captured = data["captured"]
  end
  if data.include? "processout_fee"
    @processout_fee = data["processout_fee"]
  end
  if data.include? "metadata"
     = data["metadata"]
  end
  if data.include? "sandbox"
    @sandbox = data["sandbox"]
  end
  if data.include? "created_at"
    @created_at = data["created_at"]
  end
  
  self
end

#find(transaction_id, options = nil) ⇒ Object

Find a transaction by its ID. Params:

transaction_id

ID of the transaction

options

Hash of options



278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/processout/transaction.rb', line 278

def find(transaction_id, options = nil)
  request = Request.new(@client)
  path    = "/transactions/" + CGI.escape(transaction_id) + ""
  data    = {

  }

  response = Response.new(request.get(path, data, options))
  return_values = Array.new
  
  body = response.body
  body = body["transaction"]
  
  
  obj = Transaction.new(@client)
  return_values.push(obj.fill_with_data(body))
  

  
  return_values[0]
end

#refunds(options = nil) ⇒ Object

Get the transaction’s refunds. Params:

options

Hash of options



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/processout/transaction.rb', line 221

def refunds(options = nil)
  request = Request.new(@client)
  path    = "/transactions/" + CGI.escape(@id) + "/refunds"
  data    = {

  }

  response = Response.new(request.get(path, data, options))
  return_values = Array.new
  
  a    = Array.new
  body = response.body
  for v in body['refunds']
    tmp = Refund(@client)
    tmp.fill_with_data(v)
    a.push(tmp)
  end

  return_values.push(a)
  

  
  return_values[0]
end