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, data = {}) ⇒ Transaction

Initializes the Transaction object Params:

client

ProcessOut client instance

data

data that can be used to fill the object



308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
# File 'lib/processout/transaction.rb', line 308

def initialize(client, data = {})
  @client = client

  self.id = data.fetch(:id, nil)
  self.project = data.fetch(:project, nil)
  self.project_id = data.fetch(:project_id, nil)
  self.invoice = data.fetch(:invoice, nil)
  self.invoice_id = data.fetch(:invoice_id, nil)
  self.customer = data.fetch(:customer, nil)
  self.customer_id = data.fetch(:customer_id, nil)
  self.subscription = data.fetch(:subscription, nil)
  self.subscription_id = data.fetch(:subscription_id, nil)
  self.token = data.fetch(:token, nil)
  self.token_id = data.fetch(:token_id, nil)
  self.card = data.fetch(:card, nil)
  self.card_id = data.fetch(:card_id, nil)
  self.gateway_configuration = data.fetch(:gateway_configuration, nil)
  self.gateway_configuration_id = data.fetch(:gateway_configuration_id, nil)
  self.operations = data.fetch(:operations, nil)
  self.refunds = data.fetch(:refunds, nil)
  self.name = data.fetch(:name, nil)
  self.amount = data.fetch(:amount, nil)
  self.authorized_amount = data.fetch(:authorized_amount, nil)
  self.captured_amount = data.fetch(:captured_amount, nil)
  self.refunded_amount = data.fetch(:refunded_amount, nil)
  self.available_amount = data.fetch(:available_amount, nil)
  self.currency = data.fetch(:currency, nil)
  self.error_code = data.fetch(:error_code, nil)
  self.three_d_s_status = data.fetch(:three_d_s_status, nil)
  self.status = data.fetch(:status, nil)
  self.authorized = data.fetch(:authorized, nil)
  self.captured = data.fetch(:captured, nil)
  self.processout_fee = data.fetch(:processout_fee, nil)
  self.estimated_fee = data.fetch(:estimated_fee, nil)
  self.gateway_fee = data.fetch(:gateway_fee, nil)
  self. = data.fetch(:metadata, nil)
  self.sandbox = data.fetch(:sandbox, nil)
  self.created_at = data.fetch(:created_at, nil)
  
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



28
29
30
# File 'lib/processout/transaction.rb', line 28

def amount
  @amount
end

#authorizedObject

Returns the value of attribute authorized.



37
38
39
# File 'lib/processout/transaction.rb', line 37

def authorized
  @authorized
end

#authorized_amountObject

Returns the value of attribute authorized_amount.



29
30
31
# File 'lib/processout/transaction.rb', line 29

def authorized_amount
  @authorized_amount
end

#available_amountObject

Returns the value of attribute available_amount.



32
33
34
# File 'lib/processout/transaction.rb', line 32

def available_amount
  @available_amount
end

#capturedObject

Returns the value of attribute captured.



38
39
40
# File 'lib/processout/transaction.rb', line 38

def captured
  @captured
end

#captured_amountObject

Returns the value of attribute captured_amount.



30
31
32
# File 'lib/processout/transaction.rb', line 30

def captured_amount
  @captured_amount
end

#cardObject

Returns the value of attribute card.



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

def card
  @card
end

#card_idObject

Returns the value of attribute card_id.



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

def card_id
  @card_id
end

#created_atObject

Returns the value of attribute created_at.



44
45
46
# File 'lib/processout/transaction.rb', line 44

def created_at
  @created_at
end

#currencyObject

Returns the value of attribute currency.



33
34
35
# File 'lib/processout/transaction.rb', line 33

def currency
  @currency
end

#customerObject

Returns the value of attribute customer.



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

def customer
  @customer
end

#customer_idObject

Returns the value of attribute customer_id.



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

def customer_id
  @customer_id
end

#error_codeObject

Returns the value of attribute error_code.



34
35
36
# File 'lib/processout/transaction.rb', line 34

def error_code
  @error_code
end

#estimated_feeObject

Returns the value of attribute estimated_fee.



40
41
42
# File 'lib/processout/transaction.rb', line 40

def estimated_fee
  @estimated_fee
end

#gateway_configurationObject

Returns the value of attribute gateway_configuration.



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

def gateway_configuration
  @gateway_configuration
end

#gateway_configuration_idObject

Returns the value of attribute gateway_configuration_id.



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

def gateway_configuration_id
  @gateway_configuration_id
