Class: KillBillClient::Model::Transaction

Inherits:
PaymentTransactionAttributes show all
Defined in:
lib/killbill_client/models/transaction.rb

Constant Summary

Constants inherited from Resource

Resource::KILLBILL_API_PAGINATION_PREFIX, Resource::KILLBILL_API_PREFIX

Instance Attribute Summary

Attributes inherited from Resource

#clazz, #etag, #response, #session_id, #uri

Instance Method Summary collapse

Methods inherited from Resource

#==, #_to_hash, attribute, create_alias, delete, extract_session_id, from_json, from_response, get, has_many, has_one, #hash, head, #initialize, instantiate_record_from_json, post, put, #refresh, require_multi_tenant_options!, #to_hash, #to_json

Constructor Details

This class inherits a constructor from KillBillClient::Model::Resource

Instance Method Details

#auth(account_id, payment_method_id = nil, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/killbill_client/models/transaction.rb', line 7

def auth(, payment_method_id = nil, user = nil, reason = nil, comment = nil, options = {})
  query_map                   = {}
  query_map[:paymentMethodId] = payment_method_id unless payment_method_id.nil?

  @transaction_type   = 'AUTHORIZE'
  created_transaction = self.class.post "#{Account::KILLBILL_API_ACCOUNTS_PREFIX}/#{}/payments",
                                        to_json,
                                        query_map,
                                        {
                                            :user    => user,
                                            :reason  => reason,
                                            :comment => comment,
                                        }.merge(options)
  created_transaction.refresh(options, Payment)
end

#capture(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/killbill_client/models/transaction.rb', line 55

def capture(user = nil, reason = nil, comment = nil, options = {})
  created_transaction = self.class.post "#{Payment::KILLBILL_API_PAYMENTS_PREFIX}/#{payment_id}",
                                        to_json,
                                        {},
                                        {
                                            :user    => user,
                                            :reason  => reason,
                                            :comment => comment,
                                        }.merge(options)
  created_transaction.refresh(options, Payment)
end

#chargeback(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
# File 'lib/killbill_client/models/transaction.rb', line 91

def chargeback(user = nil, reason = nil, comment = nil, options = {})
  created_transaction = self.class.post "#{Payment::KILLBILL_API_PAYMENTS_PREFIX}/#{payment_id}/chargebacks",
                                        to_json,
                                        {},
                                        {
                                            :user    => user,
                                            :reason  => reason,
                                            :comment => comment,
                                        }.merge(options)
  created_transaction.refresh(options, Payment)
end

#credit(account_id, payment_method_id = nil, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/killbill_client/models/transaction.rb', line 39

def credit(, payment_method_id = nil, user = nil, reason = nil, comment = nil, options = {})
  query_map                   = {}
  query_map[:paymentMethodId] = payment_method_id unless payment_method_id.nil?

  @transaction_type   = 'CREDIT'
  created_transaction = self.class.post "#{Account::KILLBILL_API_ACCOUNTS_PREFIX}/#{}/payments",
                                        to_json,
                                        query_map,
                                        {
                                            :user    => user,
                                            :reason  => reason,
                                            :comment => comment,
                                        }.merge(options)
  created_transaction.refresh(options, Payment)
end

#purchase(account_id, payment_method_id = nil, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/killbill_client/models/transaction.rb', line 23

def purchase(, payment_method_id = nil, user = nil, reason = nil, comment = nil, options = {})
  query_map                   = {}
  query_map[:paymentMethodId] = payment_method_id unless payment_method_id.nil?

  @transaction_type   = 'PURCHASE'
  created_transaction = self.class.post "#{Account::KILLBILL_API_ACCOUNTS_PREFIX}/#{}/payments",
                                        to_json,
                                        query_map,
                                        {
                                            :user    => user,
                                            :reason  => reason,
                                            :comment => comment,
                                        }.merge(options)
  created_transaction.refresh(options, Payment)
end

#refund(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/killbill_client/models/transaction.rb', line 67

def refund(user = nil, reason = nil, comment = nil, options = {})
  created_transaction = self.class.post "#{Payment::KILLBILL_API_PAYMENTS_PREFIX}/#{payment_id}/refunds",
                                        to_json,
                                        {},
                                        {
                                            :user    => user,
                                            :reason  => reason,
                                            :comment => comment,
                                        }.merge(options)
  created_transaction.refresh(options, Payment)
end

#void(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



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

def void(user = nil, reason = nil, comment = nil, options = {})
  created_transaction = self.class.delete "#{Payment::KILLBILL_API_PAYMENTS_PREFIX}/#{payment_id}",
                                          to_json,
                                          {},
                                          {
                                              :user    => user,
                                              :reason  => reason,
                                              :comment => comment,
                                          }.merge(options)
  created_transaction.refresh(options, Payment)
end