PayPal
First, hire PayPal choosing Cielo as a service provider.
At PayPal, it is possible to chose for automatic or posterior capture.
The merchant should integrate PayPal with Gateway in the backend. It is also possible to include the PayPal button in the checkout page.
Integrating with Gateway
In the e-wallet authorization request, send the parameter Provider
as "PayPal" and Type
as "Wallet".
Request
POST /v2/sales/
{
"MerchantOrderId": "mwrzdV42BrvDshqJoIClljPWJ",
"Customer": {
"Name": "Teste bsales",
"Identity": "12345678909",
"IdentityType": "CPF",
"Address": {
"Street": "Alameda Xingu",
"Number": "512",
"Complement": "27 andar",
"ZipCode": "12345987",
"City": "São Paulo",
"State": "SP",
"Country": "BRA",
"District": "Alphaville"
}
},
"Payment": {
"Capture": true,
"ReturnUrl": "http://httpbin.org/get",
"Provider": "PayPal",
"Type": "Wallet",
"Amount": 57000,
"Currency": "BRL",
}
Response
{
"MerchantOrderId": "mwrzdV42BrvDshqJoIClljPWJ",
"Customer": {
"Name": "Teste bsales",
"Identity": "12345678909",
"IdentityType": "CPF",
"Address": {
"Street": "Alameda Xingu",
"Number": "512",
"Complement": "27 andar",
"ZipCode": "12345987",
"City": "São Paulo",
"State": "SP",
"Country": "BRA",
"District": "Alphaville"
}
},
"Payment": {
"SentOrderId": "mwrzdV42BrvDshqJoIClljPWJ",
"AcquirerTransactionId": "2X794637K7381181L",
"Capture": true,
"RedirectUrl": "https://www.sandbox.paypal.com/checkoutnow?token=2X794637K7381181L",
"PaymentId": "7529c7d1-7e95-480c-8604-067e45eb7425",
"Type": "Wallet",
"Amount": 57000,
"ReceivedDate": "2021-12-20 16:33:20",
"Currency": "BRL",
"Country": "BRA",
"Provider": "PayPal",
"ReturnUrl": "http://httpbin.org/get",
"ReasonCode": 0,
"ReasonMessage": "Successful",
"Status": 12,
"ProviderReturnCode": "201",
"ProviderReturnMessage": "CREATED",
"Links": [{
"Method": "GET",
"Rel": "self",
"Href": "https://apiquerysandbox.braspag.com.br/v2/sales/7529c7d1-7e95-480c-8604-067e45eb7425"
}]
}
}
Adding the PayPal button
In order to add the PayPal button to the checkout page, follow the Paypal script along with the API Gateway de Pagamento integration.
Include the HTML script on your checkout page. This script will insert the PayPal button and will provide two functions that need to be developed to connect with Braspag:
createOrder
: executes the transaction authorization step (and must be integrated on the backend with the Payor's authorization method);onApprove
: captures the transaction amount.
In the script, replace the demo URL of the onApprove function ('/demo/checkout/api/paypal/order/') with paypal/{transactionId}/manualapprove.
Replace the other fields according to your backend to consume the authorization method of Braspag. See the image for an example of how the code will look.
Read and copy the complete script on the PayPal button integration page.
Updated 1 day ago