paypal checkout无法正常工作

时间:2017-03-11 16:07:23

标签: javascript jquery html css paypal

我想将paypal添加到我的网站,但它不显示需要支付的金额,而是显示客户可以随意输入并获得产品的金额。我的网站是一个任务帮助网站,人们必须选择需要多少天以及需要完成多少页面,所以我不能提出具体的价格点,因为用户将输入天数和页数以及价格将自动计算,当转发到PayPal支付页面时,它应显示要支付的价格。但是在我的网站上,当用户被转发到结账页面时,要求用户输入我不想要的金额,因为如果用户输入1 $那么我将不得不给他/她1美元的任务原价是8美元(假设)。那么,如何让paypal知道用户在自动发送到结账页面时必须支付的价格?

我的订单页面 order page

还有两个页面,第一个图像显示一个随机图像,用户被要求输入数量,并在顶部显示al muhairi。我不知道它是什么。 1st image

在第二页中,它显示了我为追踪目的而输入的金额,而不是我想要的自动价格,即8美元 请帮我解决这个问题.. 2nd image

这是代码

<script src="http://code.jquery.com/jquery.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

    <!-- Section Start For Jquery Validatation Scripts -->
    <script src="https://cdn.jsdelivr.net/jquery.validation/1.15.0/jquery.validate.min.js"></script>
    <script src="https://cdn.jsdelivr.net/jquery.validation/1.15.0/additional-methods.min.js"></script>

    <script src="js/jQuery.validator.js"></script>
     <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
    <!-- Section End For Jquery Validatation Scripts -->
<script>

