Class: Mollie::Payment

Inherits:
Base
  • Object
show all
Defined in:
lib/mollie/payment.rb,
lib/mollie/payment/refund.rb,
lib/mollie/payment/capture.rb,
lib/mollie/payment/chargeback.rb

Defined Under Namespace

Classes: Capture, Chargeback, Refund

Constant Summary collapse

STATUS_OPEN =
'open'.freeze
STATUS_CANCELED =
'canceled'.freeze
STATUS_PENDING =
'pending'.freeze
STATUS_EXPIRED =
'expired'.freeze
STATUS_FAILED =
'failed'.freeze
STATUS_PAID =
'paid'.freeze
STATUS_AUTHORIZED =
'authorized'.freeze
RECURRINGTYPE_NONE =
nil
RECURRINGTYPE_FIRST =
'first'.freeze
RECURRINGTYPE_RECURRING =
'recurring'.freeze

Instance Attribute Summary collapse

Attributes inherited from Base

#attributes

Instance Method Summary collapse

Methods inherited from Base

all, #assign_attributes, cancel, create, #delete, delete, get, id_param, #initialize, parent_id, request, resource_name, update, #update

Constructor Details

This class inherits a constructor from Mollie::Base

Instance Attribute Details

Returns the value of attribute _links.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def _links
  @_links
end

#amountObject

Returns the value of attribute amount.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def amount
  @amount
end

#amount_capturedObject

Returns the value of attribute amount_captured.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def amount_captured
  @amount_captured
end

#amount_charged_backObject

Returns the value of attribute amount_charged_back.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def amount_charged_back
  @amount_charged_back
end

#amount_refundedObject

Returns the value of attribute amount_refunded.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def amount_refunded
  @amount_refunded
end

#amount_remainingObject

Returns the value of attribute amount_remaining.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def amount_remaining
  @amount_remaining
end

#application_feeObject

Returns the value of attribute application_fee.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def application_fee
  @application_fee
end

#authorized_atObject

Returns the value of attribute authorized_at.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def authorized_at
  @authorized_at
end

#cancel_urlObject

Returns the value of attribute cancel_url.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def cancel_url
  @cancel_url
end

#canceled_atObject

Returns the value of attribute canceled_at.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def canceled_at
  @canceled_at
end

#country_codeObject

Returns the value of attribute country_code.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def country_code
  @country_code
end

#created_atObject

Returns the value of attribute created_at.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def created_at
  @created_at
end

#customer_idObject

Returns the value of attribute customer_id.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def customer_id
  @customer_id
end

#descriptionObject

Returns the value of attribute description.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def description
  @description
end

#detailsObject

Returns the value of attribute details.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def details
  @details
end

#expired_atObject

Returns the value of attribute expired_at.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def expired_at
  @expired_at
end

#expires_atObject

Returns the value of attribute expires_at.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def expires_at
  @expires_at
end

#failed_atObject

Returns the value of attribute failed_at.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def failed_at
  @failed_at
end

#idObject

Returns the value of attribute id.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def id
  @id
end

#is_cancelableObject

Returns the value of attribute is_cancelable.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def is_cancelable
  @is_cancelable
end

#localeObject

Returns the value of attribute locale.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def locale
  @locale
end

#mandate_idObject

Returns the value of attribute mandate_id.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def mandate_id
  @mandate_id
end

#metadataObject

Returns the value of attribute metadata.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def 
  @metadata
end

#methodObject

Returns the value of attribute method.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def method
  @method
end

#modeObject

Returns the value of attribute mode.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def mode
  @mode
end

#order_idObject

Returns the value of attribute order_id.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def order_id
  @order_id
end

Returns the value of attribute paid_at.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def paid_at
  @paid_at
end

#profile_idObject

Returns the value of attribute profile_id.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def profile_id
  @profile_id
end

#redirect_urlObject

Returns the value of attribute redirect_url.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def redirect_url
  @redirect_url
end

#restrict_payment_methods_to_countryObject

Returns the value of attribute restrict_payment_methods_to_country.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def restrict_payment_methods_to_country
  @restrict_payment_methods_to_country
end

