@adyen/react-native

中文文档
2.14.0发布于 2026/11/02MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 10.8万

Wraps Adyen Checkout Drop-In and Components for iOS and Android for convenient use with React Native

原始使用文档
文档目录12 节
  1. Table of Contents
  2. Prerequisites
  3. Expo Integration
  4. Manual Integration
  5. Configuration
  6. Return URL
  7. Opening Payment component
  8. Sessions Flow
  9. Advanced Flow
  10. Handling Actions
  11. Standalone Action handling
  12. Contributing

npm version Adyen iOS Adyen Android Maintainability Rating

[!Important] React Native New Architecture Support

The New Architecture for React Native is exclusively supported on versions 0.76.0 and above.

[!Important]

Adyen Android SDK 5.22.0 requires Kotlin 2.3 (2.2.20 on Expo SDK 54), Android API 36 and Android Gradle plugin 8.9.1. It is supported from React Native 0.79 and Expo SDK 54.

See Compatibility for what to set for your React Native or Expo version. The same document keeps notes for officially unsupported React Native versions below 0.74.

React Native Logo

Adyen React Native

Adyen React Native provides you with the building blocks to create a checkout experience for your shoppers, allowing them to pay using the payment method of their choice.

You can integrate with Adyen React Native in two ways:

  • Drop-in: React Native wrapper for native iOS and Android Adyen Drop-in - an all-in-one solution, the quickest way to accept payments on your React Native app.
  • Components: React Native wrapper for native iOS and Android Adyen Components - one Component per payment method that can be combined with your own payments flow.

Table of Contents

Prerequisites

Installation

Add @adyen/react-native to your React Native project:

yarn add @adyen/react-native

Expo Integration

[!IMPORTANT]

This library is not compatible with Expo Go. It is designed exclusively for use with the Continuous Native Generation.

Add @adyen/react-native plugin to your app.json:

{
  "expo": {
    "plugins": ["@adyen/react-native"]
  }
}

For Android, install expo-build-properties and set the Kotlin and Android API values for your Expo SDK from Compatibility.

Plugin Configuration Options
OptionDescription
merchantIdentifierSets ApplePay Merchant ID to your iOS app's entitlement file. Empty by default.
useFrameworksAdjust import on iOS in case your Podfile has use_frameworks! enabled.

Example with all options:

{
  "expo": {
    "plugins": [
      [
        "@adyen/react-native",
        {
          "merchantIdentifier": "merchant.com.my-merchant-id",
          "useFrameworks": true
        }
      ]
    ]
  }
}

[!TIP]

If you are facing issues with the plugin, pre-build your app and investigate the generated files:

npx expo prebuild --clean

Manual Integration

[!NOTE]

For Objective-C and Java integration, see the legacy documentation.

iOS Setup
  1. Run pod install

  2. Add returnURL handler to your AppDelegate.swift:

import Adyen

// ...

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
    return RedirectComponent.applicationDidOpen(from: url)
}

If using RCTLinkingManager or other deep-linking techniques, place ADYRedirectComponent.applicationDidOpen before them:

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
    return RedirectComponent.applicationDidOpen(from: url) || RCTLinkingManager.application(app, open: url, options: options)
}

For Universal Link support:

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
    if userActivity.activityType == NSUserActivityTypeBrowsingWeb,
       let url = userActivity.webpageURL,
       RedirectComponent.applicationDidOpen(from: url) {
        return true
    }
    return RCTLinkingManager.application(application, continue: userActivity, restorationHandler: restorationHandler)
}
  1. Add custom URL Scheme to your app.

  2. For ApplePay: Follow the Enable ApplePay for iOS guide.

Android Setup
  1. Set Kotlin, the Android API level and, on React Native 0.79, the Android Gradle plugin in android/build.gradle as listed in Compatibility.

  2. Provide your Checkout activity to AdyenCheckout in MainActivity.kt:

import com.adyenreactnativesdk.AdyenCheckout
import android.os.Bundle

// ...

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(null)
    AdyenCheckout.setLauncherActivity(this)
}
  1. Add intent-filter to your Checkout activity (for standalone components):
<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="myapp" android:path="/payment" />
</intent-filter>
  1. Add returnURL handler for standalone redirect components in MainActivity.kt:
import android.content.Intent

// ...

override fun onNewIntent(intent: Intent) {
    super.onNewIntent(intent)
    AdyenCheckout.handleIntent(intent)
}
  1. Ensure your app theme extends Theme.MaterialComponents:
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
    <!-- Your configuration here -->
</style>

Usage

For general understanding of how prebuilt UI components of Adyen work you can follow our documentation.

Configuration

To read more about other configuration, see the full list. Example of required configuration:

import { Configuration } from '@adyen/react-native';

const configuration: Configuration = {
  environment: 'test', // When you're ready to accept real payments, change the value to a suitable live environment.
  clientKey: '{YOUR_CLIENT_KEY}',
  countryCode: 'NL',
  amount: { currency: 'EUR', value: 1000 }, // Value in minor units
  returnUrl: 'myapp://payment', // See description below.
};

