FIXES
-m fallback query order when occuers wss error
This commit is contained in:
@@ -188,7 +188,7 @@ class Foodcourt::QrpayController < BaseFoodcourtController
|
||||
end
|
||||
|
||||
@paymethod = PaymentMethodSetting.find_by(payment_method: "MMQR")
|
||||
|
||||
|
||||
if @paymethod.nil?
|
||||
raise "MMQR payment method not configured"
|
||||
end
|
||||
@@ -224,7 +224,7 @@ class Foodcourt::QrpayController < BaseFoodcourtController
|
||||
redirect_to foodcourt_food_court_path
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -250,6 +250,48 @@ class Foodcourt::QrpayController < BaseFoodcourtController
|
||||
def test_pay
|
||||
end
|
||||
|
||||
def check_payment_status
|
||||
receipt_no = params[:receipt_no]
|
||||
|
||||
if receipt_no.blank?
|
||||
render json: { status: 'ERROR', message: "Receipt number is missing" }, status: :unprocessable_entity
|
||||
return
|
||||
end
|
||||
|
||||
@paymethod = PaymentMethodSetting.find_by(payment_method: "MMQR")
|
||||
|
||||
if @paymethod.nil?
|
||||
render json: { status: 'CONFIG_ERROR', message: "MMQR payment method not configured" }, status: :ok
|
||||
return
|
||||
end
|
||||
|
||||
begin
|
||||
@merchant = KbzMerchant.new(@paymethod)
|
||||
response = @merchant.query_order(merch_order_id: receipt_no)
|
||||
|
||||
|
||||
if response[:data]['code'] == '0'
|
||||
case response[:data]['trade_status']
|
||||
when 'PAY_SUCCESS'
|
||||
render json: { status: 'PAY_SUCCESS' }
|
||||
else
|
||||
render json: { status: response[:data]['trade_status'] || 'PENDING' }
|
||||
end
|
||||
else
|
||||
render json: {
|
||||
status: 'KBZ_ERROR',
|
||||
message: "KBZ Error #{response[:data]['code']}: #{response['msg']}"
|
||||
}, status: :ok
|
||||
end
|
||||
|
||||
rescue StandardError => e
|
||||
render json: {
|
||||
status: 'SERVER_ERROR',
|
||||
message: "Payment check failed: #{e.message}"
|
||||
}, status: :internal_server_error
|
||||
end
|
||||
end
|
||||
|
||||
def cancel
|
||||
# cancel orders and related
|
||||
sale_id = params[:sale_id]
|
||||
|
||||
Reference in New Issue
Block a user