Module: Frontgo::Order

Included in:
Client
Defined in:
lib/frontgo/order.rb

Overview

Instance Method Summary collapse

Instance Method Details

#cancel_order(order_uuid, params) ⇒ Object

Examples:

Cancel an order

client.cancel_order("ODR123456789", {
  cancellationNote: "Customer requested cancellation"
})


88
89
90
# File 'lib/frontgo/order.rb', line 88

def cancel_order(order_uuid, params)
  post "connect/orders/cancel/#{order_uuid}", params
end

#create_session_for_invoice_order(params) ⇒ Object

Examples:

Create an invoice order session

client.create_session_for_invoice_order({
  products: [{ name: "Router", rate: 4500, tax: 12, amount: 4500 }],
  orderSummary: { subTotal: 4017.86, totalTax: 482.14, grandTotal: 4500.00 },
  customerDetails: { name: "Kari Nordmann", email: "[email protected]" },
  submitPayment: { via: "invoice", currency: "NOK" },
  invoiceInterval: 0,
  separateInvoices: true
})


27
28
29
# File 'lib/frontgo/order.rb', line 27

def create_session_for_invoice_order(params)
  post "connect/orders/regular/submit", params
end

Examples:

Create a one-time payment link session

client.create_session_for_one_time_payment_link({
  products: [{ name: "Router", rate: 4500, tax: 12, amount: 4500 }],
  orderSummary: { subTotal: 4017.86, totalTax: 482.14, grandTotal: 4500.00 },
  customerDetails: { name: "Kari Nordmann", email: "[email protected]" },
  submitPayment: { via: "visa", currency: "NOK" },
  callback: { success: "https://example.com/success", failure: "https://example.com/failure" }
})


14
15
16
# File 'lib/frontgo/order.rb', line 14

def create_session_for_one_time_payment_link(params)
  post "connect/orders/regular/submit", params
end

#get_all_order_status(params = {}) ⇒ Object

Can be filtered by status type as query (?type=)

Examples:

Get all order statuses

client.get_all_order_status

Get only paid orders

client.get_all_order_status(type: 'paid')

Get only invoiced orders

client.get_all_order_status(type: 'invoiced')


38
39
40
# File 'lib/frontgo/order.rb', line 38

def get_all_order_status(params = {})
  get "connect/orders/status", params
end

#get_invoice_number_by_uuid(uuid) ⇒ Object

Examples:

Get invoice number for an order

client.get_invoice_number_by_uuid("ODR2005869234")


148
149
150
# File 'lib/frontgo/order.rb', line 148

def get_invoice_number_by_uuid(uuid)
  get "connect/orders/invoice-number/#{uuid}"
end

#get_order_details_by_uuid(uuid) ⇒ Object

Examples:

Get detailed order information

client.get_order_details_by_uuid("ODR986760186")


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

def get_order_details_by_uuid(uuid)
  get "connect/orders/details/#{uuid}"
end

#get_order_status_by_uuid(uuid) ⇒ Object

Examples:

Get order status by UUID

client.get_order_status_by_uuid("ODR347888404")


44
45
46
# File 'lib/frontgo/order.rb', line 44

def get_order_status_by_uuid(uuid)
  get "connect/orders/status/#{uuid}"
end

#refund_order(uuid, params) ⇒ Object

Examples:

Refund an order (full or partial)

client.refund_order("ODR123456789", {
  type: "regular",
  grandTotal: 55,
  products: [
    { id: 451, amount: 30 },
    { id: 452, amount: 25 }
  ]
})


142
143
144
# File 'lib/frontgo/order.rb', line 142

def refund_order(uuid, params)
  post "connect/orders/refund/#{uuid}", params
end

Examples:

Resend payment link to customer

client.resend_payment_link("ODR123456789", {
  countryCode: "+47",
  msisdn: "46567468",
  email: "[email protected]"
})


129
130
131
# File 'lib/frontgo/order.rb', line 129

def resend_payment_link(uuid, params)
  post "connect/orders/resend/#{uuid}", params
end

#send_e_faktura(params) ⇒ Object

Examples:

Send E-Faktura invoice

client.send_e_faktura({
  products: { "0": { name: "Hair Wash", rate: 51, tax: 0, amount: 51 } },
  customerDetails: {
    type: "private",
    name: "Kari Nordmann",
    email: "[email protected]",
    personalNumber: "12345678901"
  },
  orderSummary: { subTotal: 51.00, totalTax: 0.00, grandTotal: 51.00 }
})


65
66
67
# File 'lib/frontgo/order.rb', line 65

def send_e_faktura(params)
  post "connect/orders/invoice/create/faktura", params
end

#send_ehf_invoice(params) ⇒ Object

Examples:

Send EHF invoice for corporate customers

client.send_ehf_invoice({
  products: { "0": { name: "Hair Wash", rate: 51, tax: 0, amount: 51 } },
  customerDetails: {
    type: "corporate",
    name: "Kari Nordmann",
    email: "[email protected]",
    organizationId: "123456789"
  },
  orderSummary: { subTotal: 51.00, totalTax: 0.00, grandTotal: 51.00 }
})


80
81
82
# File 'lib/frontgo/order.rb', line 80

def send_ehf_invoice(params)
  post "connect/orders/invoice/create/ehf", params
end

#send_invoice(params) ⇒ Object

Examples:

Send regular invoice

client.send_invoice({
  products: { "0": { name: "Hair Wash", rate: 51, tax: 0, amount: 51 } },
  customerDetails: {
    type: "private",
    name: "Kari Nordmann",
    email: "[email protected]"
  },
  sendOrderBy: { sms: false, email: false, invoice: true },
  invoiceInterval: 0,
  separateInvoices: true
})


119
120
121
# File 'lib/frontgo/order.rb', line 119

def send_invoice(params)
  post "connect/orders/invoice/create", params
end

Examples:

Send payment link to customer

client.send_payment_link({
  products: { "0": { name: "Hair Wash", rate: 51, tax: 0, amount: 51 } },
  customerDetails: {
    type: "private",
    name: "Kari Nordmann",
    email: "[email protected]"
  },
  sendOrderBy: { sms: true, email: false, invoice: false },
  orderSummary: { subTotal: 51.00, totalTax: 0.00, grandTotal: 51.00 }
})


103
104
105
# File 'lib/frontgo/order.rb', line 103

def send_payment_link(params)
  post "connect/orders/payment-link/create", params
end