To save a credit card during transaction authorization, send the parameter Payment.SaveCard as "true" in the standard credit card request.
- Cards are saved in a tokenized format, and you must contract the tokenization service with Cielo.
- The card number must be valid according to the Luhn algorithm (mod10).
Request
| Environment | Method | Endpoint |
|---|---|---|
| Sandbox | post | https://apisandbox.braspag.com.br/v2/sales/ |
| Production | post | https://api.braspag.com.br/v2/sales/ |
{
"MerchantOrderId":"2017051001",
"Customer":{
"Name":"Nome do Comprador",
"Identity":"12345678909",
"IdentityType":"CPF",
"Email":"[email protected]",
"Birthdate":"1991-01-02",
"IpAddress":"127.0.0.1",
"Address":{
"Street":"Alameda Xingu",
"Number":"512",
"Complement":"27 andar",
"ZipCode":"12345987",
"City":"São Paulo",
"State":"SP",
"Country":"BRA",
"District":"Alphaville"
},
"DeliveryAddress":{
"Street":"Alameda Xingu",
"Number":"512",
"Complement":"27 andar",
"ZipCode":"12345987",
"City":"São Paulo",
"State":"SP",
"Country":"BRA",
"District":"Alphaville"
}
},
"Payment":{
"Provider":"Simulado",
"Type":"CreditCard",
"Amount":10000,
"Currency":"BRL",
"Country":"BRA",
"Installments":1,
"Interest":"ByMerchant",
"Capture":true,
"Authenticate":false,
"Recurrent":false,
"SoftDescriptor":"Mensagem",
"CreditCard":{
"CardNumber":"4551870000000181",
"Holder":"Nome do Portador",
"ExpirationDate":"12/2021",
"SecurityCode":"123",
"Brand":"Visa",
"SaveCard":true,
"Alias":"",
}
}
}--request POST "https://apisandbox.braspag.com.br/v2/sales/"
--header "Content-Type: application/json"
--header "MerchantId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
--header "MerchantKey: 0123456789012345678901234567890123456789"
--header "RequestId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
--data-binary
{
"MerchantOrderId":"2017051001",
"Customer":{
"Name":"Nome do Comprador",
"Identity":"12345678909",
"IdentityType":"CPF",
"Email":"[email protected]",
"Birthdate":"1991-01-02",
"IpAddress":"127.0.0.1",
"Address":{
"Street":"Alameda Xingu",
"Number":"512",
"Complement":"27 andar",
"ZipCode":"12345987",
"City":"São Paulo",
"State":"SP",
"Country":"BRA",
"District":"Alphaville"
},
"DeliveryAddress":{
"Street":"Alameda Xingu",
"Number":"512",
"Complement":"27 andar",
"ZipCode":"12345987",
"City":"São Paulo",
"State":"SP",
"Country":"BRA",
"District":"Alphaville"
}
},
"Payment":{
"Provider":"Simulado",
"Type":"CreditCard",
"Amount":10000,
"Currency":"BRL",
"Country":"BRA",
"Installments":1,
"Interest":"ByMerchant",
"Capture":true,
"Authenticate":false,
"Recurrent":false,
"SoftDescriptor":"Mensagem",
"CreditCard":{
"CardNumber":"4551870000000181",
"Holder":"Nome do Portador",
"ExpirationDate":"12/2021",
"SecurityCode":"123",
"Brand":"Visa",
"SaveCard":true,
"Alias":"",
}
}
}
--verbose| Property | Description | Type | Size | Required |
|---|---|---|---|---|
Payment.Provider | Name of the payment provider. | Text | 15 | Yes |
Payment.Type | Type of the payment method. | Text | 100 | Yes |
Payment.Amount | Order amount in cents. | Number | 15 | Yes |
Payment.Installments | Number of installments. | Number | 2 | Yes |
CreditCard.CardNumber | Shopper's card number. | Text | 16 | Yes |
CreditCard.Holder | Shopper's name printed on the card. Note: Field length rules may vary by acquirer. | Text | 25 | Yes |
CreditCard.ExpirationDate | Expiration date printed on the card, in MM/YYYY format. | Text | 7 | Yes |
CreditCard.SecurityCode | Security code printed on the back of the card. | Text | 4 | Yes |
CreditCard.Brand | Card brand. | Text | 10 | Yes |
CreditCard.SaveCard | "true" – to save the card. / "false" – to not save the card. | Boolean | 10 | No (default "false") |
CreditCard.Alias | Alias (nickname) for the credit card. | Text | 64 | No |
Response
The CreditCard.CardToken parameter will return the token to be saved for future transactions with the same card.
{
[...]
},
"Payment": {
"ServiceTaxAmount": 0,
"Installments": 1,
"Interest": "ByMerchant",
"Capture": true,
"Authenticate": false,
"Recurrent": false,
"CreditCard": {
"CardNumber": "455187******0181",
"Holder": "Nome do Portador",
"ExpirationDate": "12/2021",
"SaveCard": true,
"CardToken": "250e7c7c-5501-4a7c-aa42-a33d7ad61167",
"Brand": "Visa",
"Alias": "Cliente1"
},
"ProofOfSale": "3519928",
"AcquirerTransactionId": "0511023519928",
"AuthorizationCode": "536934",
"PaymentId": "3af00b2d-dbd0-42d6-a669-d4937f0881da",
"Type": "CreditCard",
"Amount": 10000,
"ReceivedDate": "2017-05-11 14:35:19",
"Currency": "BRL",
"Country": "BRA",
"Provider": "Simulado",
"ReasonCode": 0,
"ReasonMessage": "Successful",
"Status": 1,
"ProviderReturnCode": "4",
"ProviderReturnMessage": "Operation Successful",
[...]
}
}--request POST "https://apisandbox.braspag.com.br/v2/sales/"
--header "Content-Type: application/json"
--header "MerchantId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
--header "MerchantKey: 0123456789012345678901234567890123456789"
--header "RequestId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
--data-binary
{
[...]
},
"Payment": {
"ServiceTaxAmount": 0,
"Installments": 1,
"Interest": "ByMerchant",
"Capture": true,
"Authenticate": false,
"Recurrent": false,
"CreditCard": {
"CardNumber": "455187******0181",
"Holder": "Nome do Portador",
"ExpirationDate": "12/2021",
"SaveCard": true,
"CardToken": "250e7c7c-5501-4a7c-aa42-a33d7ad61167",
"Brand": "Visa",
"Alias": "Cliente1"
},
"ProofOfSale": "3519928",
"AcquirerTransactionId": "0511023519928",
"AuthorizationCode": "536934",
"PaymentId": "3af00b2d-dbd0-42d6-a669-d4937f0881da",
"Type": "CreditCard",
"Amount": 10000,
"ReceivedDate": "2017-05-11 14:35:19",
"Currency": "BRL",
"Country": "BRA",
"Provider": "Simulado",
"ReasonCode": 0,
"ReasonMessage": "Successful",
"Status": 1,
"ProviderReturnCode": "4",
"ProviderReturnMessage": "Operation Successful",
[...]
}
}
--verbose| Property | Description | Type | Size | Format |
|---|---|---|---|---|
AcquirerTransactionId | Transaction ID at the payment provider. | Text | 40 | Alphanumeric text |
ProofOfSale | Sales receipt number. | Text | 20 | Alphanumeric text |
AuthorizationCode | Authorization code. | Text | 300 | Alphanumeric text |
PaymentId | Order identifier field. | GUID | 36 | xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx |
ReceivedDate | Date when the transaction was received by Split. | Text | 19 | YYYY-MM-DD HH:mm:SS |
ReasonCode | Operation return code. | Text | 32 | Alphanumeric text |
ReasonMessage | Operation return message. | Text | 512 | Alphanumeric text |
Status | Transaction status. | Byte | 2 | Example: 1 |
ProviderReturnCode | Code returned by the payment provider (acquirer or issuer). | Text | 32 | 57 |
ProviderReturnMessage | Message returned by the payment provider (acquirer or issuer). | Text | 512 | Transaction Approved |
CreditCard.CardToken | Token in Cartão Protegido representing the card data. | GUID | 36 | xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx |