Class: Workarea::Afterpay::OrderBuilder
- Inherits:
-
Object
- Object
- Workarea::Afterpay::OrderBuilder
- Defined in:
- app/services/workarea/afterpay/order_builder.rb
Defined Under Namespace
Modules: ProductUrl
Instance Attribute Summary collapse
-
#order ⇒ Object
readonly
Returns the value of attribute order.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(order) ⇒ OrderBuilder
constructor
A new instance of OrderBuilder.
Constructor Details
#initialize(order) ⇒ OrderBuilder
Returns a new instance of OrderBuilder.
12 13 14 |
# File 'app/services/workarea/afterpay/order_builder.rb', line 12 def initialize(order) @order = Workarea::Storefront::OrderViewModel.new(order) end |
Instance Attribute Details
#order ⇒ Object (readonly)
Returns the value of attribute order.
9 10 11 |
# File 'app/services/workarea/afterpay/order_builder.rb', line 9 def order @order end |
Instance Method Details
#build ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/services/workarea/afterpay/order_builder.rb', line 16 def build { amount: { amount: order.order_balance.to_s, currency: currency_code, }, merchantReference: order.id, consumer: { phoneNumber: shipping.address.phone_number, givenNames: shipping.address.first_name, surname: shipping.address.last_name, email: order.email }, billing: address(payment.address), shipping: address(shipping.address), items: items, discounts: discounts, merchant: { redirectConfirmUrl: confirm_url, redirectCancelUrl: cancel_url }, taxAmount: { amount: order.tax_total.to_s, currency: currency_code }, shippingAmount: { amount: order.shipping_total.to_s, currency: currency_code } } end |