react-native-ythink-alipay

1.0.0 • Public • Published

react-native-ythink-alipay

React Native Module for alipay.com

install

npm install react-native-ythink-alipay --save

Android

With rnpm

rnpm link react-native-ythink-alipay

Manually

  • android/settings.gradle
include ':react-native-ythink-alipay'
project(':react-native-ythink-alipay').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-ythink-alipay/android')
  • android/app/build.gradle
dependencies {
    compile project(':react-native-ythink-alipay')
}
  • register module (in MainActivity.java)
...

import com.yunpeng.alipay.AlipayPackage; // <--- IMPORT

public class MainActivity extends ReactActivity {

    ...

    @Override
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            new AlipayPackage() // <--- ADD HERE
        );
    }
}

iOS

With rnpm

rnpm link react-native-ythink-alipay

Manually

Link AlipayModule library from your node_modules/react-native-ythink-alipay/ios folder like its described here. Don't forget to add it to "Build Phases" of project.

Config

  • Added the following libraries to your "Link Binary With Libraries":

    • [x] CoreMotion.framework
    • [x] CoreTelephony.framework
    • [x] libc++
    • [x] libz
  • add URL Schema as your app id for URL type in Targets - info

  • Make sure you have these code in AppDelegate.m to enable callback

#import "AlipayModule.h"
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
  [AlipayModule handleCallback:url];
  return YES;
}

General Usage

import Alipay from 'react-native-ythink-alipay';
Alipay.pay("signed pay info string").then(function(data){
                    console.log(data);
                }, function (err) {
                    console.log(err);
                });

Dependents (0)

Package Sidebar

Install

npm i react-native-ythink-alipay

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

9.23 MB

Total Files

23

Last publish

Collaborators

  • ythink