$ npm install react-native-sdk-payment --save
$ react-native react-native-sdk-payment
配置请参考支付宝开放文档
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-sdk-payment
and addRNPayment.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNPayment.a
,AlipaySDK.framework
to your project'sBuild Phases
➜Link Binary With Libraries
- In XCode, in the project navigator, select your project. Add
$(SRCROOT)/../node_modules/react-native-sdk-payment/ios/PaySdk
to your project'sBuild Settings
➜Framework Search Paths
- Run your project (
Cmd+R
)<
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.library.pay.RNPaymentPackage;
to the imports at the top of the file - Add
new RNPaymentPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-sdk-payment' project(':react-native-sdk-payment').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sdk-payment/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-sdk-payment')
import PaymentSDK from 'react-native-sdk-payment';
PaymentSDK.onPay(1,{ order:'123' },'appScheme',()=> {
console.log('成功回调');
},() => {
console.log('失败回调');
});