Module: Frontgo::Reservation

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

Overview

Instance Method Summary collapse

Instance Method Details

#cancel_reservation(uuid, params) ⇒ Object

Examples:

Cancel a reservation

client.cancel_reservation("RES123456789", {
  note: "Customer requested cancellation"
})


34
35
36
# File 'lib/frontgo/reservation.rb', line 34

def cancel_reservation(uuid, params)
  post "connect/reservations/cancel/#{uuid}", params
end

#capture_reservation(uuid, params) ⇒ Object

Examples:

Capture funds from a reservation

client.capture_reservation("RES123456789", {
  products: {
    "0": { id: 298, amount: 500 },
    "1": { id: 299, amount: 1500 }
  },
  grandTotal: 2000,
  additionalText: "Capture for services rendered"
})


47
48
49
# File 'lib/frontgo/reservation.rb', line 47

def capture_reservation(uuid, params)
  post "connect/reservations/capture/#{uuid}", params
end

#charge_reservation(uuid, params) ⇒ Object

Examples:

Charge additional amount from reservation

client.charge_reservation("RES123456789", {
  products: {
    "0": {
      name: "Additional Service",
      rate: 1500,
      tax: 0,
      amount: 1500
    }
  },
  grandTotal: 1500,
  additionalText: "Extra service charge"
})


64
65
66
# File 'lib/frontgo/reservation.rb', line 64

def charge_reservation(uuid, params)
  post "connect/reservations/charge/#{uuid}", params
end

#complete_reservation(uuid, params) ⇒ Object

Examples:

Complete a reservation

client.complete_reservation("RES123456789", {
  note: "Service completed successfully"
})


72
73
74
# File 'lib/frontgo/reservation.rb', line 72

def complete_reservation(uuid, params)
  post "connect/reservations/complete/#{uuid}", params
end

#create_session_for_reservation(params) ⇒ Object

Examples:

Create reservation session for checkout

client.create_session_for_reservation({
  customerDetails: {
    type: "private",
    name: "Kari Nordmann",
    email: "kari@example.com",
    countryCode: "+47",
    msisdn: "46567468"
  },
  products: { "0": { name: "Test", rate: 1000, tax: 0, amount: 1000 } },
  submitPayment: { via: "visa" },
  callback: {
    success: "https://example.com/success",
    failure: "https://example.com/failure"
  },
  settings: { isChargePartiallyRefundable: true }
})


118
119
120
# File 'lib/frontgo/reservation.rb', line 118

def create_session_for_reservation(params)
  post "connect/reservations/create", params
end

#get_reservation_details_by_uuid(uuid) ⇒ Object

Examples:

Get reservation details by UUID

client.get_reservation_details_by_uuid("RES3633019929")


26
27
28
# File 'lib/frontgo/reservation.rb', line 26

def get_reservation_details_by_uuid(uuid)
  get "connect/reservations/details/#{uuid}"
end

#get_reservation_history_by_time_frame(start_timestamp, end_timestamp) ⇒ Object

Examples:

Get reservation history by time frame

client.get_reservation_history_by_time_frame("1706674723", "1706761123")

Get last 24 hours (when no timestamps provided, defaults to last 24 hours)

client.get_reservation_history_by_time_frame("", "")


126
127
128
# File 'lib/frontgo/reservation.rb', line 126

def get_reservation_history_by_time_frame(start_timestamp, end_timestamp)
  get "connect/reservations/history/#{start_timestamp}/#{end_timestamp}"
end

#refund_reservation(uuid, params) ⇒ Object

Examples:

Refund a reservation (from captured or charged amounts)

client.refund_reservation("RES123456789", {
  type: "reservation",
  grandTotal: 500,
  products: [
    { id: 451, amount: 300 },
    { id: 452, amount: 200 }
  ],
  source: "charged",
  reference: "CHA3852658817"
})


97
98
99
# File 'lib/frontgo/reservation.rb', line 97

def refund_reservation(uuid, params)
  post "connect/reservations/refund/#{uuid}", params
end

#resend_reservation(uuid, params) ⇒ Object

Examples:

Resend reservation payment link

client.resend_reservation("RES123456789", {
  countryCode: "+47",
  msisdn: "46567468",
  email: "customer@example.com"
})


82
83
84
# File 'lib/frontgo/reservation.rb', line 82

def resend_reservation(uuid, params)
  post "connect/reservations/resend/#{uuid}", params
end

#submit_reservation(params) ⇒ Object

Examples:

Submit a new reservation

client.submit_reservation({
  customerDetails: {
    type: "private",
    name: "Kari Nordmann",
    email: "kari@example.com",
    countryCode: "+47",
    msisdn: "46567468"
  },
  products: { "0": { name: "Test", rate: 1000, tax: 0, amount: 1000 } },
  orderSummary: { subTotal: 1000.00, totalTax: 0, grandTotal: 1000.00 },
  chargeValidity: "55",
  settings: { isChargePartiallyRefundable: true }
})


20
21
22
# File 'lib/frontgo/reservation.rb', line 20

def submit_reservation(params)
  post "connect/reservations/submit", params
end