qr pay updates

- subscribe to action cable from cloud and listen
- callback from cloud to local and show success payment in real time
- payment service and process payment after callback
This commit is contained in:
Dev Team
2025-05-26 11:29:33 +06:30
parent a43f8ed4f6
commit 1768345299
5 changed files with 208 additions and 21 deletions

View File

@@ -1,5 +1,8 @@
class Foodcourt::QrpayController < BaseFoodcourtController
require 'rqrcode'
skip_before_action :authenticate, only: [:create]
skip_before_action :verify_authenticity_token, only: [:create]
def init
@cash_exist = PaymentMethodSetting.cash_exist
@@ -217,6 +220,28 @@ class Foodcourt::QrpayController < BaseFoodcourtController
end
end
def create
sale_id = params[:sale_id]
unless current_login_employee
render json: { status: false, message: "User not authenticated or employee context missing." }, status: :unauthorized
return
end
qrpayment_service = QrPaymentService.new(sale_id, current_login_employee)
result = qrpayment_service.process
if result[:status]
render json: result, status: :ok
else
status_code = result[:message].include?("not found") ? :not_found : :unprocessable_entity
render json: result, status: status_code
end
end
def test_pay
end
def cancel
# cancel orders and related
sale_id = params[:sale_id]