end

#gateway_feeObject

Returns the value of attribute gateway_fee.



41
42
43
# File 'lib/processout/transaction.rb', line 41

def gateway_fee
  @gateway_fee
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#invoiceObject

Returns the value of attribute invoice.



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

def invoice
  @invoice
end

#invoice_idObject

Returns the value of attribute invoice_id.



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

def invoice_id
  @invoice_id
end

#metadataObject

Returns the value of attribute metadata.



42
43
44
# File 'lib/processout/transaction.rb', line 42

def 
  @metadata
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#operationsObject

Returns the value of attribute operations.



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

def operations
  @operations
end

#processout_feeObject

Returns the value of attribute processout_fee.



39
40
41
# File 'lib/processout/transaction.rb', line 39

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

#project_idObject

Returns the value of attribute project_id.



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

def project_id
  @project_id
end

#refunded_amountObject

Returns the value of attribute refunded_amount.



31
32
33
# File 'lib/processout/transaction.rb', line 31

def refunded_amount
  @refunded_amount
end

#refundsObject

Returns the value of attribute refunds.



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

def refunds
  @refunds
end

#sandboxObject

Returns the value of attribute sandbox.



43
44
45
# File 'lib/processout/transaction.rb', line 43

def sandbox
  @sandbox
end

#statusObject

Returns the value of attribute status.



36
37
38
# File 'lib/processout/transaction.rb', line 36

def status
  @status
end

#subscriptionObject

Returns the value of attribute subscription.



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

def subscription
  @subscription
end

#subscription_idObject

Returns the value of attribute subscription_id.



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

def subscription_id
  @subscription_id
end

#three_d_s_statusObject

Returns the value of attribute three_d_s_status.



35
36
37
# File 'lib/processout/transaction.rb', line 35

def three_d_s_status
  @three_d_s_status
end

#tokenObject

Returns the value of attribute token.



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

def token
  @token
end

#token_idObject

Returns the value of attribute token_id.



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

def token_id
  @token_id
end

Instance Method Details

#all(options = {}) ⇒ Object

Get all the transactions. Params:

options

Hash of options



574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
# File 'lib/processout/transaction.rb', line 574

def all(options = {})
  self.prefill(options)

  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.new(@client)
    tmp.fill_with_data(v)
    a.push(tmp)
  end

  return_values.push(a)
  

  
  return_values[0]
end

#fetch_refunds(options = {}) ⇒ Object

Get the transaction’s refunds. Params:

options

Hash of options



519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
# File 'lib/processout/transaction.rb', line 519

def fetch_refunds(options = {})
  self.prefill(options)

  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.new(@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



357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
# File 'lib/processout/transaction.rb', line 357

def fill_with_data(data)
  if data.nil?
    return self
  end
  if data.include? "id"
    self.id = data["id"]
  end
  if data.include? "project"
    self.project = data["project"]
  end
  if data.include? "project_id"
    self.project_id = data["project_id"]
  end
  if data.include? "invoice"
    self.invoice = data["invoice"]
  end
  if data.include? "invoice_id"
    self.invoice_id = data["invoice_id"]
  end
  if data.include? "customer"
    self.customer = data["customer"]
  end
  if data.include? "customer_id"
    self.customer_id = data["customer_id"]
  end
  if data.include? "subscription"
    self.subscription = data["subscription"]
  end
  if data.include? "subscription_id"
    self.subscription_id = data["subscription_id"]
  end
  if data.include? "token"
    self.token = data["token"]
  end
  if data.include? "token_id"
    self.token_id = data["token_id"]
  end
  if data.include? "card"
    self.card = data["card"]
  end
  if data.include? "card_id"
    self.card_id = data["card_id"]
  end
  if data.include? "gateway_configuration"
    self.gateway_configuration = data["gateway_configuration"]
  end
  if data.include? "gateway_configuration_id"
    self.gateway_configuration_id = data["gateway_configuration_id"]
  end
  if data.include? "operations"
    self.operations = data["operations"]
  end
  if data.include? "refunds"
    self.refunds = data["refunds"]
  end
  if data.include? "name"
    self.name = data["name"]
  end
  if data.include? "amount"
    self.amount = data["amount"]
  end
  if data.include? "authorized_amount"
    self.authorized_amount = data["authorized_amount"]
  end
  if data.include? "captured_amount"
    self.captured_amount = data["captured_amount"]
  end
  if data.include? "refunded_amount"
    self.refunded_amount = data["refunded_amount"]
  end
  if data.include? "available_amount"
    self.available_amount = data["available_amount"]
  end
  if data.include? "currency"
    self.currency = data["currency"]
  end
  if data.include? "error_code"
    self.error_code = data["error_code"]
  end
  if data.include? "three_d_s_status"
    self.three_d_s_status = data["three_d_s_status"]
  end
  if data.include? "status"
    self.status = data["status"]
  end
  if data.include? "authorized"
    self.authorized = data["authorized"]
  end
  if data.include? "captured"
    self.captured = data["captured"]
  end
  if data.include? "processout_fee"
    self.processout_fee = data["processout_fee"]
  end
  if data.include? "estimated_fee"
    self.estimated_fee = data["estimated_fee"]
  end
  if data.include? "gateway_fee"
    self.gateway_fee = data["gateway_fee"]
  end
  if data.include? "metadata"
    self. = data["metadata"]
  end
  if data.include? "sandbox"
    self.sandbox = data["sandbox"]
  end
  if data.include? "created_at"
    self.created_at = data["created_at"]
  end
  
  self
end

#find(transaction_id, options = {}) ⇒ Object

Find a transaction by its ID. Params:

transaction_id

ID of the transaction

options

Hash of options



605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
# File 'lib/processout/transaction.rb', line 605

def find(transaction_id, options = {})
  self.prefill(options)

  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

#find_refund(refund_id, options = {}) ⇒ Object

Find a transaction’s refund by its ID. Params:

refund_id

ID of the refund

options

Hash of options



550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
# File 'lib/processout/transaction.rb', line 550

def find_refund(refund_id, options = {})
  self.prefill(options)

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

  }

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

  
  return_values[0]
