Skip to content
Create account
or
Sign in
The Stripe Docs logo
/
Ask AI
Create account
Sign in
Get started
Payments
Finance automation
Platforms and marketplaces
Money management
Developer tools
Get started
Payments
Finance automation
Get started
Payments
Finance automation
Platforms and marketplaces
Money management
Overview
About Stripe payments
Upgrade your integration
Payments analytics
Online payments
OverviewFind your use caseManaged Payments
Use Payment Links
Build a checkout page
Build an advanced integration
Build an in-app integration
Payment methods
Add payment methods
    Overview
    Payment method integration options
    Manage default payment methods in the Dashboard
    Payment method types
    Cards
    Pay with Stripe balance
    Bank debits
    Bank redirects
    Bank transfers
    Credit transfers (Sources)
    Buy now, pay later
    Real-time payments
      Pay by Bank
      PayNow
      PayTo
      Pix
        Accept a payment
      PromptPay
      Swish
    Vouchers
    Wallets
    Enable local payment methods by country
    Custom payment methods
Manage payment methods
Faster checkout with Link
Payment interfaces
Payment Links
Checkout
Web Elements
In-app Elements
Payment scenarios
Custom payment flows
Flexible acquiring
Orchestration
In-person payments
Terminal
Other Stripe products
Financial Connections
Crypto
Climate
HomePaymentsAdd payment methodsReal-time paymentsPix

Pix payments

Learn how to accept Pix, a common payment method in Brazil.

Copy page

Stripe users can accept Pix payments from customers in Brazil. Customers pay by copying and pasting a Pix string or scanning a QR code directly in their bank apps.

Determine compatibility

Supported business locations: BR, US

Supported currencies: brl

Presentment currencies: brl

Payment mode: Yes

Setup mode: No

Subscription mode: No

A Checkout Session must satisfy all of the following conditions to support Pix payments:

  • Prices for all line items must be in the brl currency.
  • You can only use one-time line items (recurring subscription plans aren’t supported).

Accept a payment

Note

Build an integration to accept a payment with Checkout before using this guide.

Use this guide to learn how to enable Pix—it shows the differences between accepting a card payment and using Pix.

Enable Pix as a payment method

When creating a new Checkout Session, you need to:

  1. Add pix to the list of payment_method_types.
  2. Make sure all your line_items use the brl currency.
