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-s-alipay

v1.0.8

Published

React Native 支付宝模块,同时支持ios和android,react native 0.60.0+ autolink

Downloads

10

Readme

react-native-s-alipay

React Native 支付宝模块,同时支持ios和android,react native 0.60.0+ autolink

安装

npm install react-native-s-alipay --save

或者

yarn add react-native-s-alipay

配置

如果你的react native >= 0.60.0,那么你不需要做太多的配置。

Android:

android需要在android -> app -> build.gradle中配置lib包的引用:

...
repositories {
    flatDir {
        dirs project(':react-native-s-alipay').file('libs')
    }
}
...

ios:

第一步:

ios需要在ios项目的Podfile中加入支付宝依赖包的引用:

pod 'AlipaySDK-iOS'

然后运行命令:

cd ios && pod install

第二步:

等待安装成功后,进入ios工程文件夹,会看到一个.xcworkspace 结尾的文件 ,双击打开 在这里插入图片描述

第三步:

选中项目,右键添加文件 在这里插入图片描述 点击找到本项目node_modules下的react-native-s-alipay -> iosLib -> RNSAlipay, 将整个RNSAlipay文件夹导入。

第四步:

在AppDelegate.m文件中添加以下两个方法,来处理跳转的url:

头部引用:

#import "RNSAlipayManager.h"
- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
    
    if ([url.host isEqualToString:@"safepay"]) {
        //跳转支付宝钱包进行支付,处理支付结果
        [RNSAlipayManager handleCallback:url];
    }
    return YES;
}

// NOTE: 9.0以后使用新API接口
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options
{
    if ([url.host isEqualToString:@"safepay"]) {
        //跳转支付宝钱包进行支付,处理支付结果
        [RNSAlipayManager handleCallback:url];
    }
    return YES;
}

第五步:

添加url type: 在这里插入图片描述 到此支付宝配置结束。

使用

import Alipay from 'react-native-s-alipay';

//orderInfo由后端返回
Alipay.pay(orderInfo).then(
  res => {
    console.log('success:', res);
  },
  res => {
    console.log('fail:', res);
  },
);