Skip to main content

Nupay Recurring allows merchants to set up and manage recurring payments through the EBANX API. This feature ensures that customers authorize merchants to process recurring payments without requiring repeated manual approvals. Whether for subscriptions or one-click payments, Nupay Recurring simplifies the payment experience while providing robust authorization workflows.

Requirements​

How it works​

  • Enrollment - Customers authorize recurring payments through an app-to-app or web-to-app flow. This step ensures that merchants can process future transactions seamlessly. The enrollment process has two different user experiences depending on where the customer is coming from:
    • App-to-App: Ideal for purchases made within your mobile application. The customer is redirected from your app to the Nubank app to grant authorization and then returns.
    • Web-to-App: Ideal for purchases made on a website (desktop or mobile). The customer receives a push notification on their phone to approve the authorization in the Nubank app.
  • First payment - Customers authorize the initial payment via the NuPay platform, choosing a payment source (credit or debit).
  • Subsequent payments - Once enrolled, future payments occur automatically using the merchant_enrollment_code, without requiring additional customer action.
  • Notifications - EBANX notifies merchants of payment status updates via webhooks.

Instructions​

Follow the steps below.

  1. Select your environment
    ​

    Select the appropriate environment for your integration. Use the sandbox environment for testing, or the production environment for live transactions. Use the URL for your HTTP requests based on your selection.

    Check the method's availability for your country and tenant in Payment Methods by Country. Questions about tenant and environment? Check our API Operability and API Endpoints.

    Cross-border sandbox
    https://sandbox.ebanxpay.com/ws/userenrollment/nupay
  2. Define your parameters
    ​

    You must enroll the customer in Nupay Recurring using the /ws/userenrollment/nupay endpoint.

    You can send both parameters (email and phone_number), or just one of them.

    ParameterDescription
    integration_keyYour EBANX integration key.Required
    operationSet to enrollment.Required
    payment_type_codeSet to nupay-recurrent.Required
    enrollment.merchant_enrollment_codeUnique ID for the recurring payment.Required
    enrollment.emailCustomer email.
    Required , if no phone_number.
    Required
    enrollment.phone_numberCustomer phone number.
    Required , if no email.
    Required
    enrollment.countryCustomer country code ( e.g., br ).Required
    enrollment.back_urls.successWhen the customer accepts the enrollment, they will be redirected to this URL. The merchant can determine the outcome of the enrollment process by detecting the customer's arrival at this URL.Required for App-to-app flow
    enrollment.back_urls.failureWhen the customer denies the enrollment, they will be redirected to this URL. The merchant can determine the outcome of the enrollment process by detecting the customer's arrival at this URL.Required for App-to-app flow
    enrollment.documentCustomer's document (CPF).
    Required for Web-to-app flow
    enrollment.identification_typeMust be cpf.
    Optional
  3. Enrollment request
    ​

    The enrollment step is essential for registering customers for automatic payments. This process is handled through the /ws/userenrollment/nupay endpoint.

    Shell
    curl -X POST \
    --location 'https://sandbox.ebanxpay.com/ws/userenrollment/nupay' \
    --header 'Content-Type: application/json' \
    --data '{
    "integration_key": "{{integration_key}}",
    "operation": "enrollment",
    "payment_type_code": "nupay-recurrent",
    "enrollment": {
    "merchant_enrollment_code": "{{unique_enrollment_code}}",
    "phone_number": "5555555555",
    "email": "john.doe@example.com",
    "country": "br",
    "back_urls": {
    "success": "https://your-success-url.com",
    "failure": "https://your-failure-url.com"
    }
    }
    }'
  4. Enrollment response
    ​

    The response to this call will indicate the status of the operation.

    JSON
    {
    "redirect_url": "{{redirect_url}}",
    "status": "SUCCESS",
    "enrollment": {
    "merchant_enrollment_code": "{{unique_enrollment_code}}",
    "phone_number": "5555555555",
    "email": "john.doe@example.com",
    "country": "br",
    "back_urls": {
    "success": "https://your-success-url.com",
    "failure": "https://your-failure-url.com"
    }
    }
    }

    Sandbox Behavior - When working in a sandbox environment, the redirect_url will lead to a sandbox interface where you can simulate customer acceptance or cancellation of the enrollment agreement.

    See example below.


  5. Enrollment status check
    ​

    To confirm customer enrollment status, send a request to the /ws/userenrollments/query endpoint.

    Use the following parameters when preparing your request.

    ParameterDescriptionRequired
    integration_keyYour EBANX integration key.Required
    operationSet to enrollment.Required
    payment_type_codeSet to nupay-recurrent.Required
    enrollment.merchant_enrollment_codeUnique ID for the recurring payment.Required
    enrollment.countryCustomer’s country code (e.g., br).Required

    Sample request:

    Shell
    curl -X POST \
    --location 'https://sandbox.ebanxpay.com/ws/userenrollments/query' \
    --header 'Content-Type: application/json' \
    --data '{
    "integration_key": "your_ebanx_integration_key",
    "operation": "enrollment",
    "payment_type_code": "nupay-recurrent",
    "enrollment": {
    "merchant_enrollment_code": "d057c598",
    "country": "br"
    }
    }'

    Sample response:

    JSON
    {
    "status": "SUCCESS",
    "enrollment": {
    "status": "accepted"
    }
    }
  6. Payment request
    ​

    After the customer is successfully enrolled, call the ws/direct endpoint with the required parameters.

    ParameterDescriptionRequired
    integration_keyYour EBANX integration key.Required
    payment.nameCustomer’s full name.Required
    payment.emailCustomer’s email.Required
    payment.documentCustomer’s document (CPF).Required
    payment.countryCustomer’s country code (e.g., br).Required
    payment.phone_numberCustomer’s phone number.Required
    payment_type_codeSet to nupay-recurrent.Required
    payment.merchant_payment_codeUnique ID for the transaction.Required
    payment.currency_codeSet to BRL or USD.Required
    payment.amount_totalTotal payment amount.Required
    payment.metadata.merchant_enrollment_codeThe unique identifier associated with the recurrence, obtained in the enrollment step.Required
    payment.metadata.funding_sourceThe source of funds for the payment. Can be debit or credit.Required
    payment.metadata.installmentsNumber of installments. Only applicable when funding_source is credit.Optional
    Installments Plan

    Use the /ws/instalmentsPlan endpoint to retrieve the available installment plans and amounts before submitting the payment request. When calling this endpoint for NuPay Recurring, the document and payment_type fields are required.


    Sample request:

    Shell
    curl -X POST \
    --location 'https://sandbox.ebanxpay.com/ws/direct' \
    --header 'Content-Type: application/json' \
    --data '{
    "integration_key": "{{integration_key}}",
    "payment": {
    "name": "John Doe",
    "email": "john.doe@example.com",
    "document": "{{tax_id}}",
    "country": "br",
    "phone_number": "5555555555",
    "payment_type_code": "nupay-recurrent",
    "merchant_payment_code": "{{merchant_payment_code}}",
    "currency_code": "BRL",
    "amount_total": 99.85,
    "metadata": {
    "merchant_enrollment_code": "{{unique_enrollment_code}}",
    "funding_source": "credit"
    }
    }
    }'
  7. Payment response
    ​

    The response of this call will have no redirection. Immediate responses will have either a Completed (CO) or Canceled (CA) status, while a Pending (PE) status means the payment is still being processed by NuPay.

    Response:

    JSON
    {
    "payment": {
    "hash": "59acc5f00945fa382ab051651440826da7701533249b3a475",
    "country": "br",
    "merchant_payment_code": "{{merchant_payment_code}}",
    "order_number": null,
    "status": "PE",
    "status_date": "{{YYYY-MM-DD HH:mm:ss}}",
    "open_date": "{{YYYY-MM-DD HH:mm:ss}}",
    "confirm_date": null,
    "transfer_date": null,
    "amount_br": "99.85",
    "amount_ext": "99.85",
    "amount_ext_requested": "99.85",
    "amount_iof": "0.00",
    "currency_rate": "1.0000",
    "currency_ext": "BRL",
    "due_date": "{{YYYY-MM-DD HH:mm:ss}}",
    "instalments": "1",
    "payment_type_code": "nupay-recurrent",
    "redirect_url": "https://acquirer.redirect.example.com",
    "pre_approved": false,
    "capture_available": null,
    "currency_ext_base": "BRL",
    "type": "",
    "transaction_status": {
    "acquirer": "EBANX",
    "code": "OK",
    "description": "Payment successfully paid",
    "description_code": "ACCEPTED"
    }
    },
    "status": "SUCCESS"
    }
  8. Monitor payment for status changes
    ​

    Notifications

    • Once the payment is confirmed, EBANX will send a notification to the notification_url sent with your payment request, or the one stored in your Merchant Area.

    • Make sure your system is set up to receive notifications from EBANX for any changes in payment status.

    Status

    • After receiving a notification that status has changed, retrieve the payment status.

    • When a payment is confirmed, the status will change from pending (PE) to confirmed (CO). If the customer does not complete the payment, the status will eventually change to cancelled (CA).

  9. Congratulations!
    ​

    You have successfully integrated Nupay Recurring.

    For more information, refer to the
    Direct API reference guidechevron_right

Cancel an existing enrollment​

Enrollments can be cancelled by sending a POST request to the /ws/userenrollment/nupay/cancel endpoint.

  1. Sample request
    ​

    See example request below.

    Shell
    curl -X POST \
    --location 'https://sandbox.ebanxpay.com/ws/userenrollment/nupay/cancel' \
    --header 'Content-Type: application/json' \
    --data '{
    "integration_key": "{{integration_key}}",
    "operation": "cancel",
    "payment_type_code": "nupay-recurrent",
    "enrollment": {
    "merchant_enrollment_code": "{{unique_enrollment_code}}",
    "email": "john.doe@example.com",
    "country": "br",
    "back_urls": {
    "success": "https://your-success-url.com",
    "failure": "https://your-failure-url.com"
    }
    }
    }'
  2. Sample response
    ​

    See example response below.

    JSON
    {
    "status": "SUCCESS",
    "enrollment": {
    "status": "revoked"
    }
    }

Resources​

Use the following resources when testing in your sandbox environment.

Still need help?

Help Image

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