Skip to content
Create account
or
Sign in
The Stripe Docs logo
/
Ask AI
Create account
Sign in
Get started
Payments
Revenue
Platforms and marketplaces
Money management
Developer resources
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
    Crypto
    Bank debits
    Bank redirects
    Bank transfers
    Credit transfers (Sources)
    Buy now, pay later
    Real-time payments
    Vouchers
    Wallets
      Alipay
      Amazon Pay
      Apple Pay
      Cash App Pay
      Google Pay
      GrabPay
      Link
      MB WAY
      MobilePay
      PayPal
        PayPal button
        Activate PayPal payments
        Accept a payment
        Set up future payments
        Choose settlement preference
        Disputed payments
        Payout reconciliation
        Supported locales
        Import saved PayPal payment methods
      PayPay
      Revolut Pay
      Satispay
      Secure Remote Commerce
      Vipps
      WeChat Pay
    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
Handle multiple currencies
Custom payment flows
Flexible acquiring
Orchestration
In-person payments
Terminal
Beyond payments
Incorporate your company
Crypto
Financial Connections
Climate
Understand fraud
Radar fraud protection
Manage disputes
Verify identities
HomePaymentsAdd payment methodsWalletsPayPal

Accept a PayPal payment

Learn how to accept PayPal payment, a digital wallet popular with businesses in Europe.

Set up Stripe
Server-side

First, you need a Stripe account. Register now.

Use our official libraries for access to the Stripe API from your application:

Command Line
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
# Available as a gem sudo gem install stripe
Gemfile
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
# If you use bundler, you can add this line to your Gemfile gem 'stripe'

Create a PaymentIntent
Server-side

Stripe uses a payment object, called a PaymentIntent, to track and handle all the states of the payment until it’s completed. Create a PaymentIntent on your server, specifying the amount to collect and the currency. If you already have an integration using the Payment Intents API, add paypal to the list of payment method types for your PaymentIntent.

Command Line
cURL
Stripe CLI
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
curl https://api.stripe.com/v1/payment_intents \ -u "
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:"
\ -d amount=1099 \ -d currency=eur \ -d "payment_method_types[]"=paypal

Included in the returned PaymentIntent is a client secret, which is used to securely complete the payment process instead of passing the entire PaymentIntent object. Send the client secret back to the client so you can use it in later steps.

Include a custom description

By default, the order details on the PayPal users purchase activity page displays the order amount. You can change this by providing a custom description in the description property.

Command Line
cURL
Stripe CLI
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
curl https://api.stripe.com/v1/payment_intents \ -u "
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:"
\ -d amount=1099 \ -d currency=eur \ -d description="A sample description" \ -d "payment_method_types[]"=paypal

Customize the preferred locale

By default, the PayPal authorization page is localized based on variables such as the merchant’s country. You can set this to your customer’s preferred locale using the preferred_locale property. The value must be a two-character lowercased language code, followed by a hyphen (-), followed by a two-character uppercased country code. For example, the value for a French-language user in Belgium would be fr-BE. See supported locales for more information.

Command Line
cURL
Stripe CLI
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
curl https://api.stripe.com/v1/payment_intents \ -u "
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:"
\ -d amount=1099 \ -d currency=eur \ -d "payment_method_types[]"=paypal \ -d "payment_method_options[paypal][preferred_locale]"=fr-BE

Statement descriptors with PayPal

The descriptor that appears on the buyer’s bank statement is set by PayPal, and by default is PAYPAL *YOUR_BUSINESS_NAME. If you set the statement_descriptor field when creating the PaymentIntent, its value is appended to the one set by PayPal, up to a total limit of 22 characters.

For example, if your business name in PayPal is BUSINESS and you set statement_descriptor to order_id_1234, buyers see PAYPAL *BUSINESS order on their bank account statement.

Submit the payment to Stripe
Client-side

