npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@react-native-hero/alipay

v0.0.6

Published

react native alipay

Downloads

4

Readme

@react-native-hero/alipay

封装支付宝 SDK,支持授权登录、支付功能。

Getting started

Install the library using either Yarn:

yarn add @react-native-hero/alipay

or npm:

npm install --save @react-native-hero/alipay

Link

  • React Native v0.60+

For iOS, use cocoapods to link the package.

run the following command:

$ cd ios && pod install

For android, the package will be linked automatically on build.

  • React Native <= 0.59

run the following command to link the package:

$ react-native link @react-native-hero/alipay

Setup

iOS

修改 AppDelegate.m

// 导入库
#import <RNTAlipay.h>

// 添加此方法
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
            options:(NSDictionary<NSString*, id> *)options {
  // 确保 alipay 最先执行
  if ([RNTAlipay handleOpenURL:application openURL:url options:options]) {
    return YES;
  }
  // 其他库要求实现的 openURL 代码放在 alipay 后面,如果没有用到其他库,直接返回 YES 即可
  return YES;
}

Usage

import {
  auth,
  pay,
} from '@react-native-hero/alipay'


// 授权登录(一般透传后端传来的参数,不用管它是什么意思)
pay({
  authString: 'authString',
  // ios 需传入 appScheme
  // appScheme 为 app 在 info.plist 注册的 scheme
  appScheme: 'appScheme',
})
.then(response => {
  /**
   * 支付成功
   * 示例 data 如下
   * {
      "success": "true",
      "auth_code": "d9d1b5acc26e461dbfcb6974c8ff5E64",
      "result_code": "200",
      "user_id": "2088003646494707"
     }
   */
  response.data
})
.catch(response => {
  // 授权失败
  // code(number 类型) 可能的值如下:
  // 4000: 系统异常。
  // 6001: 用户中途取消。
  // 6002: 网络连接出错。
  response.code
  response.msg
})

// 支付(一般透传后端传来的参数,不用管它是什么意思)
pay({
  orderString: 'orderString',
  // ios 需传入 appScheme
  // appScheme 为 app 在 info.plist 注册的 scheme
  appScheme: 'appScheme',
})
.then(response => {
  /**
   * 支付成功
   * 示例 data 如下
   * {
        "alipay_trade_app_pay_response":{
            "code":"10000",
            "msg":"Success",
            "app_id":"2014072300007148",
            "out_trade_no":"081622560194853",
            "trade_no":"2016081621001004400236957647",
            "total_amount":"9.00",
            "seller_id":"2088702849871851",
            "charset":"utf-8",
            "timestamp":"2016-10-11 17:43:36"
        },
        "sign":"NGfStJf3i3ooWBuCDIQSumOpaGBcQz+aoAqyGh3W6EqA/gmyPYwLJ2REFijY9XPTApI9YglZyMw+ZMhd3kb0mh4RAXMrb6mekX4Zu8Nf6geOwIa9kLOnw0IMCjxi4abDIfXhxrXyj********",
        "sign_type":"RSA2"
    }
   */
  response.data
})
.catch(response => {
  // 支付失败
  // code(number 类型) 可能的值如下:
  // 8000: 正在处理中,支付结果未知(有可能已经支付成功),请查询商家订单列表中订单的支付状态。
  // 4000: 订单支付失败。
  // 5000: 重复请求。
  // 6001: 用户中途取消。
  // 6002: 网络连接出错。
  // 6004: 支付结果未知(有可能已经支付成功),请查询商家订单列表中订单的支付状态。
  response.code
  response.msg
})