cancel
Showing results for 
Search instead for 
Did you mean: 

When clicked on smart buttons it's not working

Options
ligena
New Community Member
Posted on

Before i clickBefore i clickAfter i click half of a secondAfter i click half of a secondthen becomes this O.othen becomes this O.o I wanted to create a smart button. I thought i did something wrong in codes but it's like that even when i test 

2 REPLIES 2

When clicked on smart buttons it's not working

Options
JackieDaytona
Contributor


// Render the PayPal button into #paypal-button-container
// by David . Nugent - Using PayPal REST V2 API Last update: 05/27/2020
paypal.Buttons({

style: {
layout: 'horizontal',
color: 'gold',
shape: 'pill',
label: 'checkout',
size: 'responsive',
tagline: 'true',
},

// Set up the transaction
createOrder: function(data, actions) {
$('#paypalmsg').hide();
$('#transmsg').show();
$('#transmsg').html('<b>'+'WAITING ON AUTHORIZATION...'+'</b>');
$('#chkoutmsg').hide()
return actions.order.create({
purchase_units: [{
description: 'GnG Order',
amount: {
value: cartTotal
}
}],
application_context: {
shipping_preference: 'NO_SHIPPING'
}

});
},
/* onClick: function() { */

/* },*/

// Finalize the transaction
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
/*return actions.order.get().then(function(orderDetails) { */
// Show a success message to the buyer
$('#transmsg').html('<b>' + 'AUTHORIZED...' + '</b>');
$('#transmsg').append('<br>'+'Transaction completed by: ' + details.payer.name.given_name +' '+ details.payer.name.surname + '<br>' + "Order Id: " + details.id + '<br>' + 'Status: PAID & APPROVED' + '<br>'+ 'Thank You For Your Order'+ '<br>');
if (details.status === "COMPLETED") {
window.setTimeout(function() {}, 500)
$('#transmsg').append('<b>' + 'Sending Order...Please Wait' + '</b>'+'<br>');
/* var getId = '#'+ $('span:contains("Market")').attr('id');
var getmrktDiv = '#'+ $(getId).offsetParent().attr('id');
var mrktchkId = '#'+ $(getmrktDiv).closest(getmrktDiv).find(".chkbox").attr('id');
var mrktpriceId = '#'+ $(getmrktDiv).closest(getmrktDiv).find(".price").attr('id');
var chkboxId = "#chk6";
var hidpriceId = "#pricef";
var marketLocation = $(mrktchkId);

if (marketLocation.length > 0 ) {
var checked = $(mrktchkId).prop('checked');
if (!checked) {
var storedVal = $(mrktpriceId).val();
if ($(mrktpriceId+':not([data-val])')) {
$(mrktpriceId).attr("data-val", storedVal);
}
$(mrktpriceId).val("");
}
} */

$('#transid').val(details.id);
$('#orderstat').val('APPROVED');
$('#orderform').submit();
}
});


if (details.error === 'INSTRUMENT_DECLINED') {
$('#transmsg').html('<b>' + 'TRANSACTION WAS DECLINED'+'</b>');
$('#transmsg').fadeIn('slow').delay(3000).fadeOut('slow', function() {
$('#paypalmsg').show();
$('#chkoutmsg').show();
$('#transmsg').empty();
});

return actions.restart();
};
},

onCancel: function(data) {
$('#transmsg').html('<b>' + 'YOUR TRANSACTION WAS CANCELLED' + '</b>');
$('#transmsg').fadeIn('slow').delay(3000).fadeOut('slow', function() {
$('#paypalmsg').show();
$('#chkoutmsg').show();
$('#transmsg').empty();
});
}

}).render('#paypal-button-container');

 

When clicked on smart buttons it's not working

Options
MTS_Andre
Moderator

Hi, you can start with adding the basic html code to render the button following the demo here (client side)

Remember to replace the client ID with your own one --> www.paypal.com/sdk/js?client-id=__YOUR_CLIENT_ID_HERE__

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.