How to integrate with Paypal payments through Ingresse.
Paypal method has a specific flow, that must be done one time per Paypal account. It is necessary in order to get customer permission to charge from Paypal account recurrently.
- Add the line below into your website header.
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
- Create the transaction to start the payment process Start Transaction
- If customer does not have a Paypal billing agreement ID in your database, creates a new Express Checkout Create a Express Checkout. It should be performed only once per customer.
- Execute at the client side, the function below:
paypal.Button.render({
// for development use 'sandbox' as 'env' value.
env: "production",
payment: function (data, action) {
// Add below the token returned from step 3.
return "BA-3A027712Y78623734";
},
onAuthorize: function (data, action) {
console.log(data);
}
}, '#paypal-button-element-id');
- Using the token created in the step above, then create a Billing Agreement by calling Create a Billing Agreement
- With all customer information, get the available installments for the customer by Get the Installments
- Then, create a new payment for transaction Pay Transaction to process the payment with Paypal customer wallet.