alipay and aliAuth module for react native from phillip
npm install rn-alipay-phillip
npm install rn-alipay-phillip --save
or
yarn add rn-alipay-phillip
`
Android
$3
`
react-native link react-native-yunpeng-alipay
`
$3
* 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)
`java
...
import com.yunpeng.alipay.AlipayPackage; // <--- IMPORT
public class MainActivity extends ReactActivity {
...
@Override
protected List getPackages() {
return Arrays.asList(
new MainReactPackage(),
new AlipayPackage() // <--- ADD HERE
);
}
}
`
iOS
$3
`
react-native link rn-alipay-phillip
`
$3
> Link AlipayModule library from your node_modules/rn-alipay-phillip/ios folder like its described here. Don't forget to add it to "Build Phases" of project.
$3
* 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
`objective_c
#import "AlipayModule.h"
`
`objective_c
- (BOOL)application:(UIApplication )application openURL:(NSURL )url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
[AlipayModule handleCallback:url];
return YES;
}
`
$3
`javascript
import Alipay from 'rn-alipay-phillip';
`
`javascript
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);
});
``