Go to "https://www.paypal.com/us/home" -------> Sign In/ Sign Up
Sign in or create an account
Once in the dashboard go to developer
Go to "Get API Credentials"
Choose Sandbox or Live ---> Create App
Choose the name ---> Create App
Copy the Client ID
Open the HTML by notepad++ or visual studio code (Download HTML Here or copy it below)
<!-- This is an html extension for Paypal
consider nominate me
modify the things below -->
<div id="smart-button-container">
<div style="text-align: center;">
<div id="paypal-button-container"></div>
</div>
</div>
<script src="https://www.paypal.com/sdk/js?client-id=sb&enable-funding=venmo¤cy=USD" data-sdk-integration-source="button-factory"></script>
</script>
<!-- just here, (sb)n1 here n2-->
<script>
let datas = window.AppInventor.getWebViewString();
let x = datas.split(",");
let currency = x[0];
let value = x[1];
let description = x[2];
//src="http://localhost/tramezzo.js"
function initPayPalButton() {
paypal.Buttons({
style: {
shape: 'pill',
color: 'gold',
layout: 'vertical',
label: 'paypal',
},
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{"description":description,"amount":{"currency_code":currency,"value": value}
}]
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(orderData) {
// Full available details
console.log('Capture result', orderData, JSON.stringify(orderData, null, 2));
// Show a success message within this page, e.g.
const element = document.getElementById('paypal-button-container');
element.innerHTML = '';
element.innerHTML = '<h3>Thank you for your payment!</h3>';
if (element.innerHTML = "Thank you for your payment!"){window.AppInventor.setWebViewString("Thank you for your payment!")}
// Or go to another URL: actions.redirect('thank_you.html');
});
},
onError: function(err) {
console.log(err);
}
}).render('#paypal-button-container');
}
initPayPalButton();
</script>
Put the copied Client ID over n1
and the value n2 is the currency
Dollar ----->USD
Australian dollar ----->AUD
Canadian dollar ----->CAD
Swiss franc ----->CHF
Japanese Yen ----->JPY
New Zealand dollar ----->NZD
Euro ----->EUR
Pound ----->GBP
Swedish krona ----->SEK
Danish krone ----->DKK
Singapore dollar ----->SGD
Hong Kong Dollar ----->HKD
Mexican Peso ----->MXN
Zloty ----->PLN
Ruble ----->RUB
Turkish Lira ----->TRY
Rand ----->ZAR
Yuan ----->CNH
Save and open app inventor
Create a new project, add a WebViewer, a notifier and go to the blocks.
Put the code in the photo or copy from the example
WARNING!!! It works only in the main page
It will be like this sample button