48 lines
1.7 KiB
JavaScript
48 lines
1.7 KiB
JavaScript
import React, { Component } from 'react';
|
|
import { Button, StyleSheet, Text, View } from 'react-native';
|
|
import Alipay from 'react-native-uiwjs-alipay';
|
|
|
|
export default class App extends Component {
|
|
componentDidMount() {
|
|
Alipay.setAlipayScheme('ap2021001172656340');
|
|
}
|
|
aliPay = () => {
|
|
const payInfo = 'app_id=2021001172656340&biz_content=%7B%22timeout_express%22%3A%2230m%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%2C%22total_amount%22%3A%220.01%22%2C%22subject%22%3A%221%22%2C%22body%22%3A%22%E6%88%91%E6%98%AF%E6%B5%8B%E8%AF%95%E6%95%B0%E6%8D%AE%22%2C%22out_trade_no%22%3A%22IQJZSRC1YMQB5HU%22%7D&charset=utf-8&format=json&method=alipay.trade.app.pay¬ify_url=http%3A%2F%2Fdomain.merchant.com%2Fpayment_notify&sign_type=RSA2×tamp=2016-08-25%2020%3A26%3A31&version=1.0&sign=cYmuUnKi5QdBsoZEAbMXVMmRWjsuUj%2By48A2DvWAVVBuYkiBj13CFDHu2vZQvmOfkjE0YqCUQE04kqm9Xg3tIX8tPeIGIFtsIyp%2FM45w1ZsDOiduBbduGfRo1XRsvAyVAv2hCrBLLrDI5Vi7uZZ77Lo5J0PpUUWwyQGt0M4cj8g%3D';
|
|
Alipay.alipay(payInfo, (resule) => {
|
|
console.log(resule)
|
|
});
|
|
}
|
|
render() {
|
|
return (
|
|
<View style={styles.container}>
|
|
<Text style={styles.welcome}>☆Alipay Example☆</Text>
|
|
<Button
|
|
onPress={this.aliPay}
|
|
title="支付宝支付"
|
|
color="#841584"
|
|
accessibilityLabel="Learn more about this purple button"
|
|
/>
|
|
</View>
|
|
);
|
|
}
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
container: {
|
|
flex: 1,
|
|
justifyContent: 'center',
|
|
alignItems: 'center',
|
|
backgroundColor: '#F5FCFF',
|
|
},
|
|
welcome: {
|
|
fontSize: 20,
|
|
textAlign: 'center',
|
|
margin: 10,
|
|
},
|
|
instructions: {
|
|
textAlign: 'center',
|
|
color: '#333333',
|
|
marginBottom: 5,
|
|
},
|
|
});
|