class Mollie::Order

Constants

STATUS_AUTHORIZED
STATUS_CANCELED
STATUS_COMPLETED
STATUS_EXPIRED
STATUS_PAID
STATUS_PENDING
STATUS_SHIPPING

Attributes

amount[RW]
amount_captured[RW]
amount_refunded[RW]
authorized_at[RW]
billing_address[RW]
cancel_url[RW]
canceled_at[RW]
completed_at[RW]
consumer_date_of_birth[RW]
created_at[RW]
expired_at[RW]
expires_at[RW]
id[RW]
is_cancelable[RW]
lines[RW]
locale[RW]
metadata[RW]
method[RW]
mode[RW]
order_number[RW]
paid_at[RW]
profile_id[RW]
redirect_url[RW]
shipping_address[RW]
shopper_country_must_match_billing_country[RW]
status[RW]
webhook_url[RW]

Public Instance Methods

amount=(amount) click to toggle source
# File lib/mollie/order.rb, line 82
def amount=(amount)
  @amount = Mollie::Amount.new(amount)
end
amount_captured=(amount) click to toggle source
# File lib/mollie/order.rb, line 86
def amount_captured=(amount)
  @amount_captured = Mollie::Amount.new(amount)
end
amount_refunded=(amount) click to toggle source
# File lib/mollie/order.rb, line 90
def amount_refunded=(amount)
  @amount_refunded = Mollie::Amount.new(amount)
end
authorized?() click to toggle source
# File lib/mollie/order.rb, line 46
def authorized?
  status == STATUS_AUTHORIZED
end
authorized_at=(authorized_at) click to toggle source
# File lib/mollie/order.rb, line 122
def authorized_at=(authorized_at)
  @authorized_at = Time.parse(authorized_at.to_s)
end
billing_address=(address) click to toggle source
# File lib/mollie/order.rb, line 94
def billing_address=(address)
  @billing_address = OpenStruct.new(address) if address.is_a?(Hash)
end
cancelable?() click to toggle source
# File lib/mollie/order.rb, line 70
def cancelable?
  is_cancelable
end
canceled?() click to toggle source
# File lib/mollie/order.rb, line 62
def canceled?
  status == STATUS_CANCELED
end
canceled_at=(canceled_at) click to toggle source
# File lib/mollie/order.rb, line 126
def canceled_at=(canceled_at)
  @canceled_at = Time.parse(canceled_at.to_s)
end
checkout_url() click to toggle source
# File lib/mollie/order.rb, line 74
def checkout_url
  Util.extract_url(links, 'checkout')
end
completed?() click to toggle source
# File lib/mollie/order.rb, line 66
def completed?
  status == STATUS_COMPLETED
end
completed_at=(completed_at) click to toggle source
# File lib/mollie/order.rb, line 130
def completed_at=(completed_at)
  @completed_at = Time.parse(completed_at.to_s)
end
created_at=(created_at) click to toggle source
# File lib/mollie/order.rb, line 106
def created_at=(created_at)
  @created_at = Time.parse(created_at.to_s)
end
expired?() click to toggle source
# File lib/mollie/order.rb, line 58
def expired?
  status == STATUS_EXPIRED
end
expired_at=(expired_at) click to toggle source
# File lib/mollie/order.rb, line 114
def expired_at=(expired_at)
  @expired_at = Time.parse(expired_at.to_s)
end
expires_at=(expires_at) click to toggle source
# File lib/mollie/order.rb, line 110
def expires_at=(expires_at)
  @expires_at = Time.parse(expires_at.to_s)
end
lines=(lines) click to toggle source
# File lib/mollie/order.rb, line 78
def lines=(lines)
  @lines = lines.map { |line| Order::Line.new(line) }
end
metadata=(metadata) click to toggle source
# File lib/mollie/order.rb, line 102
def metadata=(metadata)
  @metadata = OpenStruct.new(metadata) if metadata.is_a?(Hash)
end
paid?() click to toggle source
paid_at=(paid_at) click to toggle source
payments() click to toggle source
# File lib/mollie/order.rb, line 134
def payments
  resources = (attributes['_embedded']['payments'] if attributes['_embedded'])

  if resources.nil?
    List.new({}, Order::Payment)
  else
    List.new({ '_embedded' => { 'payments' => resources } }, Order::Payment)
  end
end
pending?() click to toggle source
# File lib/mollie/order.rb, line 42
def pending?
  status == STATUS_PENDING
end
refund!(options = {}) click to toggle source
# File lib/mollie/order.rb, line 166
def refund!(options = {})
  options[:order_id] = id
  options[:lines] ||= []
  Order::Refund.create(options)
end
refunds(options = {}) click to toggle source
# File lib/mollie/order.rb, line 144
def refunds(options = {})
  resources = (attributes['_embedded']['refunds'] if attributes['_embedded'])

  if resources.nil?
    # To avoid breaking changes, fallback to /v2/order/*orderId*/refunds
    # if the order was retrieved without embedded refunds.
    Order::Refund.all(options.merge(order_id: id))
  else
    List.new({ '_embedded' => { 'refunds' => resources } }, Order::Refund)
  end
end
shipments() click to toggle source
# File lib/mollie/order.rb, line 156
def shipments
  resources = (attributes['_embedded']['shipments'] if attributes['_embedded'])

  if resources.nil?
    List.new({}, Order::Shipment)
  else
    List.new({ '_embedded' => { 'shipments' => resources } }, Order::Shipment)
  end
end
shipping?() click to toggle source
# File lib/mollie/order.rb, line 54
def shipping?
  status == STATUS_SHIPPING
end
shipping_address=(address) click to toggle source
# File lib/mollie/order.rb, line 98
def shipping_address=(address)
  @shipping_address = OpenStruct.new(address) if address.is_a?(Hash)
end