PagSeguro Integration
In this section, we will walk you through the detailed steps for integrating Google Pay with PagSeguro. This includes the transaction flow, the necessary steps to collect and submit payment data, how to handle the API responses, and how to track the transaction status. By following these instructions, you can seamlessly process Google Pay transactions through the PagSeguro API in your application.
PagSeguro Transaction Flow

- Customer → Merchant: The customer completes the purchase on the merchant's site or app.
- Merchant → PagSeguro: The merchant server validates the customer’s data and sends the transaction to PagSeguro.
- PagSeguro → Merchant: PagSeguro processes the request and returns the transaction details.
- Merchant → Customer: The merchant server returns the transaction data to the customer.
Follow the steps below to create a Google Pay payment:
Step 1: Collecting Necessary Data
To create a Google Pay payment transaction with PagSeguro, use the following objects: integration
, order
, charge
, and payer
. You will add the token generated by Google Pay in the charge
object. The Create a Transaction endpoint page provides a comprehensive list of the required details.
Step 2: Submitting a Payment Request
After collecting all necessary information, submit a POST request to the Create a Transaction endpoint. You can find an example below.
{
"integration": {
"reference": "REF-XXX-1234567890",
"notification_url": "https://www.merchantwebsite.com/notify?type=transaction",
"language": "pt_BR"
},
"order": {
"currency": "BRL",
"items": [
{
"quantity": 1,
"description": "Product description",
"unit_price": 101.10
}
]
},
"charge": {
"country": "BR",
"type": "CREDIT_CARD",
"credit_card": {
"google_pay": {
"token": "{\"signature\":\"MEUCIQCpdjkwGbZHReTIo/G5muX0mpbbSE1Yo2L0Sk68GRQXegIgX4evAuOb8+SrYyUMV42isn4wABuoyKveYkwF/y3bLCM\\u003d\",\"intermediateSigningKey\":{\"signedKey\":\"{\\\"keyValue\\\":\\\"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEn58WtMd+S2bLaqUAVWpilWWzQBu8t9Xm5zgb6AN5buOcYbVG2ELx59XZGcYo3KscSY6h/x2XuRoBBE5DFR4VNA\\\\u003d\\\\u003d\\\",\\\"keyExpiration\\\":\\\"1700159511279\\\"}\",\"signatures\":[\"MEUCIQDkLiLhgYLkhq7sXKHD+uyv/bZjDbiwqbugNUIyOT1YAwIgEjfLQ77q6cgIcTNyetxIYHUSyghtshmkxsEzx5vDcyk\\u003d\"]},\"protocolVersion\":\"ECv2\",\"signedMessage\":\"{\\\"encryptedMessage\\\":\\\"MU6eLCx3Pm2iTvsvOI2n73KmTavd9IyEtDBG1lEP33klvkwGH4Sb6AlJ2ocDW3IP6X1XK6Cd5clMGEWL0nsMazpCdxdyIhGjyMmtQaKBm0kyRe2/UAPTMMp4++sHPPs5q7GXFz/89KSEYxJUnfDWe73o8dEzlUqUro3Ik5jpaFcWXZppUgYaTVCGawKky+DML54LEvVK4WVfjsJs1MrSa8bgtYXq2AsHlvOWWnxBp+uv96mV4BOt8kveaZ5RQJIRiqVXIcx45ayakPaOS8cTAVqQA0/buiQiJmrfLVzMsqIOqJost88XGPk0y1SC4DdxA1uy8S/GckNlyIyZ3qjrPrBX7st5L+yLnGBFZYtgYFUW7hbcY1ELV8Xtno0n4PTDrgJv4FOScSbyJ49cTZG+mgbJnoa1mRm1I3s2yVRylBoJ5PiHcPRPXVrjWhUMBU5G5e0ePRl3fgNkd9qUD6TZ3tWyvjSGtKsxSLJ8ijj0ic06OI0Q4eqtJRx3ESjZALOYqLfGO8PRtc7Ul03yMgnJwlgHtxsab1ex1UJRSFCKl6mE8PE3UIqx211OX1GIIMn6\\\",\\\"ephemeralPublicKey\\\":\\\"BFNPLyTVg9SmjR7p0u5OdXKxKsjB7AXTKN6IhIEKCyBBwUUEdyswU62+iCPcuAAAUVvjNvR/1WNrFatpichAGlk\\\\u003d\\\",\\\"tag\\\":\\\"U5/T1RpIXRCrvDdfQhofxCxXMyfJ4it5mZTa1WihLOI\\\\u003d\\\"}\"}"
},
"holder_name": "Jonh Doe"
}
},
"payer": {
"email": "[email protected]",
"ip": "192.0.2.146",
"person": {
"name": "Mr. Payer Full Name",
"birth_date": "1970-01-01",
"document": {
"type": "CPF",
"number": "98765432101"
},
"phone": {
"country_code": "55",
"number": "44900000000"
}
}
}
}
Reason Codes
If the request fails, the API will return an HTTP status code other than 200. The response body will include an
errors
array with descriptive messages and corresponding error codes.For the full list of possible error codes, see the Reason Codes reference.
Step 3: Processing the API Response
Upon a successful request, the API returns transaction details. Example response:
{
"code": "25a58ef1-3755-476b-b2f6-e445b170a849",
"reference": "REF-XXX-1234567890",
"status": "PENDING",
"amount": 101.1,
"currency": "BRL",
"country": "BR",
"created_at": "2021-04-12T12:43:13Z"
}
Step 4: Handling Transaction Status
The status
field in the response indicates the transaction state. You can monitor status updates using the notification_url
or by querying the transaction status.
Updated 20 days ago