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



8
9
10
11
12
# File 'lib/killbill_client/models/transaction.rb', line 8

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



26
27
28
29
30
# File 'lib/killbill_client/models/transaction.rb', line 26

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



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/killbill_client/models/transaction.rb', line 63

def capture(user = nil, reason = nil, comment = nil, options = {})
  created_transaction = self.class.post "#{follow_up_path(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



101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/killbill_client/models/transaction.rb', line 101

def chargeback(user = nil, reason = nil, comment = nil, options = {})

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

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



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

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



48
49
50
51
# File 'lib/killbill_client/models/transaction.rb', line 48

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



58
59
60
61
# File 'lib/killbill_client/models/transaction.rb', line 58

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



53
54
55
56
# File 'lib/killbill_client/models/transaction.rb', line 53

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



20
21
22
23
24
# File 'lib/killbill_client/models/transaction.rb', line 20

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



38
39
40
41
42
# File 'lib/killbill_client/models/transaction.rb', line 38

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



14
15
16
17
18
# File 'lib/killbill_client/models/transaction.rb', line 14

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



32
33
34
35
36
# File 'lib/killbill_client/models/transaction.rb', line 32

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



75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/killbill_client/models/transaction.rb', line 75

def refund(user = nil, reason = nil, comment = nil, options = {})

  created_transaction = self.class.post "#{follow_up_path(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



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

def void(user = nil, reason = nil, comment = nil, options = {})

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