hI everybody. I have this code: <!DOCTYPE html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
</head>
<body>
<div id="paypal-button-container"></div>
<script>
var CREATE_PAYMENT_URL = '/paypal/create-payment';
var EXECUTE_PAYMENT_URL = '/paypal/execute-payment/';
paypal.Button.render({
env: 'sandbox', // sandbox | production
// Show the buyer a 'Pay Now' button in the checkout flow
commit: true,
// payment() is called when the button is clicked
payment: function() {
return paypal.request.post(CREATE_PAYMENT_URL).then(function(data) {
//console.log(" ID del pago retornado: " + data);
console.log(CREATE_PAYMENT_URL);
return data.id;
});
},
// onAuthorize() is called when the buyer approves the payment
onAuthorize: function(data) {
return paypal.request.post(EXECUTE_PAYMENT_URL, {
paymentID: data.paymentID,
payerID: data.payerID
}).then(function() {
// The payment is complete!
// You can now show a confirmation message to the customer
alert("Felicidades! El pago fue realizado.");
}).catch(function(err) {
console.log(err);
});
console.log(" Data " + data);
},
onCancel: function(data, actions) {
return actions.redirect();
}
}, '#paypal-button-container');
</script>
</body> I have been reading about Paypal Rest Api. I read the function return JSON data, so what code I must to include in '/paypal/create-payment'; ? Please, I need a complete example. Thanks
... View more