Quantcast
Channel: Active questions tagged paypal - Stack Overflow
Viewing all articles
Browse latest Browse all 472

Paypal credit Card Payment without login in to account is not working [closed]

$
0
0

I have a registration site where users can make Payments with PayPal.Currently, only users with PayPal accounts can make Payments.Now I'm implementing pay with credit or debit card in PayPal without needing to log in .I added the SDK URL, script code for creating a subscription with the plan ID, but when I click the Debit/credit card button for payment, it redirects to the page and shows a message that things are not working at the moment.

<script src="https://www.paypal.com/sdk/js?client-id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&vault=true&intent=subscription" data-sdk-integration-source="button-factory"></script><div id="paypal-button-container"></div> $(document).ready(function(){        var testpaymentform = $("#test_payment-form");        testpaymentform.validate({        errorElement: 'span',        errorClass: 'help-block',        highlight: function(element, errorClass, validClass) {            $(element).closest('.form-group').addClass("has-error");        },        unhighlight: function(element, errorClass, validClass) {            $(element).closest('.form-group').removeClass("has-error");        },        submitHandler: function(form,event) {              if(($('.newsletter input').val()== '1')){                if($('.newsletter input').prop('checked')==false)                {                    $('#newsletter').modal('show');                    event.preventDefault();                    return false;                }            }                          if (window.location.href.indexOf("purchaseCoursedirect") > -1) {                    if($('.age1 input').prop("checked") == false){                        $('#agedialogbox1').modal('show');                        event.preventDefault();                        return false;                    }                    else{                        if($('.age2 input').prop("checked") == false){                            $('#agedialogbox2').modal('show');                            event.preventDefault();                            return false;                        }                    }                }                $("#puchaseBtn").prop("disabled", true);                $('.nextBtn').click(function(e) {                    e.preventDefault();                });                $("#loader").show();                var couponStatus  = $('#coupon_code_status').val();                var tax  = $('#tax_number').val();                var taxStatus = $('#tax_status').val();                                var couponValue  = $('#coupon_code').val();                var discount = $('#discount').val();                var amount = $("#amount").val();                var site_url  = $('#site_url').val();                //vat number from form field                var vat_number = $('#vatnumber').val();                if(taxStatus== 'no') {                    if(tax !=''){                        alert(jsValidTax);                        $('.nextBtn').unbind('click');                        $("#puchaseBtn").prop("disabled", false);                        $("#loader").hide();                        return false;                    }                    //if user entered the vat number and not clicked the validate button.                    if(vat_number !=''){                        alert(jsTaxbuttonClick);                        $('.nextBtn').unbind('click');                        $("#puchaseBtn").prop("disabled", false);                        $("#loader").hide();                        return false;                    }                }                if(amount =='0'&& couponValue!=''){                    courseId = $('#CourseID').val();                    if (window.location.href.indexOf("purchaseCoursedirect") > -1) {                        var str = 'Du kannst den 0 Euro Code nur über den regulären Registrierungsprozess einlösen. Klicken Sie dazu bitte auf "Zur Registrierung". Nachdem du dich registriert hast, kannst du deinen 0 Euro Code einlösen.';                        alertify.confirm(str).setting({'title': "Benachrichtigung",'modal': false,'closable': false,'labels': { ok: 'Zur Registrierung', cancel: 'Abbrechen' },'onok': function() {                                window.location.href=site_url+'public/register';                            },'oncancel': function() {                               window.location.href=site_url+'/public';                            }                        });                    }                    else{                        addPurchaseCourse(courseId,couponValue);return false;                    }                }                 if((couponStatus == 'yes'&& couponValue !='') || (couponValue==''&& discount=='0') ){                    var paymentType = $('#paymentType').val();                    var newsletterValue = $("#newsletterValue").val();                    if(paymentType =='PAYPAL'){                        // return;                        // form.submit();                        if (typeof paypal !== 'undefined') {                            paypal.Buttons({                            style: {                                shape: 'rect',                                color: 'gold',                                layout: 'vertical',                                label: 'subscribe'                            },                            createSubscription: function(data, actions) {                                return actions.subscription.create({                                plan_id: 'P-xxxxxxxxxxxxxxxx'                                });                            },                            onApprove: function(data, actions) {                                alert('Subscription completed! ID: '+ data.subscriptionID);                            },                            onError: function(err) {                                alert('error');                                console.error('PayPal Button Error:', err);                            }                            }).render('#paypal-button-container');                        } else {                            console.error("PayPal SDK not loaded yet.");                        }                    }else if(paymentType =='CCARD'){                        stripe.createToken(card).then(function(result) {                            if (result.error) {                              // Inform the user if there was an error.                              var errorElement = document.getElementById('card-errors');                              errorElement.textContent = result.error.message;                              $('.nextBtn').unbind('click');                              $("#puchaseBtn").prop("disabled", false);                              $("#loader").hide();                              console.log('token not created');                            } else {                              // Send the token to your server.                              console.log('token created');                              stripeTokenHandler(result.token);                            }                        });                       }else if(paymentType =='EPS'){                        form.submit();                    }                    else  {                        $('.nextBtn').unbind('click');                        $("#puchaseBtn").prop("disabled", false);                        $("#loader").hide();                    }                }else if(couponStatus!= 'no'&&couponValue !=''){                    validateCouponCode(true);                }else if(couponValue !=''&& couponStatus== 'no') {                    alert(jsValidCoupon);                    $('.nextBtn').unbind('click');                    $("#puchaseBtn").prop("disabled", false);                    $("#loader").hide();                    return false;                }else if(couponStatus == 0 || couponStatus== 'no') {                    alert(jscouponCodeReturned);                    location.reload();                }        }    });

Viewing all articles
Browse latest Browse all 472

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>