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



10
11
12
13
14
# File 'lib/killbill_client/models/transaction.rb', line 10

def auth(, payment_method_id = nil, user = nil, reason = nil, comment = nil, options = {})
  @transaction_type = 'AUTHORIZE'
  query_map = {}
  create_initial_transaction("#{Account::KILLBILL_API_ACCOUNTS_PREFIX}/#{}/payments", query_map, payment_method_id, user, reason, comment, options)
end

#auth_by_external_key(account_external_key, payment_method_id = nil, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



28
29
30
31
32
# File 'lib/killbill_client/models/transaction.rb', line 28

def auth_by_external_key(, payment_method_id = nil, user = nil, reason = nil, comment = nil, options = {})
  @transaction_type = 'AUTHORIZE'
  query_map = {:externalKey => }
  create_initial_transaction("#{Account::KILLBILL_API_ACCOUNTS_PREFIX}/payments", query_map, payment_method_id, user, reason, comment, options)
end

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



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

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

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



107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/killbill_client/models/transaction.rb', line 107

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

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



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

def complete(user = nil, reason = nil, comment = nil, options = {})
  complete_initial_transaction(user, reason, comment, options)
end

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



50
51
52
53
# File 'lib/killbill_client/models/transaction.rb', line 50

def complete_auth(user = nil, reason = nil, comment = nil, options = {})
  @transaction_type = 'AUTHORIZE'
  complete_initial_transaction(user, reason, comment, options)
end

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



60
61
62
63
# File 'lib/killbill_client/models/transaction.rb', line 60

def complete_credit(user = nil, reason = nil, comment = nil, options = {})
  @transaction_type = 'CREDIT'
  complete_initial_transaction(user, reason, comment, options)
end

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



55
56
57
58
# File 'lib/killbill_client/models/transaction.rb', line 55

def complete_purchase(user = nil, reason = nil, comment = nil, options = {})
  @transaction_type = 'PURCHASE'
  complete_initial_transaction(user, reason, comment, options)
end

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



22
23
24
25
26
# File 'lib/killbill_client/models/transaction.rb', line 22

def credit(, payment_method_id = nil, user = nil, reason = nil, comment = nil, options = {})
  @transaction_type = 'CREDIT'
  query_map = {}
  create_initial_transaction("#{Account::KILLBILL_API_ACCOUNTS_PREFIX}/#{}/payments", query_map, payment_method_id, user, reason, comment, options)
end

#credit_by_external_key(account_external_key, payment_method_id = nil, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



40
41
42
43
44
# File 'lib/killbill_client/models/transaction.rb', line 40

def credit_by_external_key(, payment_method_id = nil, user = nil, reason = nil, comment = nil, options = {})
  @transaction_type = 'CREDIT'
  query_map = {:externalKey => }
  create_initial_transaction("#{Account::KILLBILL_API_ACCOUNTS_PREFIX}/payments", query_map, payment_method_id, user, reason, comment, options)
end

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



16
17
18
19
20
# File 'lib/killbill_client/models/transaction.rb', line 16

def purchase(, payment_method_id = nil, user = nil, reason = nil, comment = nil, options = {})
  @transaction_type = 'PURCHASE'
  query_map = {}
  create_initial_transaction("#{Account::KILLBILL_API_ACCOUNTS_PREFIX}/#{}/payments", query_map, payment_method_id, user, reason, comment, options)
end

#purchase_by_external_key(account_external_key, payment_method_id = nil, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



34
35
36
37
38
# File 'lib/killbill_client/models/transaction.rb', line 34

def purchase_by_external_key(, payment_method_id = nil, user = nil, reason = nil, comment = nil, options = {})
  @transaction_type = 'PURCHASE'
  query_map = {:externalKey => }
  create_initial_transaction("#{Account::KILLBILL_API_ACCOUNTS_PREFIX}/payments", query_map, payment_method_id, user, reason, comment, options)
end

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



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

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

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



93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/killbill_client/models/transaction.rb', line 93

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