Return URL

[!IMPORTANT]

On config use a custom URL scheme or App/Universal link of your app(s).

Scenario How to use
Advanced flow

During onSubmit(data, component, extras) pass "returnUrl": data.returnUrl to make \payments API call.

Sessions flow

To make \sessions API call use AdyenDropIn.getReturnURL() to fetch returnUrl.

const returnUrl = Platform.select({
  ios: 'myapp://payment',
  android: await AdyenDropIn.getReturnURL(),
});

Opening Payment component

To use @adyen/react-native you can use our helper component AdyenCheckout and helper functions from useAdyenCheckout with standalone component:

import { useAdyenCheckout } from '@adyen/react-native';

const MyCheckoutView = () => {
  const { start } = useAdyenCheckout();

  return (
    <Button
      title="Open DropIn"
      onPress={() => {
        start('dropIn');
      }}
    />
  );
};

Sessions Flow

[!IMPORTANT]

Memoize your callbacks with useCallback to prevent unnecessary re-renders and event listener re-registration. Inline functions will cause performance issues.

import { AdyenCheckout } from '@adyen/react-native';
import { useCallback } from 'react';

const onComplete = useCallback((result, component) => {
  // Payment was completed - call `component.hide(true)` to dismiss the payment UI.
  // Call /sessions/(sessionId)?sessionResult={result} API to get more information about the payment outcome.
}, []);

const onError = useCallback((error, component) => {
  // Payment was terminated by shopper or encountered an error
  // Call `component.hide(false)` to dismiss the payment UI.
}, []);

<AdyenCheckout
  config={configuration}
  session={session}
  onComplete={onComplete}
  onError={onError}
>
  <MyCheckoutView />
</AdyenCheckout>;

Advanced Flow

import { AdyenCheckout } from '@adyen/react-native';
import { useCallback } from 'react';

const onSubmit = useCallback((data, component) => {
  // Call your server to make the `/payments` request
  // Pass `returnUrl: data.returnUrl` for cross-platform redirect flow
  // If response contains `action`, call `component.handle(response.action)`
  // Otherwise, call `component.hide(true | false)` to dismiss the payment UI
}, []);

const onAdditionalDetails = useCallback((paymentData, component) => {
  // Call your server to make the `/payments/details` request
  // Call `component.hide(true | false)` to dismiss the payment UI
}, []);

const onError = useCallback((error, component) => {
  // Payment was terminated by shopper or encountered an error
  // Call `component.hide(false)` to dismiss the payment UI
}, []);

<AdyenCheckout
  config={configuration}
  paymentMethods={paymentMethods}
  onSubmit={onSubmit}
  onAdditionalDetails={onAdditionalDetails}
  onError={onError}
>
  <MyCheckoutView />
</AdyenCheckout>;

Handling Actions

Some payment methods require additional action from the shopper such as: to scan a QR code, to authenticate a payment with 3D Secure, or to log in to their bank's website to complete the payment. To handle these additional front-end challenges, use nativeComponent.handle(action) from onSubmit callback.

const handleSubmit = (paymentData, nativeComponent) => {
  server.makePayment(paymentData)
    .then((response) => {
      if (response.action) {
        nativeComponent.handle(response.action);
      } else {
        nativeComponent.hide(response.result);
      }
    });
};

<AdyenCheckout
  ...
  onSubmit={handleSubmit}
  >
    ...
</AdyenCheckout>

Standalone Action handling

In case of API-only integration AdyenAction.handle could be used. Before you begin, make sure you follow all iOS integration and Android integration steps.

Example:

import { AdyenAction } from '@adyen/react-native';

const data = await AdyenAction.handle(apiResponse.action, { environment: 'test', clientKey: '{YOUR_CLIENT_KEY}');
result = await ApiClient.paymentDetails(data);

Documentation

Contributing

We strongly encourage you to join us in contributing to this repository so everyone can benefit from:

  • New features and functionality
  • Resolved bug fixes and issues
  • Any general improvements

Read our contribution guidelines to find out how.

Support

If you have a feature request, or spotted a bug or a technical problem, create a GitHub issue. For other questions, contact our Support Team via Customer Area or via email: [email protected]

License

MIT license. For more information, see the LICENSE file.

版本与发布记录

@adyen/react-native 共发布 44 个版本,首次发布于 2022/03/11;过去 12 个月发布了 8 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.14.0latest2026/11/023 天前
2.13.02026/10/1620 天前
2.12.02026/07/133 个月前
2.11.12026/06/025 个月前
2.11.02026/05/135 个月前
2.10.02026/04/216 个月前

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

@adyen/react-native 是什么?

Wraps Adyen Checkout Drop-In and Components for iOS and Android for convenient use with React Native

如何安装 @adyen/react-native?

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

@adyen/react-native 支持 TypeScript 吗?

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

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

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

@adyen/react-native 可以商用吗?

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

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

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

@adyen/react-native 还在维护吗?

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