Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

react-native-alipay

> 前端框架
Open source

Alipay SDK for React Native. Support RN >= 0.47.

197 stars0 likes3 views
WebsiteGitHub

About

Alipay SDK for React Native. Support RN >= 0.47.

react-native-alipay

Alipay SDK for React Native. Support mobile webpage url payment. Support RN >= 0.47.

Native AlipaySDK library (download page):

  • iOS: v15.5.9 (2018.11.26)
  • Android: v15.5.9 (2018.11.26)

Features

  • 快捷登录授权( https://docs.open.alipay.com/218/105327/ )
  • APP支付( https://docs.open.alipay.com/204/105465/ )
  • 手机网站转APP支付( https://docs.open.alipay.com/204/105695/ )
  • 参数签名( https://docs.open.alipay.com/291/106118/ )

Requirement

  • React Native >= 0.20
  • iOS >= 7.0
  • Android >= 4.4 (API 19)

Getting started

$ yarn add @0x5e/react-native-alipay

Native module installation

  • iOS Setup
  • Android Setup

API Documentation

Alipay.authWithInfo(infoStr)

  • infoStr {String} Auth request info in query string format. Must be signed before use. See Auth request params description.

Returns object with following fields:

field type description
resultStatus String See Response code description
result String Result data in query string format
memo String Reserved field, nothing

The result data has following fields:

field type description
success Boolean true if succeed
result_code String Result code
auth_code String Authorization code
user_id String User id

The result_code description:

code description
200 业务处理成功,会返回authCode
202 系统异常,请稍后再试或联系支付宝技术支持
1005 账户已冻结,如有疑问,请联系支付宝技术支持

Example code:

…

Alipay.setAlipaySandbox(isSandbox)

  • isSandbox {boolean} Whether to open sandbox. Must be payed before use. See 使用沙箱环境

Alipay.pay(orderStr)

  • orderStr {String} Order info in query string format. Must be signed before use. See App payment request params description.

Returns object with following fields:

field type description
resultStatus String See Response code description
result String Result data in json string format
memo String Reserved field, nothing

The result data has following fields:

field type description
code String 结果码,具体见公共错误码
msg String 处理结果的描述,信息来自于code返回结果的描述
app_id String 支付宝分配给开发者的应用Id
out_trade_no String 商户网站唯一订单号
trade_no String 该交易在支付宝系统中的交易流水号
total_amount String 该笔订单的资金总额,单位为RMB-Yuan
seller_id String 收款支付宝账号对应的支付宝唯一用户号
charset String 编码格式
timestamp String 时间

Example code:

…

Alipay.payInterceptorWithUrl(h5PayUrl)

  • h5PayUrl {String} The url string of mobile webpage payment. You may get it from webview. See document for detail.

Returns object with following fields:

field type description
resultCode String 返回码
returnUrl String 支付结束后应当跳转的url地址

Example code:

javascript
import Alipay from '@0x5e/react-native-alipay';

// 手机网站转APP支付
try {
  let h5PayUrl = 'https://wappaygw.alipay.com/service/rest.htm?_input_charset=utf-8&format=xml&partner=xxxx&req_data=%3Cauth_and_execute_req%3E%3Crequest_token%3Exxxx%3C%2Frequest_token%3E%3C%2Fauth_and_execute_req%3E&sec_id=MD5&service=alipay.wap.auth.authAndExecute&v=2.0&sign=xxxx'; // get from webview, signed
  let { resultCode, returnUrl } = await Alipay.payInterceptorWithUrl(h5PayUrl);
  console.info(resultCode, returnUrl);
} catch (error) {
  console.error(error);
}

Alipay.sign(object, privateKey)

If you want to do client side signature instead of server side (not recommend), you can use this.

  • object {Object} Object to be signed. The object.sign_type can specify RSA (default) or RSA2.
  • privateKey {String} Private key in PKCS#1 or PKCS#8 format.

Note: PKCS#1 private key should have wrapped with -----BEGIN RSA PRIVATE KEY----- and -----END RSA PRIVATE KEY----- PKCS#8 private key should have wrapped with -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY-----

Returns The query string with signature. See Process of signature for detail.

Example code:

…

Response code description

code description
9000 操作成功
8000 正在处理中
4000 操作失败
5000 重复请求
6001 用户中途取消
6002 网络连接出错

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScriptalipayalipaysdkandroidios

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架