React Native Module for alipay.com
npm install react-native-yunpeng-alipay --save
rnpm link react-native-yunpeng-alipay
- android/settings.gradle
include ':react-native-yunpeng-alipay'
project(':react-native-yunpeng-alipay').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-yunpeng-alipay/android')
- android/app/build.gradle
dependencies {
compile project(':react-native-yunpeng-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
);
}
}
rnpm link react-native-yunpeng-alipay
Link
AlipayModule
library from yournode_modules/react-native-yunpeng-alipay/ios
folder like its described here. Don't forget to add it to "Build Phases" of project.
-
Added the following libraries to your "Link Binary With Libraries":
- CoreMotion.framework
- CoreTelephony.framework
- libc++
- libz
-
add
URL Schema
as your app id forURL type
inTargets - 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;
}
import Alipay from 'react-native-yunpeng-alipay';
Alipay.pay("signed pay info string").then(function(data){
console.log(data);
}, function (err) {
console.log(err);
});