From ae373fe365c56df1a13fcca4e5b46b971592b3e3 Mon Sep 17 00:00:00 2001 From: Nweni Date: Mon, 24 Jun 2019 10:10:01 +0630 Subject: [PATCH] callback kbzpay --- .../api/payment/callback_controller.rb | 15 +++++++++++++++ .../api/payment/mobilepayment_controller.rb | 8 ++------ app/controllers/origami/payments_controller.rb | 2 ++ 3 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 app/controllers/api/payment/callback_controller.rb diff --git a/app/controllers/api/payment/callback_controller.rb b/app/controllers/api/payment/callback_controller.rb new file mode 100644 index 00000000..c2acb4d8 --- /dev/null +++ b/app/controllers/api/payment/callback_controller.rb @@ -0,0 +1,15 @@ +class Api::Payment::CallbackController < Api::ApiController + + skip_before_action :authenticate + + def kbzpay + Rails.logger.info params[:Request] + callback_value = params[:Request] + trade_status = params[:Request][:trade_status] + total_amount = params[:Request][:total_amount] + if trade_status == "PAY_SUCCESS" + merch_order_id = params[:Request][:merch_order_id] + end + end + +end diff --git a/app/controllers/api/payment/mobilepayment_controller.rb b/app/controllers/api/payment/mobilepayment_controller.rb index 42ab5919..220cbbeb 100644 --- a/app/controllers/api/payment/mobilepayment_controller.rb +++ b/app/controllers/api/payment/mobilepayment_controller.rb @@ -28,7 +28,7 @@ class Api::Payment::MobilepaymentController < Api::ApiController new_total = Sale.get_rounding_adjustment(saleObj.grand_total) rounding_adj = new_total-saleObj.grand_total saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) - + end end end @@ -41,7 +41,7 @@ class Api::Payment::MobilepaymentController < Api::ApiController @cash ={"change_amount"=>sale_payment[3],"balance_amount"=>sale_payment[4] ,"receipt_url"=>''} end @out = true,@cash - + else @out =false,"Something wrong!" sale_payment = SalePayment.new @@ -53,8 +53,4 @@ class Api::Payment::MobilepaymentController < Api::ApiController end - def kbz_pay - - end - end diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 71a364e2..4ec893ad 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -102,6 +102,8 @@ class Origami::PaymentsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) + status, qr = KbzPay.pay(amount, receipt_no) + filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount,nil,nil,nil) result = {