kbz pay qrcode;
This commit is contained in:
15
app/controllers/api/payment/callback_controller.rb
Normal file
15
app/controllers/api/payment/callback_controller.rb
Normal file
@@ -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
|
||||||
@@ -28,7 +28,7 @@ class Api::Payment::MobilepaymentController < Api::ApiController
|
|||||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||||
rounding_adj = new_total-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)
|
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
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"=>''}
|
@cash ={"change_amount"=>sale_payment[3],"balance_amount"=>sale_payment[4] ,"receipt_url"=>''}
|
||||||
end
|
end
|
||||||
@out = true,@cash
|
@out = true,@cash
|
||||||
|
|
||||||
else
|
else
|
||||||
@out =false,"Something wrong!"
|
@out =false,"Something wrong!"
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
@@ -53,8 +53,4 @@ class Api::Payment::MobilepaymentController < Api::ApiController
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def kbz_pay
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -104,9 +104,16 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
|
|
||||||
#TODO :: KBZPAY ( QR )
|
#TODO :: KBZPAY ( QR )
|
||||||
# On/Off setting ( show or not qr )
|
# On/Off setting ( show or not qr )
|
||||||
qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD"
|
# qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD"
|
||||||
kbz_pay_status = PaymentMethodSetting.where(:payment_method => 'KBZPay').last
|
kbz_pay_status = PaymentMethodSetting.where(:payment_method => 'KBZPay').last
|
||||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, kbz_pay_status, qrCode, 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)
|
|
||||||
|
status = false
|
||||||
|
if kbz_pay_status
|
||||||
|
|
||||||
|
status, qr = KbzPay.pay(sale_data.grand_total, sale_data.receipt_no)
|
||||||
|
end
|
||||||
|
|
||||||
|
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, 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 = {
|
result = {
|
||||||
:filepath => filename,
|
:filepath => filename,
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ class Sale < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
link_order_sale(order.id)
|
# link_order_sale(order.id)
|
||||||
|
|
||||||
end
|
end
|
||||||
self.save!
|
self.save!
|
||||||
@@ -735,9 +735,11 @@ class Sale < ApplicationRecord
|
|||||||
saleOrder = SaleOrder.where("sale_id=? and order_id=?", self.id, order_id).take
|
saleOrder = SaleOrder.where("sale_id=? and order_id=?", self.id, order_id).take
|
||||||
|
|
||||||
if saleOrder.nil?
|
if saleOrder.nil?
|
||||||
sale_order = SaleOrder.new
|
saleOrder = SaleOrder.new
|
||||||
sale = sale_order.create_sale_order(self.id, order_id)
|
# sale = saleOrder.create_sale_order(self.id, order_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sale = saleOrder.create_sale_order(self.id, order_id)
|
||||||
# if (SaleOrder.where("sale_id = #{self.id} and order_id=#{order_id}").nil?)
|
# if (SaleOrder.where("sale_id = #{self.id} and order_id=#{order_id}").nil?)
|
||||||
# SaleOrder.create(:sale_id => self.id, :order_id => order_id)
|
# SaleOrder.create(:sale_id => self.id, :order_id => order_id)
|
||||||
# end
|
# end
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ class SaleOrder < ApplicationRecord
|
|||||||
belongs_to :sale
|
belongs_to :sale
|
||||||
belongs_to :order
|
belongs_to :order
|
||||||
|
|
||||||
def create_sale_order(sale, order)
|
def create_sale_order(sale_id, order_id)
|
||||||
sale_order = SaleOrder.new
|
# sale_order = SaleOrder.new
|
||||||
sale_order.sale_id = sale
|
self.sale_id = sale_id
|
||||||
sale_order.order_id = order
|
self.order_id = order_id
|
||||||
sale_order.save!
|
self.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.sync_sale_order_records(sale_orders)
|
def self.sync_sale_order_records(sale_orders)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
# require 'prawn/qrcode'
|
# require 'prawn/qrcode'
|
||||||
|
require 'prawn/measurement_extensions'
|
||||||
class ReceiptBillPdf < Prawn::Document
|
class ReceiptBillPdf < Prawn::Document
|
||||||
include ActionView::Helpers::NumberHelper
|
include ActionView::Helpers::NumberHelper
|
||||||
|
|
||||||
@@ -685,10 +686,14 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
|
|
||||||
def pay_by_kbzpay(status, qr_code)
|
def pay_by_kbzpay(status, qr_code)
|
||||||
if status == 'Paid'
|
if status == 'Frt'
|
||||||
|
move_down line_move
|
||||||
|
move_down line_move
|
||||||
|
text "KBZ Pay", :size => self.header_font_size+2, :align => :center
|
||||||
|
move_down line_move
|
||||||
|
print_qr_code(qr_code, pos: [30, cursor], extent: 160, stroke: false, dot: 1000)
|
||||||
|
# stroke_horizontal_rule
|
||||||
move_down line_move
|
move_down line_move
|
||||||
print_qr_code(qr_code, pos: [20, cursor], extent: 200, stroke: true)
|
|
||||||
stroke_horizontal_rule
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user