When a customer clicks to pay with PayPal, use Stripe.js to submit the payment to Stripe. Stripe.js is the foundational JavaScript library for building payment flows. It automatically handles complexities like the redirect described below, and enables you to extend your integration to other payment methods. Include the Stripe.js script on your checkout page by adding it to the head of your HTML file.

checkout.html
<head> <title>Checkout</title> <script src="https://js.stripe.com/basil/stripe.js"></script> </head>

Create an instance of Stripe.js with the following JavaScript on your checkout page.

client.js
// Set your publishable key. Remember to change this to your live publishable key in production! // See your keys here: https://dashboard.stripe.com/apikeys const stripe = Stripe(
'pk_test_TYooMQauvdEDq54NiTphI7jx'
);

To create a payment on the client side, pass the client secret of the PaymentIntent object that you created in Step 2. The client secret is different from your API keys that authenticate Stripe API requests. Handle this carefully because it can complete the charge. Don’t log it, embed it in URLs, or expose it to anyone but the customer.

Confirm PayPal payment

Call stripe.confirmPayPalPayment to redirect your customer to PayPal to complete the payment. You must add a return_url to specify where Stripe will redirect your customer after they complete the payment. You can also add the return_url for new PayPal payment methods, but it’s not required when using a previously set up PayPal payment method with SetupIntent or a PaymentIntent that includes setup_future_usage.

client.js
// Redirects away from the client const {error} = await stripe.confirmPayPalPayment( '{{PAYMENT_INTENT_CLIENT_SECRET}}', { return_url: 'https://example.com/checkout/complete', } ); if (error) { // Inform the customer that there was an error. }

If you settle your PayPal funds with PayPal, the balance transaction linked to the payment has an amount of zero regardless of the payment amount, because the transaction represents money moved into and out of your Stripe balance. However, for PayPal, funds settle in your PayPal balance, and no money goes to your Stripe balance. The balance transaction in this case also includes fees associated with it. Learn about other important details related to the settlement preference.

Handling the redirect

The following URL query parameters are provided when Stripe redirects the customer to the return_url.

ParameterDescription
payment_intentThe unique identifier for the PaymentIntent.
payment_intent_client_secretThe client secret of the PaymentIntent object.

You may also append your own query parameters when providing the return_url. They persist throughout the redirect process. The return_url should correspond to a page on your website that provides the status of the payment. You should verify the status of the PaymentIntent when rendering the return page. You can do so by using the retrievePaymentIntent function from Stripe.js and passing in the payment_intent_client_secret.