end

#new(data = {}) ⇒ Object

Create a new Transaction using the current client



350
351
352
# File 'lib/processout/transaction.rb', line 350

def new(data = {})
  Transaction.new(@client, data)
end

#prefill(data) ⇒ Object

Prefills the object with the data passed as parameters Params:

data

Hash of data



473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
# File 'lib/processout/transaction.rb', line 473

def prefill(data)
  if data.nil?
    return self
  end
  self.id = data.fetch(:id, self.id)
  self.project = data.fetch(:project, self.project)
  self.project_id = data.fetch(:project_id, self.project_id)
  self.invoice = data.fetch(:invoice, self.invoice)
  self.invoice_id = data.fetch(:invoice_id, self.invoice_id)
  self.customer = data.fetch(:customer, self.customer)
  self.customer_id = data.fetch(:customer_id, self.customer_id)
  self.subscription = data.fetch(:subscription, self.subscription)
  self.subscription_id = data.fetch(:subscription_id, self.subscription_id)
  self.token = data.fetch(:token, self.token)
  self.token_id = data.fetch(:token_id, self.token_id)
  self.card = data.fetch(:card, self.card)
  self.card_id = data.fetch(:card_id, self.card_id)
  self.gateway_configuration = data.fetch(:gateway_configuration, self.gateway_configuration)
  self.gateway_configuration_id = data.fetch(:gateway_configuration_id, self.gateway_configuration_id)
  self.operations = data.fetch(:operations, self.operations)
  self.refunds = data.fetch(:refunds, self.refunds)
  self.name = data.fetch(:name, self.name)
  self.amount = data.fetch(:amount, self.amount)
  self.authorized_amount = data.fetch(:authorized_amount, self.authorized_amount)
  self.captured_amount = data.fetch(:captured_amount, self.captured_amount)
  self.refunded_amount = data.fetch(:refunded_amount, self.refunded_amount)
  self.available_amount = data.fetch(:available_amount, self.available_amount)
  self.currency = data.fetch(:currency, self.currency)
  self.error_code = data.fetch(:error_code, self.error_code)
  self.three_d_s_status = data.fetch(:three_d_s_status, self.three_d_s_status)
  self.status = data.fetch(:status, self.status)
  self.authorized = data.fetch(:authorized, self.authorized)
  self.captured = data.fetch(:captured, self.captured)
  self.processout_fee = data.fetch(:processout_fee, self.processout_fee)
  self.estimated_fee = data.fetch(:estimated_fee, self.estimated_fee)
  self.gateway_fee = data.fetch(:gateway_fee, self.gateway_fee)
  self. = data.fetch(:metadata, self.)
  self.sandbox = data.fetch(:sandbox, self.sandbox)
  self.created_at = data.fetch(:created_at, self.created_at)
  
  self
end