finished dinga and paymal payment
This commit is contained in:
@@ -74,6 +74,7 @@ def create
|
||||
sale_id = params[:sale_id]
|
||||
transaction_ref = params[:transaction_ref]
|
||||
account_no = params[:account_no]
|
||||
puts params.to_json
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop.first
|
||||
|
||||
@@ -197,13 +197,14 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
def self.create_payment(paypar_url,token,membership_id,received_amount,sale_id)
|
||||
membership_actions_data = MembershipAction.find_by_membership_type("create_payment");
|
||||
|
||||
sale_data = Sale.find_by_sale_id(sale_id)
|
||||
customer_data = Customer.find_by_customer_id(sale_data.customer_id)
|
||||
if !membership_actions_data.nil?
|
||||
|
||||
url = paypar_url.to_s + membership_actions_data.gateway_url.to_s
|
||||
merchant_uid = membership_actions_data.merchant_account_id
|
||||
auth_token = membership_actions_data.auth_token
|
||||
sale_data = Sale.find_by_sale_id(sale_id)
|
||||
|
||||
|
||||
if sale_data
|
||||
others = 0
|
||||
@@ -211,14 +212,27 @@ class SalePayment < ApplicationRecord
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
payment_prices = sale_data.grand_total - others
|
||||
# Control for Paypar Cloud
|
||||
begin
|
||||
response = HTTParty.post(url,
|
||||
:body => { account_no:membership_id,
|
||||
|
||||
if membership_id.to_i <= 0
|
||||
membership_id = customer_data.membership_id
|
||||
params = { membership_id:membership_id,
|
||||
amount:received_amount,
|
||||
receipt_no:sale_data.receipt_no,
|
||||
merchant_uid:merchant_uid,
|
||||
auth_token:auth_token}.to_json,
|
||||
auth_token:auth_token}.to_json
|
||||
else
|
||||
params = { account_no:membership_id,
|
||||
amount:received_amount,
|
||||
receipt_no:sale_data.receipt_no,
|
||||
merchant_uid:merchant_uid,
|
||||
auth_token:auth_token}.to_json
|
||||
end
|
||||
|
||||
|
||||
# Control for Paypar Cloud
|
||||
begin
|
||||
response = HTTParty.post(url,
|
||||
:body => params,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=3'
|
||||
@@ -390,12 +404,11 @@ class SalePayment < ApplicationRecord
|
||||
payment_status = false
|
||||
|
||||
#Next time - validate if the vochure number is valid - within
|
||||
customer_data = Customer.find_by_customer_id(self.sale.customer_id)
|
||||
|
||||
# customer_data = Customer.find_by_customer_id(self.sale.customer_id)
|
||||
account_no = self.payment_reference
|
||||
if account_no == 0
|
||||
account_no = customer_data.customer_id
|
||||
end
|
||||
# if account_no.to_i <= 0
|
||||
# account_no = customer_data.membership_id
|
||||
# end
|
||||
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
membership_data = SalePayment.create_payment(membership_setting.gateway_url,membership_setting.auth_token,account_no,self.received_amount,self.sale.sale_id)
|
||||
|
||||
@@ -439,13 +452,12 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
#Next time - validate if the vochure number is valid - within
|
||||
|
||||
customer_data = Customer.find_by_customer_id(self.sale.customer_id)
|
||||
# customer_data = Customer.find_by_customer_id(self.sale.customer_id)
|
||||
|
||||
account_no = self.payment_reference
|
||||
if account_no == 0
|
||||
account_no = customer_data.customer_id
|
||||
end
|
||||
|
||||
# if account_no == 0
|
||||
# account_no = customer_data.customer_id
|
||||
# end
|
||||
|
||||
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
membership_data = SalePayment.create_payment(membership_setting.gateway_url,membership_setting.auth_token,account_no,self.received_amount,self.sale.sale_id)
|
||||
|
||||
@@ -205,7 +205,7 @@
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<%=origami_payment_dinga_path%>",
|
||||
data: {payment_amount:payment_amount,membership_id:membership_id,sale_id:sale_id,transaction_ref:""},
|
||||
data: {payment_amount:payment_amount,membership_id:membership_id,sale_id:sale_id,transaction_ref:"",account_no:0},
|
||||
success: function(result){
|
||||
if(result.status == true){
|
||||
swal({
|
||||
@@ -244,11 +244,11 @@
|
||||
var receipt_no = $("#receipt_no").text() || 0;
|
||||
var customer_mamber_card_no = 0;
|
||||
|
||||
// $("#is_paymemberModal").hide();
|
||||
// $("#sxModal").show();
|
||||
// setTimeout(function(){
|
||||
// getCardNo();
|
||||
// $("#sxModal").hide();
|
||||
$("#is_paymemberModal").hide();
|
||||
$("#sxModal").show();
|
||||
setTimeout(function(){
|
||||
getCardNo();
|
||||
$("#sxModal").hide();
|
||||
customer_mamber_card_no = $("#paypar_account_no").val();
|
||||
if(sale_id != 0 && customer_mamber_card_no != 0){
|
||||
$.ajax({
|
||||
@@ -302,7 +302,7 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
// },100);
|
||||
},100);
|
||||
});
|
||||
|
||||
// Read NFC card no from java
|
||||
@@ -320,13 +320,13 @@
|
||||
// QR Code Reader
|
||||
$(".btn_qr_code").on('click', function(e){
|
||||
$("#is_memberModal").hide();
|
||||
var code = "1011002923682533";
|
||||
var code = "";
|
||||
var customer_id = '';
|
||||
var customer_name = '';
|
||||
var membership_id = '';
|
||||
var membership_type = '';
|
||||
// setTimeout(function(){
|
||||
// code=getQRCode();
|
||||
setTimeout(function(){
|
||||
code=getQRCode();
|
||||
if(sale_id != 0 && code != ""){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
@@ -341,7 +341,7 @@
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<%=origami_payment_paymal_path%>",
|
||||
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no : code},
|
||||
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no:code},
|
||||
success: function(result){
|
||||
if(result.status == true){
|
||||
swal({
|
||||
@@ -376,7 +376,7 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
// },100);
|
||||
},100);
|
||||
});
|
||||
|
||||
// Read qrcode from java
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
<div class="card m-l-10 m-t-10" style="padding:0px 20px;">
|
||||
<div class="rebate-form">
|
||||
<input type="hidden" name="receipt_no" id="receipt_no" value="<%= @receipt_no%>">
|
||||
<p class="hidden" name="sale_id" id="sale_id" ><%=@sale_id %></p>
|
||||
<p class="hidden" name="membership_id" id="membership_id" ><%=@membership_id %></p>
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label class="">You can pay up to </label>
|
||||
@@ -204,7 +206,7 @@
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<%=origami_payment_paymal_path%>",
|
||||
data: {payment_amount:payment_amount,membership_id:membership_id,sale_id:sale_id,transaction_ref:""},
|
||||
data: {payment_amount:payment_amount,membership_id:membership_id,sale_id:sale_id,transaction_ref:"",account_no:0},
|
||||
success: function(result){
|
||||
if(result.status == true){
|
||||
swal({
|
||||
@@ -237,6 +239,7 @@
|
||||
var cardNo = "";
|
||||
var sale_id = $("#sale_id").text() || 0;
|
||||
var receipt_no = $("#receipt_no").val() || "";
|
||||
|
||||
var customer_mamber_card_no = 0;
|
||||
var payment_amount = parseFloat($("#used_amount").text());
|
||||
|
||||
@@ -246,8 +249,10 @@
|
||||
getCardNo();
|
||||
$("#sxModal").hide();
|
||||
customer_mamber_card_no = $("#paypar_account_no").val();
|
||||
|
||||
if(sale_id != 0 && customer_mamber_card_no != 0){
|
||||
if (customer_mamber_card_no == 0) {
|
||||
customer_mamber_card_no = $("#membership_id").text() || 0;
|
||||
}
|
||||
if(sale_id != 0 && customer_mamber_card_no !=0){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/origami/"+sale_id+"/send_account" ,
|
||||
@@ -261,7 +266,7 @@
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<%=origami_payment_paymal_path%>",
|
||||
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref},
|
||||
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no:customer_mamber_card_no},
|
||||
success: function(result){
|
||||
if(result.status == true){
|
||||
swal({
|
||||
@@ -296,8 +301,10 @@
|
||||
|
||||
}
|
||||
});
|
||||
}else{
|
||||
swal("Opp","Please Check Member","warning")
|
||||
}
|
||||
},100);
|
||||
},100);
|
||||
});
|
||||
|
||||
// Read NFC card no from java
|
||||
@@ -335,7 +342,7 @@
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<%=origami_payment_paymal_path%>",
|
||||
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref},
|
||||
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no:code},
|
||||
success: function(result){
|
||||
if(result.status == true){
|
||||
swal({
|
||||
|
||||
Reference in New Issue
Block a user