(async () => { const url = new URL(window.location); const clientSecret = url.searchParams.get('payment_intent_client_secret'); const {paymentIntent, error} = await stripe.retrievePaymentIntent(clientSecret); if (error) { // Handle error } else if (paymentIntent && paymentIntent.status === 'succeeded') { // Handle successful payment } })();

You can find the payment owner’s name, email, payer ID, and transaction ID in the payment_method_details property.

FieldValue
payer_emailThe email address of the payer on their PayPal account.
payer_nameThe name of the payer on their PayPal account.
payer_idA unique ID of the payer’s PayPal account.
transaction_idA unique transaction ID generated by PayPal.
{ "charges": { "data": [ { "payment_method_details": { "paypal": { "payer_id": "H54KFE9XXVVYJ", "payer_email": "jenny@example.com", "payer_name": "Jenny Rosen", "transaction_id": "89W40396MK104212M" }, "type": "paypal" }, "id": "src_16xhynE8WzK49JbAs9M21jaR", "object": "source", "amount": 1099, "client_secret": "src_client_secret_UfwvW2WHpZ0s3QEn9g5x7waU", "created": 1445277809, "currency": "eur", "flow": "redirect",

OptionalHandle post-payment events

Stripe sends a payment_intent.succeeded event when the payment completes. Use the Dashboard, a custom webhook, or a partner solution to receive these events and run actions, like sending an order confirmation email to your customer, logging the sale in a database, or starting a shipping workflow.

Listen for these events rather than waiting on a callback from the client. On the client, the customer could close the browser window or quit the app before the callback executes, and malicious clients could manipulate the response. Setting up your integration to listen for asynchronous events also helps you accept more payment methods in the future. Learn about the differences between all supported payment methods.

Receive events and run business actions

There are a few options for receiving and running business actions.

Manually

Use the Stripe Dashboard to view all your Stripe payments, send email receipts, handle payouts, or retry failed payments.

  • View your test payments in the Dashboard

Custom code

Build a webhook handler to listen for events and build custom asynchronous payment flows. Test and debug your webhook integration locally with the Stripe CLI.

  • Build a custom webhook

Prebuilt apps

Handle common business events, like automation or marketing and sales, by integrating a partner application.

OptionalHandle the PayPal redirect manually

Stripe.js helps you extend your integration to other payment methods. However, you can manually redirect your customers on your server.

  1. Create and confirm a PaymentIntent of type paypal. By specifying payment_method_data, a PaymentMethod is created and immediately used with the PaymentIntent.

You must also provide the URL where your customer is redirected to after they complete their payment in the return_url field. You can provide your own query parameters in this URL. These parameters are included in the final URL upon completing the redirect flow.

Command Line
cURL
Stripe CLI
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
curl https://api.stripe.com/v1/payment_intents \ -u "
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:"
\ -d amount=1099 \ -d currency=eur \ -d "payment_method_types[]"=paypal \ -d "payment_method_data[type]"=paypal \ --data-urlencode return_url="https://example.com/checkout/complete" \ -d confirm=true
  1. Check that the PaymentIntent has a status of requires_action and the type for next_action is redirect_to_url.
Response
{ "status": "requires_action", "next_action": { "type": "redirect_to_url", "redirect_to_url": { "url": "https://hooks.stripe.com/...", "return_url": "https://example.com/checkout/complete" } }, "id": "pi_1G1sgdKi6xqXeNtkldRRE6HT", "object": "payment_intent", ... }
  1. Redirect the customer to the URL provided in the next_action.redirect_to_url.url property. This code example is approximate—the redirect method might be different in your web framework.
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
if payment_intent.status == 'requires_action' && payment_intent.next_action.type == 'redirect_to_url' url = payment_intent.next_action.redirect_to_url.url redirect(url) end

Your customer is redirected to the return_url when they complete the payment process. The payment_intent and payment_intent_client_secret URL query parameters are included along with any of your own query parameters. Stripe recommends setting up a webhook endpoint to programmatically confirm the status of a payment.

OptionalAuthorize a payment and then capture later

PayPal supports separate authorization and capture. If you’ve opted for settlement to Stripe, your authorizations are valid for 10 days. Stripe automatically reauthorizes the payment to extend the authorization period by another 10 days. This results in a total of 20 days. If the reauthorization doesn’t work, Stripe makes the payment expire right after 10 days. Listen to the charge.expired webhook to know when the authorization period ends.

If you’ve opted for settlement to PayPal, your authorizations remain valid for 3 days. Stripe tries to extend the authorization period by another 3 days. For an extended guaranteed authorization period of up to 10 days, referred to as honor period on PayPal, contact PayPal support.

Tell Stripe to authorize only

To indicate that you want separate authorization and capture, set capture_method to manual when creating the PaymentIntent. This parameter instructs Stripe to only authorize the amount on the customer’s PayPal account.

Command Line
cURL
Stripe CLI
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
curl https://api.stripe.com/v1/payment_intents \ -u "
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:"
\ -d amount=1099 \ -d currency=eur \ -d capture_method=manual \ -d "payment_method_types[]"=paypal \ -d "payment_method_data[type]"=paypal \ -d confirm=true \ --data-urlencode return_url="http://example.com"

Upon authorization success, Stripe sends a payment_intent.amount_capturable_updated event. Read our Events guide to learn more.

Capture the funds

After the authorization succeeds, the PaymentIntent status transitions to requires_capture. To capture the authorized funds, make a PaymentIntent capture request. The total authorized amount is captured by default—you can’t capture more than this, but you can capture less.

Command Line
cURL
Stripe CLI
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
curl https://api.stripe.com/v1/payment_intents/{{PAYMENT_INTENT_ID}}/capture \ -u "
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:"
\ -d amount_to_capture=750

Optional Cancel the authorization

If you need to cancel an authorization, you can cancel the PaymentIntent.

OptionalTurn on asynchronous payment methods on PayPal

By default, Stripe only allows synchronous payment methods on PayPal. This guarantees that you receive an immediate notification for the success or the failure of each payment. If you allow asynchronous payment methods, you might encounter delayed notifications for some payments. As a result, you must rely on webhook endpoints to receive notifications about the success or failure of certain payments.

To enable asynchronous payments on PayPal, contact Stripe support.

OptionalError codes

These are the common error codes and corresponding details while integrating with PayPal. If a PayPal API request returned the error, it includes a PayPal issue code and the associated Debug ID for the request. You can use the Debug ID when contacting PayPal support to get help with your issue.

Error CodeDetails
country_code_invalidThe specified country code in the shipping address is invalid.
incorrect_addressThe specified shipping address is invalid. This error is also thrown if the specified country additionally requires either a city or a postal code. For further information, please check the error message and contact PayPal support with the Debug ID and PayPal issue.
payment_method_not_availableThe paypal payment method is currently not available. This error might be caused by a timeout or server issue when connecting to PayPal API.
payment_method_provider_declineThe transaction is declined by PayPal. This is commonly caused by the merchant’s fraud protection settings on PayPal, a compliance violation, or the payer being unable to pay with the chosen funding instrument. For further information, please check the error message and contact PayPal support with the Debug ID and PayPal issue.
payment_method_provider_timeoutThe request timed out on PayPal. In most cases, this is a transient error and you can retry the request after a few moments.
payment_method_unactivatedThe paypal payment method isn’t activated for your Stripe account.
payment_method_unexpected_stateThe request failed on PayPal. This can occur if the merchant’s business account is locked, restricted, or closed by PayPal, or if the payer’s PayPal account is restricted. For further information, please check the error message and contact PayPal support with the Debug ID and PayPal issue.

OptionalTest PayPal integration

To test a successful payment on your PayPal integration, use your test API keys and view the redirect page. This page shows you the options to Authorize or Fail the user authentication as test scenarios. When you select Authorize test payment, the PaymentIntent transitions from requires_action to succeeded.

To test the case where the user fails to authenticate, use your test API keys and view the redirect page. On the redirect page, click Fail test payment. The PaymentIntent then transitions from requires_action to requires_payment_method.

To simulate the most common integration and failure scenarios for PayPal payments, pass email values that match the patterns described in Test Scenarios when you create the PaymentIntent as part of the billing details. For example, when confirming the PaymentIntent server-side, a request simulating a transaction refused by PayPal would look like:

Command Line
cURL
No results
curl https://api.stripe.com/v1/payment_intents \ -u "
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:"
\ -d amount=1099 \ -d currency=eur \ -d "payment_method_types[]"=paypal \ -d "payment_method_data[type]"=paypal \ --data-urlencode "payment_method_data[billing_details][email]"="transaction_refused@example.com"

Test scenarios

Email patternScenarioExplanation
.*payee_account_restricted@.*Merchant account restrictedCapturing or authorizing a payment fails with a payment_method_unexpected_state error if your merchant account is restricted by PayPal. Provide an email matching this pattern at time of authorization to fail the authorization.
.*transaction_refused@.*Transaction refusedCapturing a payment fails with a payment_method_provider_decline error if the transaction is refused by PayPal.
.*instrument_declined@.*Payment instrument declinedCapturing a payment fails with a payment_method_provider_decline error if the instrument presented was either declined by the processor or bank, or it can’t be used for this payment.
.*authorization_expired@.*Manually capturing an authorized paymentCapturing an authorized payment fails with a capture_charge_authorization_expired error if the authorization has already expired.
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