### Request Access Token - Shell Example Source: https://docs.cielo.com.br/ecommerce-cielo/docs/integrando-com-o-sop This snippet demonstrates how to make a POST request to the Cielo E-commerce API to obtain an access token. It includes the necessary endpoint, headers for content type, merchant ID, and authorization, along with verbose output for debugging. ```shell --request POST "https://transactionsandbox.pagador.com.br/post/api/public/v2/accesstoken" --header "Content-Type: application/json" --header "MerchantId: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" --header "Authorization: Bearer faSYkjfiod8ddJxFTU3vti_ ... _xD0i0jqcw" --data-binary --verbose ``` -------------------------------- ### Card On File Usage Example (JSON) Source: https://docs.cielo.com.br/ecommerce-cielo/docs/card-on-file-1 Example JSON structure for the CardOnFile node, specifying its usage ('First' or 'Used') and reason ('Recurring' or 'Subscription'). This is crucial for differentiating initial stored card transactions from subsequent ones. ```json { "CardOnFile":{ "Usage": "Used", "Reason":"Recurring" } } ``` -------------------------------- ### Implementing Events Source: https://docs.cielo.com.br/ecommerce-cielo/docs/integrando-com-o-sop Information about the events that can be implemented to handle script outcomes. ```APIDOC ## Implementing Events ### Description Details the three events provided by the Cielo script for handling transaction outcomes. ### Events - **onSuccess**: Event for successful transactions. Returns the `PaymentToken` and card data if card verification was requested. The `PaymentToken` is single-use and invalidated after processing. - **onError**: Event for transaction errors. Returns the error code and description. - **onInvalid**: Event for invalid data input. Returns details about fields with errors. Error messages are available in Portuguese (default), English, and Spanish. ``` -------------------------------- ### ABU Response Example - JSON Source: https://docs.cielo.com.br/ecommerce-cielo/docs/automatic-billing-updater-abu Example of a recurring credit transaction response with 'CardBrandStatus' and 'NewCard' fields. This JSON structure indicates the status of the card and provides updated card details if available. ```json { "Payment":{ "CardBrandStatus":"VALID", "NewCard": { "CardNumber": "40000000000000000", "ExpirationDate": "10/2032", "SaveCard": true, "Brand": "Master" } } } ``` -------------------------------- ### Authorizing with PaymentToken Source: https://docs.cielo.com.br/ecommerce-cielo/docs/integrando-com-o-sop Instructions on how to use a PaymentToken for payment authorization via the Cielo E-commerce API. ```APIDOC ## Authorizing with PaymentToken ### Description Guides on how to perform payment authorization using a `PaymentToken` obtained from the Cielo script, replacing card details with the token. ### Credit Card Authorization - To submit a credit transaction, send the parameter `Payment.CreditCard.PaymentToken` instead of `Payment.CreditCard`. - Learn more in the API Cielo E-commerce manual. ### Debit Card Authorization - To submit a debit transaction, send the parameter `Payment.DebitCard.PaymentToken` instead of `Payment.DebitCard`. - Learn more in the API Cielo E-commerce manual. ### Request Example (Conceptual) ```json { "Payment": { "CreditCard": { "PaymentToken": "YOUR_PAYMENT_TOKEN_HERE" } } } ``` ### Response Example (Conceptual Success) ```json { "status": "authorized", "paymentId": "some-payment-id" } ``` ``` -------------------------------- ### Payment Tokenization Source: https://docs.cielo.com.br/ecommerce-cielo/docs/integrando-com-o-sop Details on how card tokenization works and its impact on the token returned by the script. ```APIDOC ## Payment Tokenization ### Description Explains the behavior of the `CardToken` and `PaymentToken` based on the `enableTokenize` script parameter. ### Parameters #### Script Parameters - **enableTokenize** (boolean) - If set to `true`, the script will return a `CardToken` instead of a `PaymentToken`. ### Additional Information - Learn more about `CardToken` at: https://docs.cielo.com.br/ecommerce-cielo/docs/tokenizando-cartoes - `PaymentToken` can be used for a single authorization and/or within a 20-minute period. After processing, it will be invalidated. ``` -------------------------------- ### POST /v2/accesstoken - Obtain SOP Access Token Source: https://docs.cielo.com.br/ecommerce-cielo/docs/integrando-com-o-sop Create the Silent Order Post (SOP) AccessToken by sending a POST request. This token is used in the subsequent script execution. ```APIDOC ## POST /v2/accesstoken - Obtain SOP Access Token ### Description Create the Silent Order Post (SOP) AccessToken by sending a POST request. This token is used in the subsequent script execution. ### Method POST ### Endpoint - Sandbox: `https://transactionsandbox.pagador.com.br/post/api/public/v2/accesstoken` - Production: `https://transaction.pagador.com.br/post/api/public/v2/accesstoken` ### Parameters #### Headers - **Authorization** (string) - Required - `"Bearer {access_token}"` where `{access_token}` is the OAuth2 token obtained from the previous step. ### Request Example ```shell POST https://transactionsandbox.pagador.com.br/post/api/public/v2/accesstoken Authorization: Bearer {access_token} ``` ### Response *The response structure for this endpoint is not provided in the input text.* ``` -------------------------------- ### Access Token Response JSON Example Source: https://docs.cielo.com.br/ecommerce-cielo/docs/integrando-com-o-sop This JSON structure represents a successful response from the Cielo E-commerce API when requesting an access token. It includes the Merchant ID, the generated Access Token, and the issuance and expiration times for the token. ```json { "MerchantId": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "AccessToken": "MzA5YWIxNmQtYWIzZi00YmM2LWEwN2QtYTg2OTZjZjQxN2NkMDIzODk5MjI3Mg==", "Issued": "2023-08-05T08:50:04", "ExpiresIn": "2023-08-05T09:10:04" } ``` -------------------------------- ### Cielo Script JSON Return Example Source: https://docs.cielo.com.br/ecommerce-cielo/docs/integrando-com-o-sop This JSON object represents the typical return structure from the Cielo e-commerce script. It includes a `PaymentToken` for authorization and detailed card information such as brand, last four digits, and issuer, particularly when BIN query is enabled. ```json { "PaymentToken": "366f8470-54d0-43cb-95f5-c80a502afc27", "ForeignCard": false, "BinQueryReturnCode": "00", "BinQueryReturnMessage": "Analise autorizada", "Brand": "Visa", "VerifyCardStatus": 1, "VerifyCardReturnCode": "00", "VerifyCardReturnMessage": "Transacao autorizada", "CardBin": "453202", "CardLast4Digits": "4044", "CardType": "Multiple", "Issuer": "Banco Santander", "IssuerCode": "033", "Prepaid": false } ``` -------------------------------- ### Exemplo de Implementação de Script de Autenticação em HTML Source: https://docs.cielo.com.br/ecommerce-cielo/docs/implementando-script Este snippet demonstra a estrutura básica de um arquivo HTML para implementar um script de autenticação. Inclui campos ocultos para configuração de autenticação, detalhes do pedido, informações de pagamento com cartão e opções de recorrência. A função `sendOrder` é responsável por iniciar o processo de autenticação chamando `bpmpi_authenticate`. ```html