Hola hermano.
Estoy muy agradecido con tu ayuda. Me ha sido muy útil. Actualmente estoy trabajando en el cambio en los ajustes.
Te agradezco nuevamente si por favor me puedes orientar un poco. He leído la documentación de PayPal pero necesito una guía. Esto es lo que tengo hasta el momento:
Código:
<!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 = '/pp/create-payment/';
var EXECUTE_PAYMENT_URL = '/pp/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);
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>
El método de integración que escogí es "
Server-side REST".
Estoy en "Creación del Pago".El archivo está en la ruta '/pp/create-payment/index.php'
Por medio del método "payment" llamamos al archivo '/pp/create-payment/index.php' y lo configuramos.
Dentro de este archivo index.php estoy incluyendo este código que encontré en PayPal como referencia:
Código:
curl -v https://api.sandbox.paypal.com/v1/payments/payment \\
-H 'Content-Type: application/json' \\
-H 'Authorization: Bearer Access-Token' \\
-d '{
"intent": "sale",
"experience_profile_id":"experience_profile_id",
"redirect_urls":
{
"return_url": "https://example.com",
"cancel_url": "https://example.com"
},
"payer":
{
"payment_method": "paypal"
},
"transactions": [
{
"amount":
{
"total": "4.00",
"currency": "USD",
"details":
{
"subtotal": "2.00",
"shipping": "1.00",
"tax": "2.00",
"shipping_discount": "-1.00"
}
},
"item_list":
{
"items": [
{
"quantity": "1",
"name": "item 1",
"price": "1",
"currency": "USD",
"description": "item 1 description",
"tax": "1"
},
{
"quantity": "1",
"name": "item 2",
"price": "1",
"currency": "USD",
"description": "item 2 description",
"tax": "1"
}]
},
"description": "The payment transaction description.",
"invoice_number": "merchant invoice",
"custom": "merchant custom data"
}]
}'
¿Cómo obtener el Access-Token ? Cualquier corrección se lo agradezco.
Gracias.