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

rn-alipay-duang

v0.2.0

Published

react native支付宝移动支付模块

Downloads

143

Readme

rn-alipay

react-native 支付宝手机支付模块

安装

##iOS

  1. npm install rn-alipay --save
  2. 在XCode中右击项目的 Libraries 文件夹 ➜ Add Files to
  3. 进入 node_modulesrn-alipayios ➜ 选择 RNAlipay.xcodeproj
  4. 展开RNAlipay.xcodeprojProducts➜ 添加 libRNAlipay.aBuild Phases -> Link Binary With Libraries
  5. Build Phases选项卡的Link Binary With Libraries中,点击“+”号增加以下依赖:
  6. RNAlipay.xcodeprojAlipaySDK.frameworklibssl.alibcrypto.a文件拖入复制到项目文件夹下:
  7. 编译运行

##Android

  • npm install rn-alipay-duang --save
// file: android/settings.gradle
...
include ':rn-alipay-duang'  // <- add
project(':rn-alipay-duang').projectDir = new File(settingsDir, '../node_modules/rn-alipay-duang/android')  // <- add
// file: android/app/build.gradle
...
dependencies {
		...
		compile project(':rn-alipay-duang')  // <- add
}
  • 注册模块
  • 对于 react-native 版本低于 0.19.0 (use cat ./node_modules/react-native/package.json | grep version)
// file: MainActivity.java
import com.alipay.RNAlipayPackage;  // <- import

public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {

  ...

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mReactRootView = new ReactRootView(this);

    mReactInstanceManager = ReactInstanceManager.builder()
      .setApplication(getApplication())
      .setBundleAssetName("index.android.bundle")
      .setJSMainModuleName("index.android")
      .addPackage(new MainReactPackage())
      .addPackage(new RNAlipayPackage())      // <- add package
      .setUseDeveloperSupport(BuildConfig.DEBUG)
      .setInitialLifecycleState(LifecycleState.RESUMED)
      .build();

    mReactRootView.startReactApplication(mReactInstanceManager, "ExampleRN", null);

    setContentView(mReactRootView);
  }

  ...

}
  • 对于 react-native 0.19.0及以上版本
// file: MainActivity.java
	...
import com.alipay.RNAlipayPackage;//<- import package

public class MainActivity extends ReactActivity {

   /**
   * A list of packages used by the app. If the app uses additional views
   * or modules besides the default ones, add more packages here.
   */
    @Override
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
            new MainReactPackage(), //<- Add comma
            new RNAlipayPackage() //<- Add package
        );
    }
...
}
  • 对于 react-native 0.29.0及以上版本
// file: MainApplication.java
	...
import com.alipay.RNAlipayPackage;//<- import package

public class MainApplication extends Application implements ReactApplication {

   ...
    @Override
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
            new MainReactPackage(), //<- Add comma
            new RNAlipayPackage() //<- Add package
        );
    }
...
}
  • 安卓部分实现参考https://github.com/szq4119/react-native-alipay

##使用说明

  1. 导入模块
const Alipay = require('rn-alipay-duang');
  1. 基本使用
