payment api
This commit is contained in:
19
app/controllers/api/discounts_controller.rb
Normal file
19
app/controllers/api/discounts_controller.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
class Api::DiscountsController < ActionController::API
|
||||
def create
|
||||
@invoice = Sale.find(params[:invoice_id])
|
||||
end
|
||||
|
||||
#Update sale item - Price | Qty |
|
||||
def update
|
||||
end
|
||||
|
||||
#destroy - Remove items form invoice
|
||||
def destroy
|
||||
@sale.remove_item(params[:sale_item_id])
|
||||
end
|
||||
|
||||
private
|
||||
def set_invoice_params
|
||||
@sale = Sale.find(params[:invoice_id])
|
||||
end
|
||||
end
|
||||
@@ -1,33 +1,38 @@
|
||||
class Api::CustomersController < ActionController::API
|
||||
class Api::InvoicesController < ActionController::API
|
||||
before :authenticate_token
|
||||
before :set_sale_params, only:[:show, :update, :destroy]
|
||||
|
||||
#List open invoices for today.
|
||||
def index
|
||||
@sales = Sale.open_invoices
|
||||
end
|
||||
#Description
|
||||
# This API show current order details
|
||||
# Input Params - order_id
|
||||
# This API show current sale details
|
||||
# Input Params - ID
|
||||
def show
|
||||
order = Order.find(params[:order_id])
|
||||
order.order_items
|
||||
@sale = Sale.find(params[:id])
|
||||
end
|
||||
|
||||
# Description
|
||||
# This API allow new invoice creation
|
||||
# Input Params
|
||||
# order_id
|
||||
# Output Params
|
||||
# Status [Success | Error | System Error] , order_id, error_message (*)
|
||||
#Creat Sales based on Items -
|
||||
def create
|
||||
#
|
||||
end
|
||||
|
||||
#UPDATE SALES
|
||||
def update
|
||||
|
||||
end
|
||||
|
||||
def by_booking
|
||||
end
|
||||
|
||||
def by_order
|
||||
#VOID Sale
|
||||
def destroy
|
||||
#Reason | #Approval
|
||||
end
|
||||
|
||||
private
|
||||
def process_items
|
||||
def set_sale_params
|
||||
@sale = Sale.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
19
app/controllers/api/memberships_controller.rb
Normal file
19
app/controllers/api/memberships_controller.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
class Api::MembershipsController < ActionController::API
|
||||
before :authenticate_token
|
||||
|
||||
|
||||
#Add Membership to invoice
|
||||
def create
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
private
|
||||
def set_sale_params
|
||||
|
||||
end
|
||||
def process_items
|
||||
end
|
||||
|
||||
end
|
||||
@@ -31,7 +31,7 @@ class Api::OrdersController < ActionController::API
|
||||
@order.guest = params[:guest_info]
|
||||
@order.table_id = params[:table_id]
|
||||
@order.new_booking = true
|
||||
@order.employee_name = "Test User"
|
||||
@order.employee_name = current_login_employee.name
|
||||
|
||||
|
||||
#Create Table Booking or Room Booking
|
||||
@@ -41,7 +41,7 @@ class Api::OrdersController < ActionController::API
|
||||
end
|
||||
|
||||
@status = @order.generate
|
||||
|
||||
|
||||
# rescue Exception => error
|
||||
# @status = false
|
||||
# @error_messages = "Exception has occurs on System"
|
||||
|
||||
@@ -8,11 +8,82 @@ class Api::PaymentsController < ActionController::API
|
||||
# Status - [True/False] | Invoice | error_message (* when status false)
|
||||
def create
|
||||
@invoice = Sale.find(params[:invoice_id])
|
||||
|
||||
if (@invoice)
|
||||
handle_payment(@invoice)
|
||||
end
|
||||
end
|
||||
|
||||
# Update of payment status from the external party
|
||||
# Invoice No | Payment ID | External params [] (* third party references and status)
|
||||
#
|
||||
def update
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
def handle_payment(sale_payment)
|
||||
|
||||
payment_method = params[:payment_method]
|
||||
sale_payment = SalePayment.new
|
||||
|
||||
#:received_amount, :card_payment_reference, :vochure_no, :giftcard_no,
|
||||
#:customer_id, :external_payment_status
|
||||
switch (payment_method)
|
||||
case "cash"
|
||||
sale_payment.payment_method = "cash"
|
||||
sale_payment.received_amount = params[:amount]
|
||||
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
|
||||
case "creditnote"
|
||||
sale_payment.payment_method = "creditnote"
|
||||
sale_payment.received_amount = params[:amount]
|
||||
sale_payment.customer_id = params[:customer_id]
|
||||
|
||||
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
|
||||
case "visa"
|
||||
sale_payment.payment_method = "visa"
|
||||
sale_payment.received_amount = params[:amount]
|
||||
sale_payment.payment_reference = params[:payment_reference]
|
||||
|
||||
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
|
||||
case "master"
|
||||
sale_payment.payment_method = "master"
|
||||
sale_payment.received_amount = params[:amount]
|
||||
sale_payment.payment_reference = params[:payment_reference]
|
||||
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
|
||||
case "jcb"
|
||||
sale_payment.payment_method = "jcb"
|
||||
sale_payment.received_amount = params[:amount]
|
||||
sale_payment.payment_reference = params[:payment_reference]
|
||||
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
|
||||
case "mpu"
|
||||
sale_payment.payment_method = "mpu"
|
||||
sale_payment.received_amount = params[:amount]
|
||||
sale_payment.payment_reference = params[:payment_reference]
|
||||
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
|
||||
case "unionpay"
|
||||
sale_payment.payment_method = "unionpay"
|
||||
sale_payment.received_amount = params[:amount]
|
||||
sale_payment.payment_reference = params[:payment_reference]
|
||||
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
|
||||
case "vochure"
|
||||
sale_payment.payment_method = "vochure"
|
||||
sale_payment.received_amount = params[:amount]
|
||||
sale_payment.customer_id = params[:customer_id]
|
||||
sale_payment.payment_reference = params[:vochure_no]
|
||||
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
|
||||
case "giftcard"
|
||||
sale_payment.payment_method = "giftcard"
|
||||
sale_payment.received_amount = params[:amount]
|
||||
sale_payment.customer_id = params[:customer_id]
|
||||
sale_payment.payment_reference = params[:giftcard_no]
|
||||
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
|
||||
case "paypar"
|
||||
sale_payment.payment_method = "paypar"
|
||||
sale_payment.received_amount = params[:amount]
|
||||
sale_payment.payment_reference = params[:payment_reference]
|
||||
#TODO: implement paypar implementation
|
||||
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
21
app/controllers/api/sale_items_controller.rb
Normal file
21
app/controllers/api/sale_items_controller.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
class Api::SaleItemsController < ActionController::API
|
||||
|
||||
|
||||
def create
|
||||
@invoice = Sale.find(params[:invoice_id])
|
||||
end
|
||||
|
||||
#Update sale item - Price | Qty |
|
||||
def update
|
||||
end
|
||||
|
||||
#destroy - Remove items form invoice
|
||||
def destroy
|
||||
@sale.remove_item(params[:sale_item_id])
|
||||
end
|
||||
|
||||
private
|
||||
def set_invoice_params
|
||||
@sale = Sale.find(params[:invoice_id])
|
||||
end
|
||||
end
|
||||
74
app/controllers/settings/menus_controller.rb
Normal file
74
app/controllers/settings/menus_controller.rb
Normal file
@@ -0,0 +1,74 @@
|
||||
class Settings::MenusController < ApplicationController
|
||||
before_action :set_settings_menu, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /settings/menus
|
||||
# GET /settings/menus.json
|
||||
def index
|
||||
@settings_menus = Settings::Menu.all
|
||||
end
|
||||
|
||||
# GET /settings/menus/1
|
||||
# GET /settings/menus/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /settings/menus/new
|
||||
def new
|
||||
@settings_menu = Settings::Menu.new
|
||||
end
|
||||
|
||||
# GET /settings/menus/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /settings/menus
|
||||
# POST /settings/menus.json
|
||||
def create
|
||||
@settings_menu = Settings::Menu.new(settings_menu_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @settings_menu.save
|
||||
format.html { redirect_to @settings_menu, notice: 'Menu was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @settings_menu }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @settings_menu.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /settings/menus/1
|
||||
# PATCH/PUT /settings/menus/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @settings_menu.update(settings_menu_params)
|
||||
format.html { redirect_to @settings_menu, notice: 'Menu was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @settings_menu }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @settings_menu.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /settings/menus/1
|
||||
# DELETE /settings/menus/1.json
|
||||
def destroy
|
||||
@settings_menu.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to settings_menus_url, notice: 'Menu was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_settings_menu
|
||||
@settings_menu = Settings::Menu.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def settings_menu_params
|
||||
params.fetch(:settings_menu, {})
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user