Pix Automático Enrollments with an Instant Payment

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.



There are cases where a one-time purchase and a subscription are purchased at the same checkout - Pix Automático addresses this scenario by merging both transactions into a single one. It is also useful for subscriptions where the first payment is charged immediately, without a free trial period.

Note that these transactions—the instant payment and the enrollment—are executed in a single call. This means that, for example, if the customer does not have sufficient funds for the instant payment and it fails, the enrollment will also fail.

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

tip

Enrollments with instant payments can be applied to either fixed or variable amount setups!

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/direct 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/direct (server-side) as you will request a payment but adding the enrollment data. Check the required fields below:

    ParameterRequirementDescription
    integration_keyRequiredYour integration key
    operationRequiredMust be request

    Instant Payment and Customer Data:

    ParameterRequirementDescription
    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
    expiration_time_in_secondsOptionalPayment and enrollment authorization expires based on the duration specified in this parameter or the default set by EBANX (4 hours). The time must be specified in seconds.
    emailRequiredCustomer e-mail
    nameRequiredCustomer name
    documentRequiredCustomer document

    Subscription 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
    fixed_amountRequiredProvided when recurring payments will have a fixed value. For variable enrollments, use max_amount_floor instead
    start_dateRequiredDay when the payment that initiates the subscription will be charged

    The instant payment will be processed immediately, and the recurrent payment will be set on the start_date.

    Check the example below, of a 19.90 BRL monthly subscription that starts on December 30, with an instant payment of 39.90 BRL requested on December 18:

    curl -X POST 'https://sandbox.ebanxpay.com/ws/direct' \
    --data '{
    "integration_key": "{{integration_key}}",
    "operation": "request",
    "payment": {
    "merchant_payment_code": "{{unique_payment_code}}",
    "amount_total": 39.90,
    "currency_code": "BRL",
    "country": "BR",
    "payment_type_code": "pix-automatico",
    "expiration_time_in_seconds": 3600,
    "email": "{{customer_email}}",
    "name": "{{customer_name}}",
    "document": "{{customer_document}}",
    "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": 19.90,
    "start_date": "2024-12-30"
    }
    }
    }
    }'

    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.

    note

    Both the enrollment and the instant payment are encoded in the same QR Code and are confirmed at the same time.

    {
    "payment": {
    "hash": "676314e588106473c52fb2beaa9dfa3b213f05ca380db7",
    "country": "BR",
    "merchant_payment_code": "{{unique_payment_code}}",
    "order_number": null,
    "status": "PE",
    "status_date": null,
    "open_date": "2024-12-18 18:31:01",
    "confirm_date": null,
    "transfer_date": null,
    "amount_br": "39.90",
    "amount_ext": "39.75",
    "amount_iof": "0.15",
    "amount_ext_requested": "39.90",
    "currency_rate": "1.0000",
    "currency_ext": "BRL",
    "due_date": "2024-12-18",
    "instalments": "1",
    "payment_type_code": "pix-automatico",
    "redirect_url": "https://sandbox.ebanx.com/ws/simulator/confirm?hash=676314e588106473c52fb2beaa9dfa3b213f05ca380db7",
    "pre_approved": false,
    "capture_available": null,
    "customer": {
    "document": "{{customer_document}}",
    "email": "{{customer_email}}",
    "name": "{{customer_name}}",
    "birth_date": "1992-08-15"
    },
    "single_transaction": {
    "amount_local": "0.00",
    "amount_crossborder": "39.90"
    },
    "pix_automatico": {
    "qr_code_value": "00020101021226780014br.gov.bcb.pix2556fake-pix.com.br/qr/v2/ACA4311F88661BC0D48200487EF1BCD95204000053039865802BR5910FAKEPIX Ltda6008CURITIBA62070503***71336"
    }
    },
    "status": "SUCCESS",
    "redirect_url": "https://sandbox.ebanx.com/ws/simulator/confirm?hash=676314e588106473c52fb2beaa9dfa3b213f05ca380db7"
    }
  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. Additionally, you'll have a pending payment, which will also be notified separately, upon confirmation.

  4. Confirming the Enrollment and Instant Payment

    Your title

    As soon as the enrollment is confirmed by the customer in their banking app, the enrollment status is modified from pending 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": 19.90,
    "max_amount_floor": null,
    "retry": "allow_3R_7D"
    }
    }

    Additionaly, the payment status of the payment created in step 2 is modified from PE to CO and a Status Update notification is sent.

    Using the hash provided in the 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}}",
    "merchant_enrollment_code": "{{unique_enrollment_code}}",
    "status": "CO",
    "status_date": "2024-12-18 14:00:00",
    "open_date": "2024-12-18 13:00:00",
    "confirm_date": "2024-12-18 14:00:00",
    "transfer_date": null,
    "amount_br": "39.90",
    "amount_ext": "39.90",
    "amount_iof": "0.00",
    "currency_rate": "1.0000",
    "currency_ext": "BRL",
    "due_date": null,
    "payment_type_code": "pix-automatico",
    "pre_approved": false
    },
    "status": "SUCCESS"
    }
    Important!

    Pending enrollments expire based on the duration in expiration_time_in_seconds specified on your request or the default set by EBANX (4 hours). If your customers don't complete the payment and enrollment in time, both 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 next billing day. For example, if a payment is due on December 30th, the payment request must be sent no earlier than December 20th and no later than December 28th.

    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": "30/12/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-12-30",
    "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-12-30 03:00:00",
    "open_date": "2024-12-25 13:00:00",
    "confirm_date": "2024-12-30 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-12-30",
    "instalments": "1",
    "payment_type_code": "pix-automatico",
    "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