search account no,security code check,find order,payment create
This commit is contained in:
@@ -25,6 +25,10 @@ class Customer < ApplicationRecord
|
||||
self.email = pin.to_s + "@gmail.com"
|
||||
self.pin_code = pin.to_s
|
||||
self.pin_sent_at = Time.now
|
||||
tax_profiles=TaxProfile.where(group_type: "food_court")
|
||||
tax_ids =[]
|
||||
tax_profiles.each {|tax| tax_ids << "#{tax.id}"}
|
||||
self.tax_profiles = tax_ids
|
||||
self.save
|
||||
return self
|
||||
else
|
||||
@@ -381,6 +385,57 @@ class Customer < ApplicationRecord
|
||||
WALKIN = "CUS-000000000001"
|
||||
TAKEAWAY = "CUS-000000000002"
|
||||
|
||||
def self.check_paymalcard(url,token,merchant_uid,auth_token,account_no)
|
||||
# Control for Paypar Cloud
|
||||
begin
|
||||
response = HTTParty.get(url,
|
||||
:body => { merchant_uid:merchant_uid,auth_token:auth_token,paypar_account_no: account_no}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=4'
|
||||
}, :timeout => 10
|
||||
)
|
||||
rescue Errno::ECONNREFUSED
|
||||
response = { "status" => false, "message" => "Can't open membership server"}
|
||||
rescue Net::OpenTimeout
|
||||
response = { "status" => false, "message" => "No internet connection " }
|
||||
rescue OpenURI::HTTPError
|
||||
response = { "status" => false, "message" => "No internet connection "}
|
||||
rescue SocketError
|
||||
response = { "status" => false, "message" => "No internet connection "}
|
||||
end
|
||||
Rails.logger.debug "search_paypar_account_no"
|
||||
Rails.logger.debug response.to_json
|
||||
if response["status"]
|
||||
response = { "status" => true, "message" => "Success"}
|
||||
else
|
||||
response = { "status" => false, "message" => response["message"]}
|
||||
end
|
||||
return response
|
||||
end
|
||||
def self.check_security_code(url,token,merchant_uid,auth_token,account_no)
|
||||
# Control for Paypar Cloud
|
||||
begin
|
||||
response = HTTParty.get(url,
|
||||
:body => { merchant_uid:merchant_uid,auth_token:auth_token,paypar_account_no: account_no}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=4'
|
||||
}, :timeout => 10
|
||||
)
|
||||
rescue Errno::ECONNREFUSED
|
||||
response = { "status" => false, "message" => "Can't open membership server"}
|
||||
rescue Net::OpenTimeout
|
||||
response = { "status" => false, "message" => "No internet connection " }
|
||||
rescue OpenURI::HTTPError
|
||||
response = { "status" => false, "message" => "No internet connection "}
|
||||
rescue SocketError
|
||||
response = { "status" => false, "message" => "No internet connection "}
|
||||
end
|
||||
Rails.logger.debug "search_paypar_account_no"
|
||||
Rails.logger.debug response.to_json
|
||||
return response
|
||||
end
|
||||
private
|
||||
def generate_custom_id
|
||||
self.customer_id = SeedGenerator.generate_id(self.class.name, "CUS")
|
||||
|
||||
@@ -649,6 +649,8 @@ class Sale < ApplicationRecord
|
||||
# tax_profiles = TaxProfile.all.order("order_by asc")
|
||||
if order_source.to_s == "emenu"
|
||||
order_source = "cashier"
|
||||
elsif order_source.to_s == "app"
|
||||
order_source = "food_court"
|
||||
end
|
||||
|
||||
# tax_data = TaxProfile.unscope(:order).where("group_type=?",order_source).pluck(:id)
|
||||
@@ -2129,6 +2131,7 @@ def self.get_sale_data_for_other_payment_credit(sale_id)
|
||||
end
|
||||
|
||||
def unique_tax_profiles(order_source, customer_id)
|
||||
puts "unique_tax_profiles unique_tax_profiles"
|
||||
tax_data = TaxProfile.where(group_type: order_source)
|
||||
customer_tax_profiles = Customer.select(:tax_profiles).where(customer_id: customer_id).first
|
||||
if customer_tax_profiles.present?
|
||||
|
||||
@@ -222,7 +222,7 @@ class SalePayment < ApplicationRecord
|
||||
account_no: account_no, amount: amount}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=3'
|
||||
'Accept' => 'application/json; version=4'
|
||||
}, :timeout => 10
|
||||
)
|
||||
rescue Errno::ECONNREFUSED
|
||||
@@ -336,7 +336,7 @@ class SalePayment < ApplicationRecord
|
||||
:body => params,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=3'
|
||||
'Accept' => 'application/json; version=4'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
@@ -1043,7 +1043,6 @@ class SalePayment < ApplicationRecord
|
||||
.group("sale_payments.sale_payment_id")
|
||||
return query
|
||||
end
|
||||
|
||||
private
|
||||
def generate_custom_id
|
||||
if self.sale_payment_id.nil?
|
||||
|
||||
Reference in New Issue
Block a user