function initalamout(){
  var pages=parseInt($('#selectPages').val());
    console.log('pages - '+pages);

    var amount_day1=pages * 8;
    var amount_day2=pages * 7;
    var amount_day35=pages * 6;
    var amount_day69=pages * 5;

    console.log(amount_day1);
    console.log(amount_day2);
    console.log(amount_day35);
    console.log(amount_day69);

    $('.litExpress').text("$"+amount_day1);
    $('.litFast').text("$"+amount_day2);
    $('.litStandard').text("$"+amount_day35);
    $('.litMinimal').text("$"+amount_day69);

    $('#express').val("$"+amount_day1);
    $('#fast').val("$"+amount_day2);
    $('#standard').val("$"+amount_day35);
    $('#minimal').val("$"+amount_day69);


}
function myDateFormatter (dateObject) {
        var d = new Date(dateObject);
        var day = d.getDate();
        var month = d.getMonth() + 1;
        var year = d.getFullYear();
        if (day < 10) {
            day = "0" + day;
        }
        if (month < 10) {
            month = "0" + month;
        }
        var date = month + "/" + day + "/" + year;

        return date;
    }
    function update_date_price(dateobj){

      var page=$('#selectPages').val();
       var str=dateobj;
       console.log("price in fncc= "+str);
        var res = str.replace("$", "");
        var res=parseInt(res);
        $('#lblamount').text("$"+res);
        $('#payamount').val(res);
        console.log("amount - "+res);
        var days=0;
        if((res%8)==0){
          days=1;
        }
        if((res%7)==0){
          days=2;
        }
        if((res%6)==0){
          days=5;
        }
        if((res%5)==0){
          days=9;
        }
        console.log("days-"+days);
        console.log("deadline - "+$("#deadlinehide").val());
         var date = new Date($("#deadlinehide").val());

         console.log("Date - "+date);
        if(!isNaN(date.getTime())){
            date.setDate(date.getDate() + days);

            $("#datepicker").val(myDateFormatter(date));
        } else {

        }
    }
 $( document ).ready(function() {

  $('#fileupload').on( 'change', function() {
   myfile= $( this ).val();
   var ext = myfile.split('.').pop();

   if(ext=="pdf" || ext=="docx" || ext=="xls" || ext=="xlsx" || ext=="doc"){
       //alert(7);
   } else{
       alert("Invalid File Format Uploaded");
   }
});

    initalamout();
    $('#paypal-frm').hide();

//$("#datepicker").datepicker().datepicker("setDate", new Date());
$('#deadlinehide').val(myDateFormatter(new Date()));
var rndval=Math.floor(100000000 + Math.random() * 900000000);
   $('#lblreference').text(rndval);
   $('#hdreference').text(rndval);
   $( "#datepicker" ).datepicker({

    onSelect: function(dateText, inst) {
//             alert(dateText);
              var cost=dateText;
        console.log("cost - "+cost);
        $('#deadlinehide').val(cost);

        },  format: 'mm/dd/yyyy'
   }).datepicker("setDate", new Date());

    $('input[type=radio][name=optionsRadios]').change(function() {

        $('#lblamount').text("$"+this.value);
        $('#payamount').val(this.value);
        console.log("val - "+this.value);
       update_date_price(this.value);


    });

    $('#selectPages').on('change', function() {

    var pages=parseInt(this.value);
    console.log('pages - '+pages);

    var amount_day1=pages * 8;
    var amount_day2=pages * 7;
    var amount_day35=pages * 6;
    var amount_day69=pages * 5;

    console.log(amount_day1);
    console.log(amount_day2);
    console.log(amount_day35);
    console.log(amount_day69);

    $('.litExpress').text("$"+amount_day1);
    $('.litFast').text("$"+amount_day2);
    $('.litStandard').text("$"+amount_day35);
    $('.litMinimal').text("$"+amount_day69);

    $('#express').val("$"+amount_day1);
    $('#fast').val("$"+amount_day2);
    $('#standard').val("$"+amount_day35);
    $('#minimal').val("$"+amount_day69);

//      $('#lblamount').text(this.value);


    update_date_price($('input[name=optionsRadios]:checked', '#main-frm').val());

    });


    $.validator.addMethod("birth", function (value, element) {
        var year = value.split('/');
        if ( value.match(/^\d\d?\/\d\d?\/\d\d\d\d$/) && parseInt(year[2]) <= 1990 )
            return true;
        else
            return false;
    },"Please enter a date in the format dd/mm/yyyy.");


    $('#main-frm').validate({ // initialize the plugin
         errorClass: "invalid-msg",
        rules: {
            name: {
                required: true                
            },

            email:{
              required: true,    
              email:true          
            },
            cemail:{
              required:true,
              email:true,
              equalTo: "#email"
            },
            subject:{
              required:true

            },
            message:{
              required: true,
              maxlength: 250
            },
            deadlinedate:{
              required: true,

            }

        }
      /*  submitHandler: function (form) { // for demo
            alert('valid form submitted'); // for demo
            console.log('a');
            return false; // for demo
        }*/
    });

       $('#submit-btn').on('click', function() {

        if($("#main-frm").valid()){
        //$("#submit-btn").submit();  
        var paypalamount=$('#lblamount').text();
        var paypalitem=$('input[name=optionsRadios]:checked', '#main-frm').attr('id');
        var paypalreferencenumber=$('#lblreference').text();
console.log("--");
        console.log(paypalamount);
        console.log(paypalitem);
        console.log(paypalreferencenumber);
        //$('#paypal-amount').text(paypalamount);
        $('#am').val(paypalamount.replace("$", ""));
        //$('#paypal-item').text(paypalitem);
        //$('#paypal-referencenumber').text(paypalreferencenumber);

        alert('You Can Proceed For Paypal Checkout Now');
        //$("#submit-btn").hide();
        //$('#paypal-frm').show();

        if($('input[type=radio][name=optionsRadios]').val()=="$8"){
          $('#planchoosen').val("Express");
        }
        if($('input[type=radio][name=optionsRadios]').val()=="$7"){
         $('#planchoosen').val("Fast"); 
        }
        if($('input[type=radio][name=optionsRadios]').val()=="$6"){
          $('#planchoosen').val("Standard");
        }
        if($('input[type=radio][name=optionsRadios]').val()=="$5"){
          $('#planchoosen').val("Minimal");
        }
        $('#main-frm').submit();
        }
    });


    });

    </script>

https://jsfiddle.net/bmcbs3bo/

抱歉英语不好,不是我的母语

0 个答案:

没有答案