#sequence_typeObject

Returns the value of attribute sequence_type.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def sequence_type
  @sequence_type
end

#settlement_amountObject

Returns the value of attribute settlement_amount.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def settlement_amount
  @settlement_amount
end

#settlement_idObject

Returns the value of attribute settlement_id.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def settlement_id
  @settlement_id
end

#statusObject

Returns the value of attribute status.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def status
  @status
end

#subscription_idObject

Returns the value of attribute subscription_id.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def subscription_id
  @subscription_id
end

#webhook_urlObject

Returns the value of attribute webhook_url.



15
16
17
# File 'lib/mollie/payment.rb', line 15

def webhook_url
  @webhook_url
end

Instance Method Details

#authorized?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/mollie/payment.rb', line 78

def authorized?
  status == STATUS_AUTHORIZED
end

#cancelable?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/mollie/payment.rb', line 90

def cancelable?
  is_cancelable
end

#canceled?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/mollie/payment.rb', line 58

def canceled?
  status == STATUS_CANCELED
end

#captures(options = {}) ⇒ Object



207
208
209
# File 'lib/mollie/payment.rb', line 207

def captures(options = {})
  Payment::Capture.all(options.merge(payment_id: id))
end

#chargebacks(options = {}) ⇒ Object



203
204
205
# File 'lib/mollie/payment.rb', line 203

def chargebacks(options = {})
  Payment::Chargeback.all(options.merge(payment_id: id))
end

#checkout_urlObject



188
189
190
# File 'lib/mollie/payment.rb', line 188

def checkout_url
  Util.extract_url(links, 'checkout')
end

#customer(options = {}) ⇒ Object



211
212
213
214
# File 'lib/mollie/payment.rb', line 211

def customer(options = {})
  return if customer_id.nil?
  Customer.get(customer_id, options)
end

#expired?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/mollie/payment.rb', line 66

def expired?
  status == STATUS_EXPIRED
end

#failed?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/mollie/payment.rb', line 70

def failed?
  status == STATUS_FAILED
end

#mandate(options = {}) ⇒ Object



216
217
218
219
220
221
# File 'lib/mollie/payment.rb', line 216

def mandate(options = {})
  return if customer_id.nil?
  return if mandate_id.nil?
  options = options.merge(customer_id: customer_id)
  Customer::Mandate.get(mandate_id, options)
end

#open?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/mollie/payment.rb', line 54

def open?
  status == STATUS_OPEN
end

#order(options = {}) ⇒ Object



235
236
237
238
# File 'lib/mollie/payment.rb', line 235

def order(options = {})
  return if order_id.nil?
  Order.get(order_id, options)
end

#paid?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/mollie/payment.rb', line 74

def paid?
  status == STATUS_PAID
end

#pending?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/mollie/payment.rb', line 62

def pending?
  status == STATUS_PENDING
end

#refund!(options = {}) ⇒ Object



192
193
194
195
196
197
# File 'lib/mollie/payment.rb', line 192

def refund!(options = {})
  options[:payment_id] = id
  # refund full amount by default
  options[:amount] ||= amount.to_h
  Payment::Refund.create(options)
end

#refunded?Boolean

Returns:

  • (Boolean)


82
83
84
85
86
87
88
# File 'lib/mollie/payment.rb', line 82

def refunded?
  if amount_refunded
    amount_refunded.value > 0
  else
    false
  end
end

#refunds(options = {}) ⇒ Object



199
200
201
# File 'lib/mollie/payment.rb', line 199

def refunds(options = {})
  Payment::Refund.all(options.merge(payment_id: id))
end

#settlement(options = {}) ⇒ Object



223
224
225
226
# File 'lib/mollie/payment.rb', line 223

def settlement(options = {})
  return if settlement_id.nil?
  Settlement.get(settlement_id, options)
end

#subscription(options = {}) ⇒ Object



228
229
230
231
232
233
# File 'lib/mollie/payment.rb', line 228

def subscription(options = {})
  return if customer_id.nil?
  return if subscription_id.nil?
  options = options.merge(customer_id: customer_id)
  Customer::Subscription.get(subscription_id, options)
end