Ruby
Stripe::Checkout::Session.create({ mode: 'payment', payment_method_types: ['card'], payment_method_types: ['card', 'pix'], line_items: [{ price_data: { currency: 'usd', # To accept `pix`, all line items must have currency: brl currency: 'brl', product_data: { name: 'T-shirt', }, unit_amount: 2000, }, quantity: 1, }], success_url: 'https://example.com/success', cancel_url: 'https://example.com/cancel', })

Additional payment method options

You can set the number of seconds before a pending Pix payment expires by specifying the optional expires_after_seconds parameter in the payment method options for your PaymentIntent. For example, if you confirm a Pix on Monday at 14:00 and you set expires_after_seconds to 600, the Pix expires on Monday at 14:10. You can set expires_after_seconds to a value between 10 seconds and 1209600 seconds (14 days). The default is 86400 seconds (1 day). After you create the PaymentIntent, confirm it to start the expiry timer.

Redirect to a Stripe-hosted instructions page

Note

Unlike card payments, we don’t redirect your customer to the success_url with Pix payments.

After submitting the Checkout form successfully, we redirect your customer to the hosted_instructions_url. Your customer scans the QR code or copies the Pix string from the Stripe-hosted instructions page.

We send a payment_intent.requires_action event when a Pix code is created successfully. Locate the hosted_instructions_url in payment_intent.next_action.pix_display_qr_code.hosted_instructions_url to email your customers the instructions link. Learn more about how to monitor a PaymentIntent with webhooks.

We allow customization of customer-facing UIs on the branding settings page. You can apply the following brand settings to the Stripe-hosted instructions page:

  • Icon—your brand image and public business name
  • Accent color—use as the color of the Copy Code button
  • Brand color—use as the background color

Fulfill your orders

Because Pix is a delayed notification payment method, you need to use a method such as webhooks to monitor the payment status and handle order fulfillment. Learn more about setting up webhooks and fulfilling orders.

We send the following events when the payment status changes:

Event NameDescriptionNext steps

checkout.session.completed

Your customer successfully submits the Checkout form and Stripe generates the Pix code.

You can choose to email the hosted_instructions_url to your customer in case they lose the Pix code.

Wait for your customer to pay the Pix.

checkout.session.async_payment_succeededYour customer successfully paid the Pix. The PaymentIntent transitions to succeeded.Fulfill the goods or services that your customer purchased.
checkout.session.async_payment_failedThe Pix code is expired, or the payment has failed for some other reason. The PaymentIntent returns to a status of requires_payment_method.Send your customer an email and request that they place a new order.

Test your integration

To test your integration:

  1. Select Pix.
  2. Enter the buyer’s details and tap Pay. In a testing environment, you can use 000.000.000-00 as a test tax identifier (CPF or CNPJ).
  3. Click Simulate scan to open a Stripe-hosted Pix test payment page. From this page, you can either authorize or expire the test payment.

In live mode, the Pay button displays a Pix QR code. You need a Brazilian bank account with Pix enabled to complete or cancel this payment flow.

You can also set payment_method.billing_details.email to the following values to test different scenarios.

EmailDescription

{any_prefix}@{any_domain}

Simulates a Pix that a customer pays after 3 minutes—the payment_intent.succeeded webhook arrives after about 3 minutes. In production, this webhook arrives as soon as the Pix is paid.

We ignore the payment_method_options.pix.expires_at and payment_method_options.pix.expires_after_seconds parameters in this case.

Example: anything@example.com

{any_prefix}succeed_immediately@{any_domain}

Simulates a Pix that your customer pays immediately—the payment_intent.succeeded webhook arrives within several seconds. In production, this webhook arrives as soon as the Pix is paid.

We ignore the payment_method_options.pix.expires_at and payment_method_options.pix.expires_after_seconds parameters in this case.

Example: succeed_immediately@example.com

{any_prefix}expire_immediately@{any_domain}

Simulates a Pix that expires before your customer pays—the payment_intent.payment_failed webhook arrives within several seconds.

We ignore the payment_method_options.pix.expires_at and payment_method_options.pix.expires_after_seconds parameters in this case.

Example: expire_immediately@example.com

{any_prefix}expire_with_delay@{any_domain}

Simulates a Pix that expires before your customer pays—the payment_intent.payment_failed webhook arrives after about 3 minutes.

We ignore the payment_method_options.pix.expires_at and payment_method_options.pix.expires_after_seconds parameters in this case.

Example: expire_with_delay@example.com

{any_prefix}fill_never@{any_domain}

Simulates a Pix that never succeeds—it expires according to the payment_method_options.pix.expires_at or payment_method_options.pix.expires_after_seconds parameter. The payment_intent.payment_failed webhook displays after the simulation completes.

Example: fill_never@example.com

OptionalRefunds
Server-side

See also

  • Checkout fulfillment
  • Customizing Checkout

Expiration

Pix codes expire after the specified expires_at UNIX timestamp. After the Pix expires, confirm the PaymentIntent with another payment method or cancel it. Set expiration parameters in the payment method options under the pix key.

A customer can’t pay a Pix after it expires.

FieldValueDefault valueRequired Example
expires_after_secondsThe number of seconds before a pending Pix payment expires. Valid values are from 10 seconds to 1209600 seconds (14 days)86400 seconds (1 day)NoIf you confirm a Pix on Monday at 14:00 and you set expires_after_seconds to 600, the Pix expires on Monday at 14:10. Note that the start time isn’t when the PaymentIntent is created, but when it is confirmed.
expires_atA Unix timestamp that shows when the pending Pix payment expires. Valid values are from 10 seconds to 14 days in the futureThe default is 1 day in the futureNoIf you create a Pix on Monday at 14:00 and you set expires_at to 2 days in the future, the Pix expires on Wednesday at 14:00

expires_after_seconds and expires_at are mutually exclusive. An error occurs if both are set. Both are also optional, and if neither is set, the expiration defaults to 1 day from when the PaymentIntent is confirmed.

Note

The value returned on expires_at from the next_action response is the same as the input set on payment_method_options.expires_at. Although, in real scenarios, the actual expiration timestamp might differ. This doesn’t impact your customers experience paying with Pix, but it’s recommended to rely on the payment_intent.payment_failed event to consider if the payment intent has expired.

Cancellation

You can cancel Pix payments before they expire by cancelling the PaymentIntent associated with the Pix payment.

Was this page helpful?
YesNo
Need help? Contact Support.
Join our early access program.
Check out our changelog.
Questions? Contact Sales.
LLM? Read llms.txt.
Powered by Markdoc