0

I have a small problem with the paypal button by default I try to hide it to show my own button: /

Here is my code .js

$(document).ready(function(){
$.getScript("https://www.paypalobjects.com/api/checkout.js", function(){

    paypal.Button.render({
        env: 'sandbox', // Or 'sandbox',

        commit: true, // Show a 'Pay Now' button

        style: {
        color: 'gold',
        size: 'small'
        },

        payment: function(data, actions) {
        var create_payment  = 'config/app/API/paypal/payment.php';
        return paypal.request.post(create_payment).then(function(data) {
            return data.id;
        });
    },

        onAuthorize: function(data, actions) {
        var execute_payment = 'config/app/API/paypal/pay.php';
        return paypal.request.post(execute_payment, {
            paymentID: data.paymentID,
            payerID:   data.payerID
        }).then(function(data) {

    //
            });

        });
        },

        onCancel: function(data, actions) {
        /* 
        * Buyer cancelled the payment 
        */
        },

        onError: function(err) {

        alert('error', err);

        console.log(err);

        }
    }, '#btn-checkout');
});

});

<div class="btn-paypal" id='btn-checkout'>Payer avec paypal</div>

the problem is that i always have the yellow paypal button that appears at the bottom of my button i can not get to the mask.

doe
  • 3
  • 4

1 Answers1

0

I mean this:

$(document).ready(()=>{
  $(".newbutton").click(()=>{
    $(".paypalbutton").trigger("click")
  })

  $(".paypalbutton").click(()=>{
    alert("Example function that this was executed while pressing the other button")
  })
})
.paypalbutton{
display:none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a class="paypalbutton" href="#whatever">Pay</a>

<a class="newbutton" href="javascript:void(0)">Pay</a>

What this does is to use a fake button to execute another one.

Let me know if you understand and if it works!