Class: KillBillClient::Model::InvoicePayment

Inherits:
InvoicePaymentAttributes show all
Includes:
AuditLogWithHistoryHelper, CustomFieldHelper, TagHelper
Defined in:
lib/killbill_client/models/invoice_payment.rb

Constant Summary collapse

KILLBILL_API_INVOICE_PAYMENTS_PREFIX =
"#{KILLBILL_API_PREFIX}/invoicePayments"

Constants included from TagHelper

TagHelper::AUTO_INVOICING_OFF_ID, TagHelper::AUTO_PAY_OFF_ID, TagHelper::MANUAL_PAY_ID, TagHelper::OVERDUE_ENFORCEMENT_OFF_ID, TagHelper::TEST_ID, TagHelper::WRITTEN_OFF_ID

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AuditLogWithHistoryHelper

included

Methods included from TagHelper

#add_tag, #add_tag_from_definition_id, #control_tag?, included, #remove_tag, #remove_tag_from_definition_id, #set_tags

Methods included from CustomFieldHelper

included

Class Method Details

.chargeback(payment_id, amount, currency, effective_date = nil, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/killbill_client/models/invoice_payment.rb', line 48

def chargeback(payment_id, amount, currency, effective_date = nil, user = nil, reason = nil, comment = nil, options = {})
  payload                          = InvoicePaymentTransactionAttributes.new
  payload.amount                   = amount
  payload.currency                 = currency
  payload.effective_date           = effective_date

  invoice_payment = post "#{KILLBILL_API_INVOICE_PAYMENTS_PREFIX}/#{payment_id}/chargebacks",
                         payload.to_json,
                         {},
                         {
                             :user    => user,
                             :reason  => reason,
                             :comment => comment,
                         }.merge(options)
  invoice_payment.refresh(options)
end

.chargeback_reversal(payment_id, transaction_external_key, effective_date = nil, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



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

def chargeback_reversal(payment_id, transaction_external_key, effective_date = nil, user = nil, reason = nil, comment = nil, options = {})
  payload                          = InvoicePaymentTransactionAttributes.new
  payload.transaction_external_key = transaction_external_key
  payload.effective_date           = effective_date

  invoice_payment = post "#{KILLBILL_API_INVOICE_PAYMENTS_PREFIX}/#{payment_id}/chargebackReversals",
                         payload.to_json,
                         {},
                         {
                             :user    => user,
                             :reason  => reason,
                             :comment => comment,
                         }.merge(options)
  invoice_payment.refresh(options)
end

.complete_invoice_payment_transaction(payment_id, user, reason, comment, options) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/killbill_client/models/invoice_payment.rb', line 81

def complete_invoice_payment_transaction(payment_id, user, reason, comment, options)
  invoice_payment = PaymentTransactionAttributes.new
  invoice_payment.payment_id = payment_id

  put "#{KILLBILL_API_INVOICE_PAYMENTS_PREFIX}/#{payment_id}",
      invoice_payment.to_json,
      {},
      {
          :user => user,
          :reason => reason,
          :comment => comment
      }.merge(options)
end

.find_by_id(payment_id, with_plugin_info = false, with_attempts = false, options = {}) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/killbill_client/models/invoice_payment.rb', line 21

def find_by_id(payment_id, with_plugin_info = false, with_attempts = false, options = {})
  get "#{KILLBILL_API_INVOICE_PAYMENTS_PREFIX}/#{payment_id}",
      {
          :withAttempts => with_attempts,
          :withPluginInfo => with_plugin_info
      },
      options
end

.refund(payment_id, amount, adjustments = nil, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/killbill_client/models/invoice_payment.rb', line 30

def refund(payment_id, amount, adjustments = nil, user = nil, reason = nil, comment = nil, options = {})
  payload             = InvoicePaymentTransactionAttributes.new
  payload.amount      = amount
  payload.is_adjusted = !adjustments.nil?
  payload.adjustments = adjustments

  invoice_payment = post "#{KILLBILL_API_INVOICE_PAYMENTS_PREFIX}/#{payment_id}/refunds",
                         payload.to_json,
                         {},
                         {
                             :user    => user,
                             :reason  => reason,
                             :comment => comment,
                         }.merge(options)

  invoice_payment.refresh(options)
end

Instance Method Details

#bulk_create(external_payment = false, payment_method_id = nil, target_date = nil, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/killbill_client/models/invoice_payment.rb', line 110

def bulk_create(external_payment = false, payment_method_id = nil, target_date = nil, user = nil, reason = nil, comment = nil, options = {})
  # Nothing to return (nil)
  self.class.post "#{Account::KILLBILL_API_ACCOUNTS_PREFIX}/#{}/invoicePayments",
                  {},
                  {
                      :externalPayment => external_payment,
                      :paymentAmount   => purchased_amount,
                      :paymentMethodId => payment_method_id,
                      :targetDate => target_date
                  },
                  {
                      :user    => user,
                      :reason  => reason,
                      :comment => comment,
                  }.merge(options)
end

#create(external_payment = false, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/killbill_client/models/invoice_payment.rb', line 96

def create(external_payment = false, user = nil, reason = nil, comment = nil, options = {})
  created_invoice_payment = self.class.post "#{Invoice::KILLBILL_API_INVOICES_PREFIX}/#{target_invoice_id}/payments",
                                            to_json,
                                            {
                                                :externalPayment => external_payment
                                            },
                                            {
                                                :user    => user,
                                                :reason  => reason,
                                                :comment => comment,
                                            }.merge(options)
  created_invoice_payment.refresh(options)
end