card payment

This commit is contained in:
Myat Zin Wai Maw
2019-11-27 15:05:42 +06:30
parent 98b74af6cf
commit fe5dc6bb5a
15 changed files with 93 additions and 78 deletions

View File

@@ -171,7 +171,8 @@ class SalePayment < ApplicationRecord
#record an payment in sale-audit
remark = "Payment failed - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]"
sale_audit = SaleAudit.record_payment(invoice.id, remark,action_by.name)
return false, "Payment failed"
# return false, "Payment failed"
return false, self.save,membership_data
end
else
#record an payment in sale-audit
@@ -303,8 +304,8 @@ class SalePayment < ApplicationRecord
def self.create_payment(paypar_url,payment_type,membership_id,received_amount,sale_id)
# membership_actions_data = MembershipAction.find_by_membership_type("create_payment");
membership_actions_data = PaymentMethodSetting.find_by_payment_method(payment_type)
sale_data = Sale.find_by_sale_id(sale_id)
membership_actions_data = PaymentMethodSetting.find_by_payment_method_and_shop_code(payment_type,sale_data.shop_code)
customer_data = Customer.find_by_customer_id(sale_data.customer_id)
if !membership_actions_data.nil?
@@ -543,7 +544,7 @@ class SalePayment < ApplicationRecord
# if account_no.to_i <= 0
# account_no = customer_data.membership_id
# end
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",self.sale.shop_code)
membership_data = SalePayment.create_payment(membership_setting.gateway_url,"PAYMAL",account_no,self.received_amount,self.sale.sale_id)
#record an payment in sale-audit
@@ -686,7 +687,7 @@ class SalePayment < ApplicationRecord
self.sale.sale_status = "completed"
if MembershipSetting.find_by_rebate(1) && is_foc == 0 && is_credit == 0
if MembershipSetting.find_by_rebate_and_shop_code(1,self.sale.shop_code) && is_foc == 0 && is_credit == 0
response = rebat(sObj)
#record an payment in sale-audit
@@ -845,8 +846,8 @@ class SalePayment < ApplicationRecord
overall_dis = sObj.total_discount
if credit != 1
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("get_member_campaign")
membership = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",sObj.shop_code)
memberaction = MembershipAction.find_by_membership_type_and_shop_code("get_member_campaign",sObj.shop_code)
merchant_uid = memberaction.merchant_account_id.to_s
campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
auth_token = memberaction.auth_token.to_s
@@ -930,8 +931,8 @@ class SalePayment < ApplicationRecord
if total_amount >= 0
receipt_no = sObj.receipt_no
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("rebate")
membership = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",sObj.shop_code)
memberaction = MembershipAction.find_by_membership_type_and_shop_code("rebate",sObj.shop_code)
merchant_uid = memberaction.merchant_account_id.to_s
campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
auth_token = memberaction.auth_token.to_s
@@ -962,7 +963,7 @@ class SalePayment < ApplicationRecord
rescue SocketError
response = { "status": false, "message": "Can't connect server"}
end
Rails.logger.debug "Rebage Response"
Rails.logger.debug "Rebate Response"
Rails.logger.debug response.to_json
return response
end