调至内容部分
创建账户或登录
Stripe 文档徽标
/
询问人工智能
创建账户登录
开始
付款
销售收入
平台和交易市场
资金管理
开发人员资源
API 和 SDK帮助
概览
关于 Stripe 支付
升级您的集成
支付分析
线上付款
概览查找您的用例使用 Managed Payments
使用 Payment Link
使用预制结账页面
使用 Elements 构建自定义集成
构建应用内集成
线下支付
Terminal
支付方式
添加支付方式
    概览
    支付方式集成选项
    在管理平台中管理默认支付方式
    支付方式类型
    银行卡
    使用 Stripe 余额支付
    稳定币支付
    银行借记
    银行重定向
    银行转账
    贷记转账(来源)
    先买后付
    实时付款
    付款凭单
    钱包
      支付宝
      Amazon Pay
      Apple Pay
      Cash App Pay
      Google Pay
      GrabPay
      Link
      MB WAY
      MobilePay
      PayPal
        PayPal 按钮
        激活 PayPal 支付
        收款
        设置未来付款
        选择结算偏好
        有争议的付款
        提现对账
        导入已保存的 PayPal 支付方式
      PayPay
      Revolut Pay
      Satispay
      Secure Remote Commerce
      Vipps
      微信支付
    按国家启用本地支付方式
    自定义支付方式
管理支付方式
用 Link 更快结账
支付场景
处理多种货币
自定义支付流程
灵活收单
编排
超越支付功能
成立公司
加密货币
智能体商务 (Agentic Commerce)
Financial Connections
Climate
了解欺诈
Radar 欺诈保护
管理争议
验证身份
美国
简体中文
首页付款Add 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.

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

You can set the PayPal authorization page to your customer’s preferred locale through the preferred_locale property. See the following table for supported locales:

ValueLocaleCountry
cs-CZCzechThe Czech Republic
da-DKDanishDenmark
de-ATGermanAustria
de-DEGermanGermany
de-LUGermanLuxembourg
el-GRGreekGreece
en-GBEnglishUnited Kingdom
en-USEnglishUnited States of America
es-ESSpanishSpain
fi-FIFinnishFinland
fr-BEFrenchBelgium
fr-FRFrenchFrance
fr-LUFrenchLuxembourg
hu-HUHungarianHungary
it-ITItalianItaly
nl-BEDutchBelgium
nl-NLDutchNetherlands
pl-PLPolishPoland
pt-PTPortuguesePortugal
sk-SKSlovakSlovakia
sv-SESwedishSweden

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/clover/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",

可选Handle 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.

可选Handle 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.

可选Authorize 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.

可选Turn 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.

可选Error 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.

可选Test 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.
此页面的内容有帮助吗?
是否
  • 需要帮助?联系支持。
  • 查看我们的更改日志。
  • 有问题?联系销售。
  • LLM? Read llms.txt.
  • Powered by Markdoc