Di sotto riporto il codice che ho preso dal kit sviluppatori PayPal.
Ho fatto la prova e funziona.
Visto che sono una pippa in .js qualcuno mi sa dire come gli devo passare l'importo corretto?
Grazie.
codice:
<div id="paypal-button-container"></div>
<script>
// Render the PayPal button
paypal.Button.render({
// Set your environment
env: 'production', // sandbox | production
// Specify the style of the button
style: {
label: 'checkout', // checkout || credit
size: 'small', // tiny | small | medium
shape: 'pill', // pill | rect
color: 'blue' // gold | blue | silver
},
// PayPal Client IDs - replace with your own
// Create a PayPal app: https://developer.paypal.com/developer/applications/create
client: {
sandbox: 'AZDxjDScFpQtjWTOUtWKbyN_bDt4OgqaF4eYXlewfBP4-8aqX3PiV8e1GWU6liB2CUXlkA59kJXE7M6R',
},
// Wait for the PayPal button to be clicked
payment: function() {
// Make a client-side call to the REST api to create the payment
return paypal.rest.payment.create(this.props.env, this.props.client, {
transactions: [
{
amount: { total: '0.01', currency: 'EUR' }
}
]
});
},
// Wait for the payment to be authorized by the customer
onAuthorize: function(data, actions) {
return actions.payment.execute().then(function() {
window.alert('Payment Complete!');
});
}
}, '#paypal-button-container');