Class: Mollie::Order

Inherits:
Base
  • Object
show all
Defined in:
lib/mollie/order.rb,
lib/mollie/order/line.rb,
lib/mollie/order/refund.rb,
lib/mollie/order/payment.rb,
lib/mollie/order/shipment.rb

Defined Under Namespace

Classes: Line, Payment, Refund, Shipment

Constant Summary collapse

STATUS_PENDING =
'pending'.freeze
STATUS_AUTHORIZED =
'authorized'.freeze
STATUS_PAID =
'paid'.freeze
STATUS_SHIPPING =
'shipping'.freeze
STATUS_EXPIRED =
'expired'.freeze
STATUS_CANCELED =
'canceled'.freeze
STATUS_COMPLETED =
'completed'.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.



11
12
13
# File 'lib/mollie/order.rb', line 11

def _links
  @_links
end

#amountObject

Returns the value of attribute amount.



11
12
13
# File 'lib/mollie/order.rb', line 11

def amount
  @amount
end

#amount_capturedObject

Returns the value of attribute amount_captured.



11
12
13
# File 'lib/mollie/order.rb', line 11

def amount_captured
  @amount_captured
end

#amount_refundedObject

Returns the value of attribute amount_refunded.



11
12
13
# File 'lib/mollie/order.rb', line 11

def amount_refunded
  @amount_refunded
end

#authorized_atObject

Returns the value of attribute authorized_at.



11
12
13
# File 'lib/mollie/order.rb', line 11

def authorized_at
  @authorized_at
end

#billing_addressObject

Returns the value of attribute billing_address.



11
12
13
# File 'lib/mollie/order.rb', line 11

def billing_address
  @billing_address
end

#cancel_urlObject

Returns the value of attribute cancel_url.



11
12
13
# File 'lib/mollie/order.rb', line 11

def cancel_url
  @cancel_url
end

#canceled_atObject

Returns the value of attribute canceled_at.



11
12
13
# File 'lib/mollie/order.rb', line 11

def canceled_at
  @canceled_at
end

#completed_atObject

Returns the value of attribute completed_at.



11
12
13
# File 'lib/mollie/order.rb', line 11

def completed_at
  @completed_at
end

#consumer_date_of_birthObject

Returns the value of attribute consumer_date_of_birth.



11
12
13
# File 'lib/mollie/order.rb', line 11

def consumer_date_of_birth
  @consumer_date_of_birth
end

#created_atObject

Returns the value of attribute created_at.



11
12
13
# File 'lib/mollie/order.rb', line 11

def created_at
  @created_at
end

#expired_atObject

Returns the value of attribute expired_at.



11
12
13
# File 'lib/mollie/order.rb', line 11

def expired_at
  @expired_at
end

#expires_atObject

Returns the value of attribute expires_at.



11
12
13
# File 'lib/mollie/order.rb', line 11

def expires_at
  @expires_at
end

#idObject

Returns the value of attribute id.



11
12
13
# File 'lib/mollie/order.rb', line 11

def id
  @id
end

#is_cancelableObject

Returns the value of attribute is_cancelable.



11
12
13
# File 'lib/mollie/order.rb', line 11

def is_cancelable
  @is_cancelable
end

#linesObject

Returns the value of attribute lines.



11
12
13
# File 'lib/mollie/order.rb', line 11

def lines
  @lines
end

#localeObject

Returns the value of attribute locale.



11
12
13
# File 'lib/mollie/order.rb', line 11

def locale
  @locale
end

#metadataObject

Returns the value of attribute metadata.



11
12
13
# File 'lib/mollie/order.rb', line 11

def 
  @metadata
end

#methodObject

Returns the value of attribute method.



11
12
13
# File 'lib/mollie/order.rb', line 11

def method
  @method
end

#modeObject

Returns the value of attribute mode.



11
12
13
# File 'lib/mollie/order.rb', line 11

def mode
  @mode
end

#order_numberObject

Returns the value of attribute order_number.



11
12
13
# File 'lib/mollie/order.rb', line 11

def order_number
  @order_number
end

Returns the value of attribute paid_at.



11
12
13
# File 'lib/mollie/order.rb', line 11

def paid_at
  @paid_at
end

#profile_idObject

Returns the value of attribute profile_id.



11
12
13
# File 'lib/mollie/order.rb', line 11

def profile_id
  @profile_id
end

#redirect_urlObject

Returns the value of attribute redirect_url.



11
12
13
# File 'lib/mollie/order.rb', line 11

def redirect_url
  @redirect_url
end

#shipping_addressObject

Returns the value of attribute shipping_address.



11
12
13
# File 'lib/mollie/order.rb', line 11

def shipping_address
  @shipping_address
end

#shopper_country_must_match_billing_countryObject

Returns the value of attribute shopper_country_must_match_billing_country.



11
12
13
# File 'lib/mollie/order.rb', line 11

def shopper_country_must_match_billing_country
  @shopper_country_must_match_billing_country
end

#statusObject

Returns the value of attribute status.



11
12
13
# File 'lib/mollie/order.rb', line 11

def status
  @status
end

#webhook_urlObject

Returns the value of attribute webhook_url.



11
12
13
# File 'lib/mollie/order.rb', line 11

def webhook_url
  @webhook_url
end

Instance Method Details

#authorized?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/mollie/order.rb', line 46

def authorized?
  status == STATUS_AUTHORIZED
end

#cancelable?Boolean

Returns:

  • (Boolean)


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

def cancelable?
  is_cancelable
end

#canceled?Boolean

Returns:

  • (Boolean)


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

def canceled?
  status == STATUS_CANCELED
end

#checkout_urlObject



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

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

#completed?Boolean

Returns:

  • (Boolean)


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

def completed?
  status == STATUS_COMPLETED
end

#expired?Boolean

Returns:

  • (Boolean)


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

def expired?
  status == STATUS_EXPIRED
end

#paid?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/mollie/order.rb', line 50

def paid?
  status == STATUS_PAID
end

#paymentsObject



134
135
136
137
138
139
140
141
142
# 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?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/mollie/order.rb', line 42

def pending?
  status == STATUS_PENDING
end

#refund!(options = {}) ⇒ Object



166
167
168
169
170
# File 'lib/mollie/order.rb', line 166

def refund!(options = {})
  options[:order_id] = id
  options[:lines] ||= []
  Order::Refund.create(options)
end

#refunds(options = {}) ⇒ Object



144
145
146
147
148
149
150
151
152
153
154
# 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

#shipmentsObject



156
157
158
159
160
161
162
163
164
# 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?Boolean

Returns:

  • (Boolean)


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

def shipping?
  status == STATUS_SHIPPING
end