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



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
# File 'lib/processout/transaction.rb', line 383

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.amount_local = data.fetch(:amount_local, nil)
  self.authorized_amount = data.fetch(:authorized_amount, nil)
  self.authorized_amount_local = data.fetch(:authorized_amount_local, nil)
  self.captured_amount = data.fetch(:captured_amount, nil)
  self.captured_amount_local = data.fetch(:captured_amount_local, nil)
  self.refunded_amount = data.fetch(:refunded_amount, nil)
  self.refunded_amount_local = data.fetch(:refunded_amount_local, nil)
  self.available_amount = data.fetch(:available_amount, nil)
  self.available_amount_local = data.fetch(:available_amount_local, nil)
  self.currency = data.fetch(:currency, nil)
  self.error_code = data.fetch(:error_code, nil)
  self.gateway_name = data.fetch(:gateway_name, 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.voided = data.fetch(:voided, nil)
  self.refunded = data.fetch(:refunded, nil)
  self.chargedback = data.fetch(:chargedback, nil)
  self.received_fraud_notification = data.fetch(:received_fraud_notification, nil)
  self.received_retrieval_request = data.fetch(:received_retrieval_request, 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.gateway_fee_local = data.fetch(:gateway_fee_local, nil)
  self.currency_fee = data.fetch(:currency_fee, nil)
  self. = data.fetch(:metadata, nil)
  self.sandbox = data.fetch(:sandbox, nil)
  self.created_at = data.fetch(:created_at, nil)
  self.chargedback_at = data.fetch(:chargedback_at, nil)
  self.refunded_at = data.fetch(:refunded_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

#amount_localObject

Returns the value of attribute amount_local.



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

def amount_local
  @amount_local
end

#authorizedObject

Returns the value of attribute authorized.



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

def authorized
  @authorized
end

#authorized_amountObject

Returns the value of attribute authorized_amount.



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

def authorized_amount
  @authorized_amount
end

#authorized_amount_localObject

Returns the value of attribute authorized_amount_local.



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

def authorized_amount_local
  @authorized_amount_local
end

#available_amountObject

Returns the value of attribute available_amount.



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

def available_amount
  @available_amount
end

#available_amount_localObject

Returns the value of attribute available_amount_local.



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

def available_amount_local
  @available_amount_local
end

#capturedObject

Returns the value of attribute captured.



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

def captured
  @captured
end

#captured_amountObject

Returns the value of attribute captured_amount.



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

def captured_amount
  @captured_amount
end

#captured_amount_localObject

Returns the value of attribute captured_amount_local.



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

def captured_amount_local
  @captured_amount_local
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

#chargedbackObject

Returns the value of attribute chargedback.



47
48
49
# File 'lib/processout/transaction.rb', line 47

def chargedback
  @chargedback
end

#chargedback_atObject

Returns the value of attribute chargedback_at.



58
59
60
# File 'lib/processout/transaction.rb', line 58

def chargedback_at
  @chargedback_at
end

#created_atObject

Returns the value of attribute created_at.



57
58
59
# File 'lib/processout/transaction.rb', line 57

def created_at
  @created_at
end

#currencyObject

Returns the value of attribute currency.



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

def currency
  @currency
end

#currency_feeObject

Returns the value of attribute currency_fee.



54
55
56
# File 'lib/processout/transaction.rb', line 54

def currency_fee
  @currency_fee
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.



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

def error_code
  @error_code
end

#estimated_feeObject

Returns the value of attribute estimated_fee.



51
52
53
# File 'lib/processout/transaction.rb', line 51

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.



52
53
54
# File 'lib/processout/transaction.rb', line 52

def gateway_fee
  @gateway_fee
end

#gateway_fee_localObject

Returns the value of attribute gateway_fee_local.



53
54
55
# File 'lib/processout/transaction.rb', line 53

def gateway_fee_local
  @gateway_fee_local
end

#gateway_nameObject

Returns the value of attribute gateway_name.



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

def gateway_name
  @gateway_name
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.



55
56
57
# File 'lib/processout/transaction.rb', line 55

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.



50
51
52
# File 'lib/processout/transaction.rb', line 50

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

#received_fraud_notificationObject

Returns the value of attribute received_fraud_notification.



48
49
50
# File 'lib/processout/transaction.rb', line 48

def received_fraud_notification
  @received_fraud_notification
end

#received_retrieval_requestObject

Returns the value of attribute received_retrieval_request.



49
50
51
# File 'lib/processout/transaction.rb', line 49

def received_retrieval_request
  @received_retrieval_request
end

#refundedObject

Returns the value of attribute refunded.



46
47
48
# File 'lib/processout/transaction.rb', line 46

def refunded
  @refunded
end

#refunded_amountObject

Returns the value of attribute refunded_amount.



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

def refunded_amount
  @refunded_amount
end

#refunded_amount_localObject

Returns the value of attribute refunded_amount_local.



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

def refunded_amount_local
  @refunded_amount_local
end

#refunded_atObject

Returns the value of attribute refunded_at.



59
60
61
# File 'lib/processout/transaction.rb', line 59

def refunded_at
  @refunded_at
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.



56
57
58
# File 'lib/processout/transaction.rb', line 56

def sandbox
  @sandbox
end

#statusObject

Returns the value of attribute status.



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

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.



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

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

#voidedObject

Returns the value of attribute voided.



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

def voided
  @voided
end

Instance Method Details

#all(options = {}) ⇒ Object

Get all the transactions. Params:

options

Hash of options



724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
# File 'lib/processout/transaction.rb', line 724

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



669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
# File 'lib/processout/transaction.rb', line 669

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



447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
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
515
516
517
518
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
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
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
600
601
602
603
# File 'lib/processout/transaction.rb', line 447

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? "amount_local"
    self.amount_local = data["amount_local"]
  end
  if data.include? "authorized_amount"
    self.authorized_amount = data["authorized_amount"]
  end
  if data.include? "authorized_amount_local"
    self.authorized_amount_local = data["authorized_amount_local"]
  end
  if data.include? "captured_amount"
    self.captured_amount = data["captured_amount"]
  end
  if data.include? "captured_amount_local"
    self.captured_amount_local = data["captured_amount_local"]
  end
  if data.include? "refunded_amount"
    self.refunded_amount = data["refunded_amount"]
  end
  if data.include? "refunded_amount_local"
    self.refunded_amount_local = data["refunded_amount_local"]
  end
  if data.include? "available_amount"
    self.available_amount = data["available_amount"]
  end
  if data.include? "available_amount_local"
    self.available_amount_local = data["available_amount_local"]
  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? "gateway_name"
    self.gateway_name = data["gateway_name"]
  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? "voided"
    self.voided = data["voided"]
  end
  if data.include? "refunded"
    self.refunded = data["refunded"]
  end
  if data.include? "chargedback"
    self.chargedback = data["chargedback"]
  end
  if data.include? "received_fraud_notification"
    self.received_fraud_notification = data["received_fraud_notification"]
  end
  if data.include? "received_retrieval_request"
    self.received_retrieval_request = data["received_retrieval_request"]
  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? "gateway_fee_local"
    self.gateway_fee_local = data["gateway_fee_local"]
  end
  if data.include? "currency_fee"
    self.currency_fee = data["currency_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
  if data.include? "chargedback_at"
    self.chargedback_at = data["chargedback_at"]
  end
  if data.include? "refunded_at"
    self.refunded_at = data["refunded_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



755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
# File 'lib/processout/transaction.rb', line 755

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



700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
# File 'lib/processout/transaction.rb', line 700

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



440
441
442
# File 'lib/processout/transaction.rb', line 440

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



608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
# File 'lib/processout/transaction.rb', line 608

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.amount_local = data.fetch(:amount_local, self.amount_local)
  self.authorized_amount = data.fetch(:authorized_amount, self.authorized_amount)
  self.authorized_amount_local = data.fetch(:authorized_amount_local, self.authorized_amount_local)
  self.captured_amount = data.fetch(:captured_amount, self.captured_amount)
  self.captured_amount_local = data.fetch(:captured_amount_local, self.captured_amount_local)
  self.refunded_amount = data.fetch(:refunded_amount, self.refunded_amount)
  self.refunded_amount_local = data.fetch(:refunded_amount_local, self.refunded_amount_local)
  self.available_amount = data.fetch(:available_amount, self.available_amount)
  self.available_amount_local = data.fetch(:available_amount_local, self.available_amount_local)
  self.currency = data.fetch(:currency, self.currency)
  self.error_code = data.fetch(:error_code, self.error_code)
  self.gateway_name = data.fetch(:gateway_name, self.gateway_name)
  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.voided = data.fetch(:voided, self.voided)
  self.refunded = data.fetch(:refunded, self.refunded)
  self.chargedback = data.fetch(:chargedback, self.chargedback)
  self.received_fraud_notification = data.fetch(:received_fraud_notification, self.received_fraud_notification)
  self.received_retrieval_request = data.fetch(:received_retrieval_request, self.received_retrieval_request)
  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.gateway_fee_local = data.fetch(:gateway_fee_local, self.gateway_fee_local)
  self.currency_fee = data.fetch(:currency_fee, self.currency_fee)
  self. = data.fetch(:metadata, self.)
  self.sandbox = data.fetch(:sandbox, self.sandbox)
  self.created_at = data.fetch(:created_at, self.created_at)
  self.chargedback_at = data.fetch(:chargedback_at, self.chargedback_at)
  self.refunded_at = data.fetch(:refunded_at, self.refunded_at)
  
  self
end