1.0.3 • Published 7 years ago
rn-alipay-phillip v1.0.3
rn-alipay-phillip
React Native Module for alipay.com
install
npm install rn-alipay-phillip --save
or
yarn add rn-alipay-phillipAndroid
With link
react-native link react-native-yunpeng-alipayManually
- android/settings.gradle
include ':rn-alipay-phillip'
project(':rn-alipay-phillip').projectDir = new File(rootProject.projectDir, '../node_modules/rn-alipay-phillip/android')- android/app/build.gradle
dependencies {
compile project(':rn-alipay-phillip')
}- 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 link
react-native link rn-alipay-phillipManually
Link
AlipayModulelibrary from yournode_modules/rn-alipay-phillip/iosfolder 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":
- CoreMotion.framework
- CoreTelephony.framework
- libc++
- libz
add
URL Schemaas your app id forURL typeinTargets - 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 'rn-alipay-phillip';Alipay.pay("signed pay info string").then(function(data){
console.log(data);
}, function (err) {
console.log(err);
});
Alipay.authLogin("signed pay info string").then(function(data){
console.log(data);
}, function (err) {
console.log(err);
});