@bounceapp/react-native-paypal

中文文档
1.0.0发布于 2026/10/09MITTypeScriptESM + CJS零依赖近 30 天下载 1.2万

React Native wrapper to bridge PayPal iOS and Android SDK

原始使用文档
文档目录10 节
  1. Platform Compatibility
  2. Documentation
  3. Installation
  4. Requirements
  5. Android return URLs
  6. Bare Workflow
  7. Expo
  8. Usage example
  9. 👏 Contributing
  10. License

@bounceapp/react-native-paypal

Package version MIT license PRs Welcome

React Native wrapper to bridge PayPal iOS and Android SDK, support only requestBillingAgreement for the moment

Platform Compatibility

Android DeviceAndroid EmulatoriOS DeviceiOS SimulatorExpo GOWeb
✅✅✅✅❌❌

Documentation

API Reference.

Upgrading from 0.8.x? 1.0.0 moves to Braintree Android v5 and iOS v7 and is a breaking release. See the migration guide.

Installation

yarn add @bounceapp/react-native-paypal

This is an Expo module, so your app needs the expo package. Bare React Native apps can add it with npx install-expo-modules@latest. It requires Expo SDK 56 or later.

Requirements

Minimum
ExpoSDK 56
iOS16.0 (Braintree iOS v7)
AndroidAPI 23 (Braintree Android v5)

Android return URLs

Braintree Android v5 returns from the PayPal flow through an Android App Link, so you need a domain you control serving an assetlinks.json that lists your app. Pass that URL as appLinkReturnUrl on every requestBillingAgreement call.

Give the App Link its own path, such as /paypal, and scope the intent-filter to it with a pathPrefix. Without one, the filter claims every link on the host, so if you use your main domain, all of its web links open your app.

Two things to know about how Braintree handles the return:

  • The pathPrefix only scopes which links Android sends to your app. Braintree itself matches a return on scheme and host alone, so another link on the same host that reaches the app during a flow is not a PayPal return. It settles as Canceled.
  • If the App Link is not verified, Braintree falls back to the ${applicationId}.braintree scheme on its own.

The ${applicationId}.braintree scheme is still used, now as the fallback for buyers who have turned off "Open supported links". This library derives it from your application ID automatically — you only need to keep declaring it.

Bare Workflow

// android/app/src/main/AndroidManifest.xml
<activity
  android:name=".MainActivity"
  // ...
  >
  // ...
  <!-- App Link: the primary return path. -->
  <intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data
      android:scheme="https"
      android:host="your-app.example.com"
      android:pathPrefix="/paypal" />
  </intent-filter>
  <!-- Deep link: the fallback return path. -->
  <intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="${applicationId}.braintree" />
  </intent-filter>
</activity>

Expo

Add the config plugin with the same URL you pass as appLinkReturnUrl:

// app.json
{
  "expo": {
    "plugins": [
      [
        "@bounceapp/react-native-paypal",
        { "appLinkReturnUrl": "https://your-app.example.com/paypal" }
      ]
    ]
  }
}

On prebuild it adds both intent-filters to your main activity: the App Link, scoped to the URL's path with a pathPrefix, and the .braintree fallback scheme, derived from android.package exactly as the library derives it at runtime. If you declared either filter yourself under expo.android.intentFilters, remove it.

Usage example

// App.tsx
import { useState } from "react"
import { Button } from "react-native"
import { requestBillingAgreement } from "@bounceapp/react-native-paypal"

export default function App() {
  const [loading, setLoading] = useState(false)

  const onPress = async () => {
    setLoading(true)
    const res = await requestBillingAgreement({
      clientToken: "CLIENT_TOKEN",
      // Android only: your verified App Link. Ignored on iOS.
      appLinkReturnUrl: "https://your-app.example.com/paypal",
    })

    setLoading(false)

    if (res.error) {
      console.error(res.error)
      return
    }
  }

  return <Button title="Pay with PayPal" onPress={onPress} disabled={loading} />
}

Every expected outcome resolves: a nonce in payload, or an error whose code is Canceled or Failed. The promise rejects only on a programming error, such as an option of the wrong type, so there is no need for a try/catch around the call in normal use.

👏 Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

The source code is made available under the MIT license. Some of the dependencies can be licensed differently, with the BSD license, for example.

版本与发布记录

@bounceapp/react-native-paypal 共发布 15 个版本,首次发布于 2022/08/02;过去 12 个月发布了 1 个版本。

版本发布日期距今
1.0.0latest2026/10/0930 天前
0.8.02025/10/131.1 年前
0.7.12025/07/031.3 年前
0.7.02025/07/011.4 年前
0.6.02024/12/171.9 年前
0.5.22024/06/052 年前

关于 @bounceapp/react-native-paypal 的常见问题

@bounceapp/react-native-paypal 是什么?

React Native wrapper to bridge PayPal iOS and Android SDK

如何安装 @bounceapp/react-native-paypal?

在项目目录运行 npm install @bounceapp/react-native-paypal,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:expo(>=56.0.0)、react(*)、react-native(>=0.85.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bounceapp/react-native-paypal 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bounceapp/react-native-paypal 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@bounceapp/react-native-paypal 可以商用吗?

@bounceapp/react-native-paypal 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bounceapp/react-native-paypal 的下载量有多少?

根据 npm 官方下载统计,@bounceapp/react-native-paypal 在 2026/10/09 – 2026/11/07 这 30 天内被下载 12,364 次,日均约 412 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bounceapp/react-native-paypal 还在维护吗?

最新版本 1.0.0 发布于 2026/10/09(30 天前);至今共发布 15 个版本,其中过去 12 个月发布了 1 个;首次发布于 2022/08/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。