Topup payment
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -1,5 +1,5 @@
|
||||
source 'https://rubygems.org'
|
||||
ruby '2.4.1'
|
||||
ruby '2.4.0'
|
||||
git_source(:github) do |repo_name|
|
||||
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
|
||||
"https://github.com/#{repo_name}.git"
|
||||
|
||||
3
app/assets/javascripts/origami/paymal.coffee
Normal file
3
app/assets/javascripts/origami/paymal.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
3
app/assets/stylesheets/origami/paymal.scss
Normal file
3
app/assets/stylesheets/origami/paymal.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the origami/Paymal controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
101
app/controllers/origami/paymal_controller.rb
Normal file
101
app/controllers/origami/paymal_controller.rb
Normal file
@@ -0,0 +1,101 @@
|
||||
class Origami::PaymalController < BaseOrigamiController
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
payment_method = params[:payment_method]
|
||||
@cashier_type = params[:type]
|
||||
@membership_rebate_balance=0
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
|
||||
@shop = Shop::ShopDetail
|
||||
# if @shop.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
# else
|
||||
# new_total = sale_data.grand_total
|
||||
# end
|
||||
# @rounding_adj = new_total-sale_data.grand_total
|
||||
@rounding_adj = sale_data.rounding_adjustment
|
||||
|
||||
@payparcount = 0
|
||||
others = 0
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "paypar"
|
||||
@payparcount = @payparcount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@payment_prices = sale_data.grand_total - @payparcount -others
|
||||
|
||||
|
||||
if sale_data
|
||||
if sale_data.customer_id
|
||||
customer_data= Customer.find_by_customer_id(sale_data.customer_id)
|
||||
if customer_data
|
||||
@membership_id = customer_data.membership_id
|
||||
if !@membership_id.nil?
|
||||
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
if membership_setting.gateway_url
|
||||
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
|
||||
if member_actions.gateway_url
|
||||
@campaign_type_id = nil
|
||||
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
|
||||
merchant_uid= member_actions.merchant_account_id
|
||||
auth_token = member_actions.auth_token.to_s
|
||||
membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token)
|
||||
if membership_data["status"]==true
|
||||
@membership_rebate_balance=membership_data["balance"]
|
||||
@out = true, @membership_rebate_balance,@membership_id
|
||||
end
|
||||
else
|
||||
@out =false,0
|
||||
end
|
||||
else
|
||||
@out = false,0
|
||||
end
|
||||
|
||||
|
||||
else
|
||||
@out = false, 0
|
||||
end
|
||||
else
|
||||
@out = false, 0
|
||||
end
|
||||
else
|
||||
@out = false, 0
|
||||
end
|
||||
else
|
||||
@out = false, 0
|
||||
end
|
||||
@out = false, 0
|
||||
end
|
||||
def create
|
||||
cash = params[:payment_amount]
|
||||
sale_id = params[:sale_id]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop::ShopDetail
|
||||
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
# 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
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
status, @sale = sale_payment.process_payment(saleObj, @user, cash, "paymal")
|
||||
if status == true
|
||||
@out = true, "Success!"
|
||||
else
|
||||
@out =false, "Please try again payment!"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
@@ -211,6 +211,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@mastercount = 0.0
|
||||
@unionpaycount = 0.0
|
||||
@credit = 0.0
|
||||
@paymalcount = 0.0
|
||||
@sale_data = Sale.find_by_sale_id(sale_id)
|
||||
@balance = 0.00
|
||||
@accountable_type = ''
|
||||
@@ -324,6 +325,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@unionpaycount += spay.payment_amount
|
||||
elsif spay.payment_method == "creditnote"
|
||||
@credit += spay.payment_amount
|
||||
elsif spay.payment_method == "paymal"
|
||||
@paymalcount += spay.payment_amount
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
2
app/helpers/origami/paymal_helper.rb
Normal file
2
app/helpers/origami/paymal_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Origami::PaymalHelper
|
||||
end
|
||||
@@ -48,6 +48,8 @@ class SalePayment < ApplicationRecord
|
||||
payment_status = paypar_payment
|
||||
when "foc"
|
||||
payment_status = foc_payment
|
||||
when "paymal"
|
||||
payment_status = paymal_payment
|
||||
else
|
||||
puts "it was something else"
|
||||
end
|
||||
@@ -159,6 +161,60 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
return response;
|
||||
|
||||
end
|
||||
|
||||
def self.create_payment(paypar_url,token,membership_id,received_amount,sale_id)
|
||||
membership_actions_data = MembershipAction.find_by_membership_type("create_payment");
|
||||
|
||||
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
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
payment_prices = sale_data.grand_total - others
|
||||
# Control for Paypar Cloud
|
||||
begin
|
||||
response = HTTParty.post(url,
|
||||
:body => { membership_id:membership_id,
|
||||
amount:received_amount,
|
||||
receipt_no:sale_data.receipt_no,
|
||||
merchant_uid:merchant_uid,
|
||||
auth_token:auth_token}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=3'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
rescue Net::OpenTimeout
|
||||
response = false
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = { status: false}
|
||||
|
||||
rescue SocketError
|
||||
response = { status: false}
|
||||
end
|
||||
else
|
||||
response = false;
|
||||
end
|
||||
|
||||
else
|
||||
response =false;
|
||||
end
|
||||
|
||||
Rails.logger.debug "Payment response"
|
||||
Rails.logger.debug response.to_json
|
||||
|
||||
return response;
|
||||
|
||||
end
|
||||
|
||||
# Check for Card Payment
|
||||
@@ -297,6 +353,35 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
end
|
||||
|
||||
def paymal_payment
|
||||
payment_status = false
|
||||
|
||||
#Next time - validate if the vochure number is valid - within
|
||||
customer_data = Customer.find_by_customer_id(self.sale.customer_id)
|
||||
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
membership_data = SalePayment.create_payment(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id)
|
||||
|
||||
#record an payment in sale-audit
|
||||
remark = "#{membership_data} PayMal Payment- for Customer #{self.sale.customer_id} Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} "
|
||||
sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, 1)
|
||||
|
||||
if membership_data["status"]==true
|
||||
self.payment_method = "paymal"
|
||||
self.payment_amount = self.received_amount
|
||||
self.payment_reference = self.voucher_no
|
||||
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
||||
self.payment_status = "pending"
|
||||
payment_method = self.save!
|
||||
SalePayment.where(:sale_payment_id => self.sale_payment_id).update_all(:payment_status => 'paid')
|
||||
sale_update_payment_status(self.received_amount.to_f)
|
||||
|
||||
else
|
||||
sale_update_payment_status(0)
|
||||
end
|
||||
return payment_status
|
||||
|
||||
end
|
||||
|
||||
def sale_update_payment_status(paid_amount,check_foc = false)
|
||||
#update amount_outstanding
|
||||
self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f
|
||||
|
||||
@@ -697,11 +697,12 @@
|
||||
|
||||
$(".choose_payment").on('click', function () {
|
||||
$( "#loading_wrapper").show();
|
||||
alert(parseInt(jQuery.inArray("PAYMAL", type)));
|
||||
|
||||
var sale_id = $('#sale_id').val();
|
||||
type = $('.payment_method').val();
|
||||
if(parseInt(jQuery.inArray("Credit", type)) == -1){
|
||||
if (parseInt(jQuery.inArray("MPU", type)) != -1 || parseInt(jQuery.inArray("VISA", type)) != -1 || parseInt(jQuery.inArray("JCB", type)) != -1 || parseInt(jQuery.inArray("Master", type)) != -1 || parseInt(jQuery.inArray("UNIONPAY", type)) != -1 || parseInt(jQuery.inArray("Redeem", type)) != -1) {
|
||||
if (parseInt(jQuery.inArray("MPU", type)) != -1 || parseInt(jQuery.inArray("VISA", type)) != -1 || parseInt(jQuery.inArray("JCB", type)) != -1 || parseInt(jQuery.inArray("Master", type)) != -1 || parseInt(jQuery.inArray("UNIONPAY", type)) != -1 || parseInt(jQuery.inArray("Redeem", type)) != -1 || parseInt(jQuery.inArray("PAYMAL",type))!= -1) {
|
||||
calculate_member_discount(sale_id,"Card");
|
||||
|
||||
}else{
|
||||
|
||||
2
app/views/origami/paymal/create.json.jbuilder
Normal file
2
app/views/origami/paymal/create.json.jbuilder
Normal file
@@ -0,0 +1,2 @@
|
||||
json.set! :status, @out[0]
|
||||
json.set! :message, @out[1]
|
||||
201
app/views/origami/paymal/index.html.erb
Normal file
201
app/views/origami/paymal/index.html.erb
Normal file
@@ -0,0 +1,201 @@
|
||||
<div class="container-fluid">
|
||||
<!-- <div class="page-header">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="<%=origami_root_path %>"><%= t :home %></a></li>
|
||||
<li class="breadcrumb-item"><a href="/origami/sale/<%=@sale_id %>/payment"><%= t("views.btn.payment") %></a></li>
|
||||
<li class="breadcrumb-item active"><%= t("views.right_panel.details.redeem") %></li>
|
||||
<span class="float-right">
|
||||
<%= link_to t('.back',:default => t("views.btn.back")),'/origami/sale/'+@sale_id+'/payment/others_payment'%>
|
||||
</span>
|
||||
</ol>
|
||||
</div> -->
|
||||
<h5>PayMal Payment</h5>
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-5 col-sm-5">
|
||||
<div class="card m-l-10 m-t-10" style="padding:0px 20px;">
|
||||
<div class="rebate-form">
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label class="">You can pay up to </label>
|
||||
<%@payment_prices = @payment_prices +@rounding_adj%>
|
||||
<input type="text" name="" id="paymentamt" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%= @payment_prices %>" data-value="<%=@sale_id %>" data-member-value="<%= @membership_id %>">
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
<% if @payparcount > 0 %>
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label class="">Recent Payment Amount </label>
|
||||
<input type="text" name="" id="" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%= @payparcount %>" data-value="<%=@sale_id %>" data-member-value="<%= @membership_id %>">
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label class="">Available Balance </label>
|
||||
<input type="text" name="valid_amount" id="valid_amount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@membership_rebate_balance%>" data-value="<%=@sale_id %>" data-member-value="<%= @membership_id %>">
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label class="">Payment Balance</label>
|
||||
<div id="used_amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <% if @payparcount > 0 %>
|
||||
<p class="">Last time rebate amount is <%= @payparcount %></p>
|
||||
<% end %>
|
||||
<p class="">You can rebate upto <span style="color:red;" id="food_prices"><%= @payment_prices %></span></p> -->
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<div class="m-t-10 p-l-20">
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-1 col-sm-1">
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-left" data-value="1" data-type="num">1</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="2" data-type="num">2</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="3" data-type="num">3</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-left" data-value="4" data-type="num">4</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="5" data-type="num">5</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="6" data-type="num">6</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-left" data-value="7" data-type="num">7</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="8" data-type="num">8</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="9" data-type="num">9</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-left" data-value="0" data-type="num">0</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="." data-type="num">.</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="00" data-type="num">00</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number green border-left" data-type="nett">Nett</div>
|
||||
<div class="col-md-4 cashier_number red border-left" data-type="del">Del</div>
|
||||
<div class="col-md-4 cashier_number orange border-left" data-type="clr">Clr</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<div class="row bottom m-l-5">
|
||||
<div class="cashier_number long border-left" data-value="1000" data-type="add">1000</div>
|
||||
<div class="cashier_number long left" data-value="3000" data-type="add">3000</div>
|
||||
</div>
|
||||
<div class="row bottom m-l-5">
|
||||
<div class="cashier_number long border-left" data-value="5000" data-type="add">5000</div>
|
||||
<div class="cashier_number long left" data-value="10000" data-type="add">10000</div>
|
||||
</div>
|
||||
<div class="row bottom m-l-5">
|
||||
<div class="pay purple left" id="paymal_payment">Pay</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<button type="button" class="btn bg-default m-t-10 btn-lg btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/<%= @cashier_type %>/payment/others_payment';"> <i class="material-icons m-t--5">reply</i>Back </button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var cashier_type = "<%= @cashier_type %>";
|
||||
$(document).ready(function() {
|
||||
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
|
||||
else {
|
||||
$('#paymentamt').attr("value",parseFloat("<%= @payment_prices %>") - parseFloat(localStorage.getItem("cash")));
|
||||
}
|
||||
});
|
||||
$(document).on('click', '.cashier_number', function(event){
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
if(event.handled !== true) {
|
||||
var original_value;
|
||||
original_value = $('#used_amount').text();
|
||||
|
||||
var input_value = $(this).attr("data-value");
|
||||
|
||||
var input_type = $(this).attr("data-type");
|
||||
switch (input_type) {
|
||||
case 'num':
|
||||
if (original_value == "0.0"){
|
||||
$('#used_amount').text(input_value);
|
||||
}else{
|
||||
$('#used_amount').append(input_value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'add':
|
||||
var input_value = $(this).attr("data-value");
|
||||
amount = parseInt(input_value) + parseInt(original_value);
|
||||
$('#used_amount').html(amount);
|
||||
|
||||
break;
|
||||
case 'clr':
|
||||
$('#used_amount').html("0.0");
|
||||
break;
|
||||
case 'del' :
|
||||
var cash=$('#used_amount').text();
|
||||
$('#used_amount').text(cash.substr(0,cash.length-1));
|
||||
break;
|
||||
case 'nett':
|
||||
var remain_amount = $('#paymentamt').val();
|
||||
$('#used_amount').text(remain_amount);
|
||||
break;
|
||||
|
||||
}
|
||||
event.handled = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$("#paymal_payment").click(function(){
|
||||
valid_amount = $("#valid_amount").val();
|
||||
sale_id = $("#valid_amount").attr('data-value');
|
||||
membership_id = $("#valid_amount").attr('data-member-value');
|
||||
payment_amount = parseFloat($("#used_amount").text());
|
||||
if(payment_amount<=0 ){
|
||||
swal ( "Oops" , "Please type valid amount!" , "warning" );
|
||||
}else if(valid_amount< payment_amount){
|
||||
swal ( "Oops" , "Insufficient Amount!" , "warning" );
|
||||
}else{
|
||||
if(payment_amount <= "<%= @payment_prices %>"){
|
||||
$(this).off("click");
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<%=origami_payment_paymal_path%>",
|
||||
data: {payment_amount:payment_amount,membership_id:membership_id,sale_id:sale_id},
|
||||
success: function(result){
|
||||
if(result.status == true){
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: result.message,
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment"
|
||||
});
|
||||
|
||||
}else{
|
||||
swal ( "Information" , result.message);
|
||||
}
|
||||
}
|
||||
})
|
||||
}else {
|
||||
swal ( "Oops" , "Payment Amount is over!" , "warning" );
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -265,6 +265,17 @@
|
||||
<div class="col-md-4" id="unionpaycount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<!-- PAYMAL -->
|
||||
|
||||
<div class="row payment <%= @paymalcount!=0.0 ? 'payment others-color' : 'hidden'%>">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">PAYMAL</div>
|
||||
<% if @paymalcount != 0.0 %>
|
||||
<div class="col-md-4 master is_card" id="paymalcount"><%= number_with_precision(@paymalcount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="paymalcount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="row m-l-5 m-r-5">
|
||||
<div class="col-md-8"><strong>Balance</strong></div>
|
||||
<div class="col-md-4"><strong><span id='balance'><%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></span></strong></div>
|
||||
@@ -488,7 +499,7 @@ var customer_name = "<%= @customer.name %>";
|
||||
$("#credit_payment").show();
|
||||
}
|
||||
|
||||
if(parseInt(jQuery.inArray("MPU", payment_type)) !=-1 || parseInt(jQuery.inArray("VISA", payment_type)) !=-1 || parseInt(jQuery.inArray("JCB", payment_type)) !=-1 || parseInt(jQuery.inArray("Master", payment_type)) !=-1 || parseInt(jQuery.inArray("UNIONPAY", payment_type)) !=-1 || parseInt(jQuery.inArray("Redeem", payment_type)) !=-1){
|
||||
if(parseInt(jQuery.inArray("MPU", payment_type)) !=-1 || parseInt(jQuery.inArray("VISA", payment_type)) !=-1 || parseInt(jQuery.inArray("JCB", payment_type)) !=-1 || parseInt(jQuery.inArray("Master", payment_type)) !=-1 || parseInt(jQuery.inArray("UNIONPAY", payment_type)) !=-1 || parseInt(jQuery.inArray("Redeem", payment_type)) !=-1, parseInt(jQuery.inArray("PAYMAL", payment_type)) !=-1){
|
||||
$("#card_payment").show();
|
||||
} else{
|
||||
$("#card_payment").hide();
|
||||
@@ -553,6 +564,8 @@ var customer_name = "<%= @customer.name %>";
|
||||
}
|
||||
else if(payment_type == "Credit" && $('#credit').text()==0 && sub_total != 0.0){
|
||||
swal("Oops","Please Pay with Credit Payment","warning");
|
||||
}else if(payment_type == "PAYMAL" && $('#paymalcount').text()==0 && sub_total != 0.0){
|
||||
swal("Oops","Please Pay with Paymal Payment","warning");
|
||||
}else{
|
||||
|
||||
$( "#loading_wrapper").show();
|
||||
@@ -826,7 +839,8 @@ var customer_name = "<%= @customer.name %>";
|
||||
var jcb1 = $('#jcbcount').text();
|
||||
var master1 = $('#mastercount').text();
|
||||
var unionpay1 = $('#unionpaycount').text();
|
||||
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1);
|
||||
var paymal1 = $('#paymalcount').text();
|
||||
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1) + parseFloat(visa1) + parseFloat(paymal1);
|
||||
var total = $('#amount_due').text();
|
||||
var amt = 0;
|
||||
<% if precision.to_i > 0 %>;
|
||||
@@ -854,8 +868,9 @@ var customer_name = "<%= @customer.name %>";
|
||||
var jcb = $('#jcbcount').text();
|
||||
var master = $('#mastercount').text();
|
||||
var unionpay = $('#unionpaycount').text();
|
||||
var paymal = $('#paymalcount').text();
|
||||
var amount_due = $('#amount_due').text();
|
||||
var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master) + parseFloat(unionpay)
|
||||
var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master) + parseFloat(unionpay) + parseFloat(paymal)
|
||||
var result = parseFloat(amount_due) - parseFloat(total);
|
||||
<% if precision.to_i > 0 %>
|
||||
$('#balance').text(parseFloat(result).toFixed(<%= precision %>));
|
||||
|
||||
@@ -177,7 +177,6 @@
|
||||
data: {redeem_amount:redeem_amount,membership_id:membership_id,sale_id:sale_id},
|
||||
success: function(result){
|
||||
if(result.status == true){
|
||||
console.log(result)
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: result.message,
|
||||
|
||||
@@ -665,11 +665,10 @@ $("#first_bill").on('click', function(){
|
||||
|
||||
$(".choose_payment").on('click', function () {
|
||||
$( "#loading_wrapper").show();
|
||||
|
||||
var sale_id = $('#sale_id').val();
|
||||
type = $('.payment_method').val();
|
||||
if(parseInt(jQuery.inArray("Credit", type)) == -1){
|
||||
if (parseInt(jQuery.inArray("MPU", type)) != -1 || parseInt(jQuery.inArray("VISA", type)) != -1 || parseInt(jQuery.inArray("JCB", type)) != -1 || parseInt(jQuery.inArray("Master", type)) != -1 || parseInt(jQuery.inArray("UNIONPAY", type)) != -1 || parseInt(jQuery.inArray("Redeem", type)) != -1) {
|
||||
if (parseInt(jQuery.inArray("MPU", type)) != -1 || parseInt(jQuery.inArray("VISA", type)) != -1 || parseInt(jQuery.inArray("JCB", type)) != -1 || parseInt(jQuery.inArray("Master", type)) != -1 || parseInt(jQuery.inArray("UNIONPAY", type)) != -1 || parseInt(jQuery.inArray("Redeem", type)) != -1 || parseInt(jQuery.inArray("PAYMAL", type)) != -1) {
|
||||
calculate_member_discount(sale_id,"Card");
|
||||
|
||||
}else{
|
||||
|
||||
@@ -20,11 +20,11 @@ class ActionController::Base
|
||||
end
|
||||
else
|
||||
# check for license file
|
||||
if check_license
|
||||
current_license(ENV["SX_PROVISION_URL"])
|
||||
else
|
||||
redirect_to activate_path
|
||||
end
|
||||
# if check_license
|
||||
# current_license(ENV["SX_PROVISION_URL"])
|
||||
# else
|
||||
# redirect_to activate_path
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -180,6 +180,7 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
post 'payment/paypar' => 'paypar_payments#create'
|
||||
post 'payment/credit' => 'credit_payments#create'
|
||||
post 'payment/voucher' => 'voucher_payments#create'
|
||||
post 'payment/paymal' => 'paymal#create'
|
||||
|
||||
get 'sale/:sale_id/:type/payment/credit_payment' => "credit_payments#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment' => "others_payments#index"
|
||||
@@ -187,6 +188,7 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
get 'sale/:sale_id/:type/payment/others_payment/VISA' => "visa#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/Master' => "master#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/JCB' => "jcb#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/PAYMAL' => "paymal#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/UNIONPAY' => "unionpay#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/Redeem' => "redeem_payments#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/Voucher' => "voucher#index"
|
||||
|
||||
12
spec/controllers/origami/paymal_controller_spec.rb
Normal file
12
spec/controllers/origami/paymal_controller_spec.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Origami::PaymalController, type: :controller do
|
||||
|
||||
describe "GET #index" do
|
||||
it "returns http success" do
|
||||
get :index
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
15
spec/helpers/origami/paymal_helper_spec.rb
Normal file
15
spec/helpers/origami/paymal_helper_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the Origami::PaymalHelper. For example:
|
||||
#
|
||||
# describe Origami::PaymalHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
RSpec.describe Origami::PaymalHelper, type: :helper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/views/origami/paymal/index.html.erb_spec.rb
Normal file
5
spec/views/origami/paymal/index.html.erb_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "paymal/index.html.erb", type: :view do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
Reference in New Issue
Block a user