class Mollie::Payment

Constants

RECURRINGTYPE_FIRST
RECURRINGTYPE_NONE
RECURRINGTYPE_RECURRING
STATUS_AUTHORIZED
STATUS_CANCELED
STATUS_EXPIRED
STATUS_FAILED
STATUS_OPEN
STATUS_PAID
STATUS_PENDING

Attributes

amount[RW]
amount_captured[RW]
amount_charged_back[RW]
amount_refunded[RW]
amount_remaining[RW]
application_fee[RW]
authorized_at[RW]
cancel_url[RW]
canceled_at[RW]
country_code[RW]
created_at[RW]
customer_id[RW]
description[RW]
details[RW]
expired_at[RW]
expires_at[RW]
failed_at[RW]
id[RW]
is_cancelable[RW]
locale[RW]
mandate_id[RW]
metadata[RW]
method[RW]
mode[RW]
order_id[RW]
paid_at[RW]
profile_id[RW]
redirect_url[RW]
restrict_payment_methods_to_country[RW]
sequence_type[RW]
settlement_amount[RW]
settlement_id[RW]
status[RW]
subscription_id[RW]
webhook_url[RW]

Public Instance Methods

amount=(amount) click to toggle source
# File lib/mollie/payment.rb, line 164
def amount=(amount)
  @amount = Mollie::Amount.new(amount)
end
amount_captured=(amount_captured) click to toggle source
# File lib/mollie/payment.rb, line 172
def amount_captured=(amount_captured)
  @amount_captured = Mollie::Amount.new(amount_captured)
end
amount_charged_back=(amount_charged_back) click to toggle source
# File lib/mollie/payment.rb, line 176
def amount_charged_back=(amount_charged_back)
  @amount_charged_back = Mollie::Amount.new(amount_charged_back)
end
amount_refunded=(amount_refunded) click to toggle source
# File lib/mollie/payment.rb, line 184
def amount_refunded=(amount_refunded)
  @amount_refunded = Mollie::Amount.new(amount_refunded)
end
amount_remaining=(amount_remaining) click to toggle source
# File lib/mollie/payment.rb, line 180
def amount_remaining=(amount_remaining)
  @amount_remaining = Mollie::Amount.new(amount_remaining)
end
application_fee=(application_fee) click to toggle source
# File lib/mollie/payment.rb, line 94
def application_fee=(application_fee)
  amount      = Amount.new(application_fee['amount'])
  description = application_fee['description']

  @application_fee = OpenStruct.new(
    amount: amount,
    description: description
  )
end
authorized?() click to toggle source
# File lib/mollie/payment.rb, line 78
def authorized?
  status == STATUS_AUTHORIZED
end
authorized_at=(authorized_at) click to toggle source
# File lib/mollie/payment.rb, line 120
def authorized_at=(authorized_at)
  @authorized_at = begin
                     Time.parse(authorized_at.to_s)
                   rescue StandardError
                     nil
                   end
end
cancelable?() click to toggle source
# File lib/mollie/payment.rb, line 90
def cancelable?
  is_cancelable
end
canceled?() click to toggle source
# File lib/mollie/payment.rb, line 58
def canceled?
  status == STATUS_CANCELED
end
canceled_at=(canceled_at) click to toggle source
# File lib/mollie/payment.rb, line 136
def canceled_at=(canceled_at)
  @canceled_at = begin
                   Time.parse(canceled_at.to_s)
                 rescue StandardError
                   nil
                 end
end
captures(options = {}) click to toggle source
# File lib/mollie/payment.rb, line 207
def captures(options = {})
  Payment::Capture.all(options.merge(payment_id: id))
end
chargebacks(options = {}) click to toggle source
# File lib/mollie/payment.rb, line 203
def chargebacks(options = {})
  Payment::Chargeback.all(options.merge(payment_id: id))
end
checkout_url() click to toggle source
# File lib/mollie/payment.rb, line 188
def checkout_url
  Util.extract_url(links, 'checkout')
end
created_at=(created_at) click to toggle source
# File lib/mollie/payment.rb, line 112
def created_at=(created_at)
  @created_at = begin
                  Time.parse(created_at.to_s)
                rescue StandardError
                  nil
                end
end
customer(options = {}) click to toggle source
# File lib/mollie/payment.rb, line 211
def customer(options = {})
  return if customer_id.nil?
  Customer.get(customer_id, options)
end
details=(details) click to toggle source
# File lib/mollie/payment.rb, line 104
def details=(details)
  @details = OpenStruct.new(details) if details.is_a?(Hash)
end
expired?() click to toggle source
# File lib/mollie/payment.rb, line 66
def expired?
  status == STATUS_EXPIRED
end
expired_at=(expired_at) click to toggle source
# File lib/mollie/payment.rb, line 144
def expired_at=(expired_at)
  @expired_at = begin
                  Time.parse(expired_at.to_s)
                rescue StandardError
                  nil
                end
end
expires_at=(expires_at) click to toggle source
# File lib/mollie/payment.rb, line 152
def expires_at=(expires_at)
  @expires_at = begin
                  Time.parse(expires_at.to_s)
                rescue StandardError
                  nil
                end
end
failed?() click to toggle source
# File lib/mollie/payment.rb, line 70
def failed?
  status == STATUS_FAILED
end
failed_at=(failed_at) click to toggle source
# File lib/mollie/payment.rb, line 160
def failed_at=(failed_at)
  @failed_at = Time.parse(failed_at)
end
mandate(options = {}) click to toggle source
# 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
metadata=(metadata) click to toggle source
# File lib/mollie/payment.rb, line 108
def metadata=(metadata)
  @metadata = OpenStruct.new(metadata) if metadata.is_a?(Hash)
end
open?() click to toggle source
# File lib/mollie/payment.rb, line 54
def open?
  status == STATUS_OPEN
end
order(options = {}) click to toggle source
# File lib/mollie/payment.rb, line 235
def order(options = {})
  return if order_id.nil?
  Order.get(order_id, options)
end
paid?() click to toggle source
paid_at=(paid_at) click to toggle source
pending?() click to toggle source
# File lib/mollie/payment.rb, line 62
def pending?
  status == STATUS_PENDING
end
refund!(options = {}) click to toggle source
# 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?() click to toggle source
# File lib/mollie/payment.rb, line 82
def refunded?
  if amount_refunded
    amount_refunded.value > 0
  else
    false
  end
end
refunds(options = {}) click to toggle source
# File lib/mollie/payment.rb, line 199
def refunds(options = {})
  Payment::Refund.all(options.merge(payment_id: id))
end
settlement(options = {}) click to toggle source
# File lib/mollie/payment.rb, line 223
def settlement(options = {})
  return if settlement_id.nil?
  Settlement.get(settlement_id, options)
end
settlement_amount=(settlement_amount) click to toggle source
# File lib/mollie/payment.rb, line 168
def settlement_amount=(settlement_amount)
  @settlement_amount = Mollie::Amount.new(settlement_amount)
end
subscription(options = {}) click to toggle source
# 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