Smart Checkout Payment not coming through

ekilpatrick
Contributor
Contributor

Hi all!

 

I have set up the Smart Button Checkout on my website. I tested it with my personal card, but no payment is showing up in my paypal or on my credit card even tho I get the notification at the end saying it has confirmed my transaction. 

 

I'd love any help! 

Thanks! 

 

Login to Me Too
5 REPLIES 5

Gabriel_PP
Moderator
Moderator

Hi @ekilpatrick 

Thanks for using our Community Forum,

I see, apologies.

Would you mind providing me the steps to reproduce a purchase on your site? URL of your Site? Code of your button?

 

Thanks,

Login to Me Too

ekilpatrick
Contributor
Contributor

Hi! 

 

Yes here you go. thanks! So basically i created a new page, put in the text, pasted the code, and then published it. However, even when it shows up, and the process of purchasing something works, i don't see any withdrawal from my bank account or any thing new in my paypal. 

https://www.cmscva.org/

 

<div id="smart-button-container">
<div style="text-align: center;">
<div style="margin-bottom: 1.25rem;">
<p></p>
<select id="item-options"><option value="5 Dollars" price="5">5 Dollars - 5 USD</option><option value="15 Dollars" price="15">15 Dollars - 15 USD</option><option value="30 Dollars" price="30">30 Dollars - 30 USD</option><option value="60 Dollars" price="60">60 Dollars - 60 USD</option><option value="Custom" price="">Custom - USD</option></select>
<select style="visibility: hidden" id="quantitySelect"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select>
</div>
<div id="paypal-button-container"></div>
</div>
</div>
<script src="https://www.paypal.com/sdk/js?client-id=sb&currency=USD" data-sdk-integration-source="button-factory"></script>
<script>
function initPayPalButton() {
var shipping = 0;
var itemOptions = document.querySelector("#smart-button-container #item-options");
var quantity = parseInt(10);
var quantitySelect = document.querySelector("#smart-button-container #quantitySelect");
if (!isNaN(quantity)) {
quantitySelect.style.visibility = "visible";
}
var orderDescription = '';
if(orderDescription === '') {
orderDescription = 'Item';
}
paypal.Buttons({
style: {
shape: 'pill',
color: 'silver',
layout: 'vertical',
label: 'checkout',

},
createOrder: function(data, actions) {
var selectedItemDescription = itemOptions.options[itemOptions.selectedIndex].value;
var selectedItemPrice = parseFloat(itemOptions.options[itemOptions.selectedIndex].getAttribute("price"));
var tax = (0 === 0) ? 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 + parseFloat(shipping) + tax;
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(details) {
alert('Transaction completed by ' + details.payer.name.given_name + '!');
});
},
onError: function(err) {
console.log(err);
},
}).render('#paypal-button-container');
}
initPayPalButton();
</script>

Login to Me Too

Gabriel_PP
Moderator
Moderator

Hi @ekilpatrick 

Thanks for the information,

 

The problem is that you are redirecting your buyers to our Sandbox environment:

https://www.sandbox.paypal.com/checkoutnow?sessionID=

This is your code:

src="https://www.paypal.com/sdk/js?client-id=sb&currency=USD"


You need to pass your LIVE credentials (client ID) on the client-id variable.

In order to get the REST API credentials (Secret and Client ID) please do the following:

- go to https://developer.paypal.com/
- on the top right corner click "log-in into Dashboard"
- use your PayPal/Developer credentials to login
- click on Dashboard - "My Apps & Credentials"
- from the "APP name" menu choose your App and click on it
In here you can see all the details and credentials. Please NOTE that to check for LIVE credentials you have to click on the top right corner switch (LIVE/Sandbox) the LIVE button.

Also it could be that the client ID is correct but you are pointing to Sandbox instead of Live or viceversa:

Sandbox: POST https://api.sandbox.paypal.com/v1/oauth2/token

Live: POST https://api.paypal.com/v1/oauth2/token

 

If you have any issues doing this, please contact your developer or person handling the integration to get this sorted.

Thanks and apologies,

Login to Me Too

ekilpatrick
Contributor
Contributor

hi! 

 

thank you so much for this. Unfortunately, we don't have a developer right now and I'm trying to figure it out on my own. I attempted to do it but I'm really not sure what I'm doing so I'm going to hold off for right now. 

 

I really appreciate your help and hopefully, if I understand more in the future I can use your information to make it work. 

 

Best, 

 

Elizabeth 

Login to Me Too

Gabriel_PP
Moderator
Moderator

Hi @ekilpatrick 

Thanks for your response,

 

I understand! Yes, this might sound a bit complicated, but it's not thaaat baad! If you take some time, I believe you can do it. 

You have other workarounds.

 

You could create your button using our tool on your profile:

(login to your PayPal account and click on this link:) 

https://www.paypal.com/it/cgi-bin/webscr?cmd=_button-management

 

There you should have some options to create different type of buttons, or you can do them manually:

Example code: https://developer.paypal.com/docs/paypal-payments-standard/integration-guide/html-example-buy-now/

You can edit them according to your needs, but you need to pass your paypal email account on the Business variable:

<input type="hidden" name="business" value="addyouremailhere">

 

I hope this helps, best of luck! 

Thanks,

 

 

Login to Me Too

Haven't Found your Answer?

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