javascript sdk not rendering buttons on mobile

compbob
Contributor
Contributor

Installed smart buttons on a go daddy website and dropping in HTML code.  Buttons work perfectly on desktop webpages, however they do not appear on mobile.  

 

<div id="smart-button-container1">
<div style="text-align: center;">
<div style="margin-bottom: 1.25rem;">
<p><label id="item-optionslbl1" style="font:larger;font-weight:bold">Dec 10th - 7:30PM - 22.50 USD</label></p>
<p>Select the number of tickets below for December 10th</p>
<select style="visibility: visible" id="quantitySelect1"><option value="1">1<option value="2">2<option value="3">3<option value="4">4<option value="5">5<option value="6">6<option value="7">7<option value="8">8<option value="9">9<option value="10">10<option value="11">11<option value="12">12<option value="13">13<option value="14">14<option value="15">15<option value="16">16<option value="17">17<option value="18">18<option value="19">19<option value="20">20</select>
</div>
<div id="paypal-button-container1"></div>

</div>
</div>
<hr>

 

<script src="https://www.paypal.com/sdk/js?client-id=xxxxyyyy&disable-funding=venmo,paylater&currency=USD" ></script>

 

 

<script>
var itemdesc1 = "description- 22.50 USD";
function initPayPalButton1() {
var shipping = 0;
var itemOptions = itemdesc1;
var quantity = parseInt(20);
var quantitySelect = document.querySelector("#smart-button-container1 #quantitySelect1");
if (!isNaN(quantity)) {
quantitySelect.style.visibility = "visible";
}
var orderDescription = "It's a Wonderful Life - Dec 10";
if (orderDescription === '') {
orderDescription = 'Item';
}
paypal.Buttons({
style: {
shape: 'rect',
color: 'gold',
layout: 'vertical',
label: 'paypal',

},

createOrder: function (data, actions) {
var selectedItemDescription = itemdesc1;
var selectedItemPrice = 22.50;
var tax = (0 === 0 || false) ? 0 : (selectedItemPrice * (parseFloat(0) / 100));
if (quantitySelect.options.length > 0) {
quantity = parseInt(quantitySelect.options[quantitySelect.selectedIndex].value);
} else {
quantity = 1;
}

tax *= quantity;
tax = Math.round(tax * 100) / 100;
var priceTotal = quantity * selectedItemPrice;
priceTotal = Math.round(priceTotal * 100) / 100;
var itemTotalValue = Math.round((selectedItemPrice * quantity) * 100) / 100;

return actions.order.create({
purchase_units: [{
description: orderDescription,
amount: {
currency_code: 'USD',
value: priceTotal,
breakdown: {
item_total: {
currency_code: 'USD',
value: itemTotalValue,
},
shipping: {
currency_code: 'USD',
value: shipping,
},
tax_total: {
currency_code: 'USD',
value: tax,
}
}
},
items: [{
name: selectedItemDescription,
unit_amount: {
currency_code: 'USD',
value: selectedItemPrice,
},
quantity: quantity
}]
}]
});
},
onApprove: function (data, actions) {
return actions.order.capture().then(function (orderData) {

// Full available details
console.log('Capture result', orderData, JSON.stringify(orderData, null, 2));


actions.redirect('http://www.brewstertheatercompany.org/');

});
},
onError: function (err) {
console.log(err);
},
}).render('#paypal-button-container1');
}
initPayPalButton1();
</script>

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

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