Pix Automático Variable Enrollments

Overview

Pix Automático works by establishing an authorization, achieved through an enrollment process, between merchant and customer, and referencing it in every recurring payment. This way, the customer's bank can validate the payment against the enrollment and transfer funds without the need for customer interaction, given that they know the payment request has been validated and comes from a valid source.



A more versitile form of Pix Automático enrollments are variable subscriptions, where the merchant and customer agree on a value range that the recurring payment can vary. Typically, this is used in consumption based subscription models, but can also be used to adjust prices over time, to compensate for variations like inflation, FX or interest rates.

By following this basic integration guide, you will understand how you can create enrollments and accept Pix Automático recurring payments in your check-out, by using EBANX Direct API. To complete a payment with Pix Automático you will need a few API calls that will create an enrollment for your customer, the recurring payment and provide the necessary information for the customer to complete the transaction.

Availability

Pix Automático integration through Direct API will be available in Brazil only.

What you will need

A Sandbox Account

As with any secure payment integration, you will first need to set up authorization. The EBANX sandbox allows you to set up a test environment to run transactions using test credit card numbers and explore our payment solutions.

Sign up for an Sandbox Account at our EBANX Business Page, select your business model and answer a few questions. We'll get in touch with you shortly after!

Sign up for an EBANX Sandbox Account here

How it works