// 为了安全起见,在生产环境中需把签名放在服务端完成 服务端返回josn格式的 订单信息 及签名服务端返回以下数据
const privateKey = 'MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAN0yqPkLXlnhM+2H/57aHsYHaHXazr9pFQun907TMvmbR04wHChVsKVgGUF1hC0FN9hfeYT5v2SXg1WJSg2tSgk7F29SpsF0I36oSLCIszxdu7ClO7c22mxEVuCjmYpJdqb6XweAZzv4Is661jXP4PdrCTHRdVTU5zR9xUByiLSVAgMBAAECgYEAhznORRonHylm9oKaygEsqQGkYdBXbnsOS6busLi6xA+iovEUdbAVIrTCG9t854z2HAgaISoRUKyztJoOtJfI1wJaQU+XL+U3JIh4jmNx/k5UzJijfvfpT7Cv3ueMtqyAGBJrkLvXjiS7O5ylaCGuB0Qz711bWGkRrVoosPM3N6ECQQD8hVQUgnHEVHZYtvFqfcoq2g/onPbSqyjdrRu35a7PvgDAZx69Mr/XggGNTgT3jJn7+2XmiGkHM1fd1Ob/3uAdAkEA4D7aE3ZgXG/PQqlm3VbE/+4MvNl8xhjqOkByBOY2ZFfWKhlRziLEPSSAh16xEJ79WgY9iti+guLRAMravGrs2QJBAOmKWYeaWKNNxiIoF7/4VDgrcpkcSf3uRB44UjFSn8kLnWBUPo6WV+x1FQBdjqRviZ4NFGIP+KqrJnFHzNgJhVUCQFzCAukMDV4PLfeQJSmna8PFz2UKva8fvTutTryyEYu+PauaX5laDjyQbc4RIEMU0Q29CRX3BA8WDYg7YPGRdTkCQQCG+pjU2FB17ZLuKRlKEdtXNV6zQFTmFc1TKhlsDTtCkWs/xwkoCfZKstuV3Uc5J4BNJDkQOGm38pDRPcUDUh2/';
const data = {
    privateKey,
    partner: '2088302277569230',
    seller: '12312341234',
    outTradeNO: '1231231231231', //订单ID(由商家自行制定)
    subject: '测试商品标题', //商品标题
    body: '测试产品描述', //商品描述
    totalFee: '1', //商品价格
    notifyURL: 'http://www.baidu.com"', //回调URL
    service: 'mobile.securitypay.pay',
    paymentType: '1',
    inputCharset: 'utf-8',
    itBPay: '30m',
    showURL: 'm.alipay.com',
    appSchemeIOS: 'testapp20', //应用注册scheme,在AlixPayDemo-Info.plist定义URL types
};
Alipay.pay(data).then((msg) => {
    console.log(msg);
}, (e) => {
    console.log(e);
});
  1. For Global Alipay https://global.alipay.com/product/mobilepayments.htm
// 为了安全起见,在生产环境中需把签名放在服务端完成 服务端返回josn格式的 订单信息 及签名服务端返回以下数据
const privateKey = 'MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAN0yqPkLXlnhM+2H/57aHsYHaHXazr9pFQun907TMvmbR04wHChVsKVgGUF1hC0FN9hfeYT5v2SXg1WJSg2tSgk7F29SpsF0I36oSLCIszxdu7ClO7c22mxEVuCjmYpJdqb6XweAZzv4Is661jXP4PdrCTHRdVTU5zR9xUByiLSVAgMBAAECgYEAhznORRonHylm9oKaygEsqQGkYdBXbnsOS6busLi6xA+iovEUdbAVIrTCG9t854z2HAgaISoRUKyztJoOtJfI1wJaQU+XL+U3JIh4jmNx/k5UzJijfvfpT7Cv3ueMtqyAGBJrkLvXjiS7O5ylaCGuB0Qz711bWGkRrVoosPM3N6ECQQD8hVQUgnHEVHZYtvFqfcoq2g/onPbSqyjdrRu35a7PvgDAZx69Mr/XggGNTgT3jJn7+2XmiGkHM1fd1Ob/3uAdAkEA4D7aE3ZgXG/PQqlm3VbE/+4MvNl8xhjqOkByBOY2ZFfWKhlRziLEPSSAh16xEJ79WgY9iti+guLRAMravGrs2QJBAOmKWYeaWKNNxiIoF7/4VDgrcpkcSf3uRB44UjFSn8kLnWBUPo6WV+x1FQBdjqRviZ4NFGIP+KqrJnFHzNgJhVUCQFzCAukMDV4PLfeQJSmna8PFz2UKva8fvTutTryyEYu+PauaX5laDjyQbc4RIEMU0Q29CRX3BA8WDYg7YPGRdTkCQQCG+pjU2FB17ZLuKRlKEdtXNV6zQFTmFc1TKhlsDTtCkWs/xwkoCfZKstuV3Uc5J4BNJDkQOGm38pDRPcUDUh2/';
const data = {
    privateKey,
    partner: '2088302277569230',
    seller: '12312341234',
    outTradeNO: '1231231231231', //订单ID(由商家自行制定)
    subject: '测试商品标题', //商品标题
    body: '测试产品描述', //商品描述
    totalFee: '1', //商品价格
    notifyURL: 'http://www.baidu.com"', //回调URL
    service: 'mobile.securitypay.pay',
    paymentType: '1',
    inputCharset: 'utf-8',
    itBPay: '30m',
    showURL: 'm.alipay.com',
    appSchemeIOS: 'testapp20', //应用注册scheme,在AlixPayDemo-Info.plist定义URL types
		outContext: { // Additional args for global alipay
	      currency: 'USD',
	      forex_biz: 'FP',
    },
};
Alipay.pay(data).then((msg) => {
    console.log(msg);
}, (e) => {
    console.log(e);
});

##参考支付宝文档

##Demo https://github.com/huangzuizui/rn-alipay-demo