To complete a Pix Automático enrollment and recurring payments, please follow the steps below.

  1. Enable Pix Automático in your dashboard

    The first step is to check if Pix Automático is active in your EBANX Dashboard.

    All set? We can go ahead to next step, otherwise, please get in touch with our integration specialists.

  2. Call the /ws/userenrollment API to get the Enrollment QR Code

    Your title

    Pix Automático generates a QR Code, which is scanned by the user in their banking app of choice. To get this, you just need to call the end-point ws/userenrollment (server-side) with the following fields:

    ParameterRequirementDescription
    integration_keyRequiredYour integration key
    payment_type_codeRequiredMust be pix-automatico
    operationRequiredMust be enrollment

    Enrollment data:

    ParameterRequirementDescription
    countryRequiredMust be BR
    emailRequiredCustomer e-mail
    nameRequiredCustomer name
    documentRequiredCustomer document
    merchant_enrollment_codeRequiredUnique enrollment code
    subscription_nameRequiredDescriptor of the service being provided, which will be displayed in the customer's banking app
    expiration_dateOptionalIf necessary, defines when the enrollment is no longer valid and no further payments will be charged
    frequencyRequiredThe billing cycle of the enrollment.
    Available frequencies are: weekly,monthly, quarterly,semi-annual,annual
    retryRequiredDetermines whether the merchant will retry payments that fail on the expect billing day.
    The available retry policies are: not_allowed for no additional attempts or allow_3R_7D for up to three retries within seven days after the first payment
    max_amount_floorOptionalProvided when recurring payments have a variable value - the maximum value will be set by the customer in their bank app, but can't be lower than this value. For fixed enrollments, use fixed_amount instead
    start_dateRequiredDay when the payment that initiates the subscription will be charged

    Check the example:

    curl POST 'https://sandbox.ebanxpay.com/ws/userenrollment/' \
    --header 'Content-Type: application/json' \
    --data '{
    {
    "integration_key": "{{integration_key}}",
    "payment_type_code": "pix-automatico",
    "operation": "enrollment",
    "enrollment": {
    "country": "BR",
    "email": "{{customer_email}}",
    "name": "{{customer_name}}",
    "document": "{{customer_document}}",
    "merchant_enrollment_code": "{{unique_enrollment_code}}",
    "subscription": {
    "subscription_name": "Descriptor of the subscription.",
    "expiration_date": "2025-12-30",
    "frequency": "monthly",
    "retry": "allow_3R_7D",
    "fixed_amount": null,
    "max_amount_floor": 100,
    "start_date": "2024-12-15"
    }
    }
    }'

    A successful request will return a JSON response like the one below. The Pix Automático raw QR Code value will be in the parameter qr_code_value.

    You can also use the redirect_url to redirect your customer to an external page to display the Pix Automatico voucher and QR code. In Sandbox environment, you will find in the redirect_url the link to use our Simulator.

    {
    "status": "SUCCESS",
    "redirect_url": "https://sandbox.ebanx.com/ewallet/recurrency-agreement?return_url=https%3A%2F%2Fsandbox.ebanx.com%2Fws%2Fcustomerenrollment-finish%2Ffake%3Fenrollment%3DMTYwOTA6bXktZW5yb2xsbWVudC0zMzA%253D&enrollment_uuid=PpKBQFh3wwa4agh9e",
    "enrollment": {
    "merchant_enrollment_code": "{{unique_enrollment_code}}",
    "country": "BR",
    "name": "{{customer_name}}",
    "email": "{{customer_email}}",
    "subscription": {
    "frequency": "monthly",
    "expiration_date": "2025-12-30",
    "subscription_name": "Descriptor of the subscription.",
    "start_date": {
    "date": "2024-12-15",
    "timezone_type": 3,
    "timezone": "UTC"
    },
    "retry": "allow_3R_7D",
    "max_amount_floor": "100.00",
    "qr_code_value": "00020101021226780014br.gov.bcb.pix2556fake-pix.com.br/qr/v2/ACA4311F88661BC0D48200487EF1BCD95204000053039865802BR5910FAKEPIX Ltda6008CURITIBA62070503***36923"
    }
    }
    }
  3. Presenting the Pix QR Code

    You can present the QR code by rendering the code at your page.


    Copying QR Code to Clipboard

    Alternatively, you can simply deliver the QR Code number from qr_code_value to your customer's clipboard so they can paste it into their banking/wallet app.

    At this point you have a pending enrollment and will be notified via webhook when there is a status change.

  4. Confirming the Enrollment

    Your title

    As soon as the enrollment is confirmed by the customer in their banking app, the enrollment status is modified from peding to accepted and a Status Update notification is sent to the URL defined in your merchant configuration.

    {
    "operation":"enrollment_status_change",
    "notification_type":"update",
    "merchant_enrollment_code":"{{unique_enrollment_code}}"
    }

    Using the ID provided in merchant_enrollment_code, use the ws/userenrollment/query endpoint to get the latest status of the enrollment.

    Check the example:

    curl POST 'https://sandbox.ebanxpay.com/ws/userenrollment/query' \
    --header 'Content-Type: application/json' \
    --data '{
    "integration_key": "{{integration_key}}",
    "enrollment": {
    "merchant_enrollment_code": "{{unique_enrollment_code}}"
    }
    }'

    A successful request will return a JSON response like the one below, with a status of accepted for the enrollment approved by the customer. Other possible enrollment statuses include not accepted, pending, expired, not_found and revoked, depending on the actions taken by the merchant or customer.

    {
    "status": "SUCCESS",
    "enrollment": {
    "status": "accepted",
    "email": "{{customer_email}}"
    },
    "subscription": {
    "subscription_name": "Descriptor of the subscription.",
    "expiration_date": "2025-12-30",
    "frequency": "monthly",
    "fixed_amount": null,
    "max_amount_floor": 100.00,
    "retry": "allow_3R_7D"
    }
    }
    Important!

    Pending enrollments expire 2 days before the first payment date (start_date). If your customers don't complete the enrollment in time, the enrollment will be automatically canceled.

  5. Call the /ws/direct API to schedule the Pix Automático payment

    Very Important!

    The recurring payment request must be sent between 2 and 10 days before the expected billing day. For example, if a payment is due on January 17th, the payment request must be sent no earlier than January 7th and no later than January 15th.

    Your title

    Scheduling a recurring payment with Pix Automático is really straightforward. The following fields are required:

    ParameterRequirementDescription
    operationRequiredMust be request
    merchant_payment_codeRequiredUnique merchant payment code
    amount_totalRequiredTotal amount to be charged. Note that the amount must match the one set in the enrollment
    currency_codeRequiredMust be BRL
    countryRequiredMust be BR
    payment_type_codeRequiredMust be pix-automatico
    emailRequiredCustomer e-mail
    nameRequiredCustomer name
    documentRequiredCustomer document
    due_dateRequiredExpected billing date (DD/MM/YYYY) - it must be between 2 and 10 days after the current date
    merchant_enrollment_codeRequiredThe enrollment code generated in the previous steps. The enrollment must have a accepted status to be used in recurring payments

    Check the example:

    curl -X POST 'https://sandbox.ebanxpay.com/ws/direct' \
    --data '{
    "integration_key": "{{integration_key}}",
    "operation": "request",
    "payment": {
    "merchant_payment_code": {{merchant_payment_code}},
    "amount_total": 19.90,
    "currency_code": "BRL",
    "country": "BR",
    "payment_type_code": "pix-automatico",
    "email": "{{customer_email}}",
    "name": "{{customer_name}}",
    "document": "{{customer_document}}",
    "due_date": "17/01/2024",
    "enrollment": {
    "merchant_enrollment_code": "{{merchant_enrollment_code}}"
    }
    }
    }'

    A successful request will return a JSON response like the one below. The Pix Automático payment will have a pending (PE) status and will be confirmed later, by the customer's bank.

    {
    "payment": {
    "hash": "{{unique_payment_hash}}",
    "country": "BR",
    "merchant_payment_code": "{{unique_payment_code}}",
    "merchant_enrollment_code": "{{unique_enrollment_code}}",
    "status": "PE",
    "status_date": null,
    "open_date": "2024-01-10 13:00:00",
    "confirm_date": null,
    "transfer_date": null,
    "amount_br": "19.90",
    "amount_ext": "19.90",
    "amount_iof": "0.00",
    "currency_rate": "1.0000",
    "currency_ext": "BRL",
    "due_date": "2024-01-17",
    "payment_type_code": "pix-automatico",
    "pre_approved": false
    },
    "status": "SUCCESS",
    "redirect_url": "https://sandbox.ebanx.com/ws/redirect/execute?hash=6762e422391626568b710810924fdaea7401f4f5bb4881"
    }
    note

    In the Sandbox environment, the redirect_url in the response of your payment schedule will lead you to the payment Simulator, allowing you to reproduce multiple payment processing scenarios.

  6. Confirming the Payment

    Your title

    As soon as the payment is confirmed by the customer's bank, the payment status is modified from PE to CO and a Status Update notification is sent.

    {
    "operation":"payment_status_change",
    "notification_type":"update",
    "merchant_payment_code":"{{unique_payment_code}}"
    }

    Using the hash provided in the payment response, use the ws/query endpoint to get the latest status of the payment.

    Check the example:

    curl POST 'https://sandbox.ebanxpay.com/ws/query' \
    --header 'Content-Type: application/json' \
    --data '{
    "integration_key": "{{integration_key}}",
    "hash": "{{unique_payment_hash}}"
    }'

    A successful request will return a JSON response like the one below, with a status of CO for the successful recurring payment.

    {
    "payment": {
    "hash": "{{unique_payment_hash}}",
    "country": "BR",
    "merchant_payment_code": "{{unique_payment_code}}",
    "status": "CO",
    "status_date": "2024-01-17 03:00:00",
    "open_date": "2024-01-10 13:00:00",
    "confirm_date": "2024-01-17 03:00:00",
    "transfer_date": null,
    "amount_br": "19.90",
    "amount_ext": "19.90",
    "amount_iof": "0.00",
    "amount_ext_requested": "0.00",
    "currency_rate": "1.0000",
    "currency_ext": "BRL",
    "due_date": "2024-01-17",
    "instalments": "1",
    "payment_type_code": "pix-automatico",
    "redirect_url": "00020101021226740014br.gov.bcb.pix2552pix.ebanx.com\/qr\/v2\/F2D9448AA5B94ED3450A4A8933748F5952040000556345643602BR5911EbanxLTDA.6008CURITIBA62070503***63045022",
    "pre_approved": false,
    "capture_available": null,
    "customer": {
    "document": "{{customer_document}}",
    "email": "{{customer_email}}",
    "name": "{{customer_name}}",
    "birth_date": "1992-08-15",
    "address": "",
    "street_number": "",
    "street_complement": "",
    "city": "",
    "state": "",
    "zipcode": "",
    "country": "BR",
    "phone_number": ""
    },
    "single_transaction": {
    "amount_local": "0.00",
    "amount_crossborder": "19.90"
    },
    "enrollment": {
    "merchant_enrollment_code": "{{merchant_enrollment_code}}"
    }
    }
    }

    Now, for each new billing cycle, simply repeat 5 and 6!

note

Pix Automático will go live on June 16, 2025. In the meantime, you can use our Sandbox environment, available since December 1, 2024!

Still need help?

Help Image

We hope this article was helpful. If you still have questions, you can explore the following options:

Last updated on by Sarah Nicolau