gpt4 book ai didi

javascript - react native Stripe 支付网关

转载 作者:行者123 更新时间:2023-11-29 15:12:25 25 4
gpt4 key购买 nike

我正在使用 React Native 实现 Stripe 支付网关,我正在使用 react-native-stripe-api

import React, { Component } from "react";
import {
Text,
View,
Image,
TouchableOpacity,
I18nManager,
AsyncStorage,

} from "react-native";
import {
Container,
Right,
Item,
Input,
Header,
Left,
Body,
Title,
Form
} from "native-base";
import FontAwesome from "react-native-vector-icons/FontAwesome";
import Ionicons from "react-native-vector-icons/Ionicons";
// Screen Styles
import styles from "../Theme/Styles/Signin";
import Logo from "../image/qualpros.png";
import axios from "axios";
import AwesomeAlert from "react-native-awesome-alerts";
import Stripe from "react-native-stripe-api";

class Stripedemo extends Component {
static navigationOptions = {
header: null,
showAlert: false,
message: ""
};

state = {
data: [],
number: null,
expmonth: null,
expyear: null,
cvc: null
};



payme(comp) {

var cardDetails = {
"card[number]": "4242424242424242",
"card[exp_month]": "09",
"card[exp_year]": "2023",
"card[cvc]": "123"
};

var formBody = [];
for (var property in cardDetails) {
var encodedKey = encodeURIComponent(property);
var encodedValue = encodeURIComponent(cardDetails[property]);
formBody.push(encodedKey + "=" + encodedValue);
}
formBody = formBody.join("&");

return fetch('https://api.stripe.com/v1/tokens', {
method: 'post',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Bearer ' + '<My_Secret_key>'
},
body: formBody
});

}

constructor(props) {
super(props);
this.state = { showAlert: false };
}

showAlert = () => {
this.setState({
showAlert: true
});
};

hideAlert = () => {
this.setState({
showAlert: false
});
};

render() {
return (
<Container>
<Header style={styles.header}>
<Left style={styles.left}>
<TouchableOpacity
style={styles.backArrow}
onPress={() => this.props.navigation.navigate("ProfileScreen")}
>
<FontAwesome
name={I18nManager.isRTL ? "angle-right" : "angle-left"}
size={30}
color="#6f6f6f"
/>
</TouchableOpacity>
</Left>
<Body style={styles.body} />
<Right style={styles.right} />
</Header>
<View style={styles.logosec}>
<Image source={Logo} style={styles.logostyle} />
</View>
<Form style={styles.form}>
<Item rounded style={styles.inputStyle}>
<Input
textAlign={I18nManager.isRTL ? "right" : "left"}
placeholder="number"
value={"4242 4242 4242 4242"}
style={styles.inputmain}
onChangeText={number => {
this.setState({ number });
}}
autoCapitalize="none"
/>
</Item>
<Item rounded style={styles.inputStyle}>
<Input
textAlign={I18nManager.isRTL ? "right" : "left"}
placeholder="expmonth"
value={"09"}
style={styles.inputmain}
onChangeText={expmonth => {
this.setState({ expmonth });
}}
autoCapitalize="none"
/>
</Item>
<Item rounded style={styles.inputStyle}>
<Input
textAlign={I18nManager.isRTL ? "right" : "left"}
placeholder="expyear"
value={"18"}
style={styles.inputmain}
onChangeText={expyear => {
this.setState({ expyear });
}}
autoCapitalize="none"
/>
</Item>
<Item rounded style={styles.inputStyle}>
<Input
textAlign={I18nManager.isRTL ? "right" : "left"}
placeholder="cvc"
value={"111"}
style={styles.inputmain}
onChangeText={cvc => {
this.setState({ cvc });
}}
autoCapitalize="none"
/>
</Item>

<TouchableOpacity
info
style={styles.signInbtn}
onPress={this.payme.bind(this)}
>
<Text autoCapitalize="words" style={styles.buttongetstarted}>
Add Card
</Text>
</TouchableOpacity>
</Form>
<View style={styles.bottomView} />

<AwesomeAlert
show={this.state.showAlert}
showProgress={false}
title="QualPros!"
message={this.state.message}
closeOnTouchOutside={true}
closeOnHardwareBackPress={false}
showConfirmButton={true}
confirmText="Ok"
confirmButtonColor="#d91009"
onConfirmPressed={() => {
this.hideAlert();
}}
/>
</Container>
);
}
}
export default Stripedemo;

上面是我的代码。

我从这段代码中收到错误 404,并且我已经按照示例中所示的相同方式实现了。

我不介意尝试微不足道的图书馆,但我想要使用信用卡和借记卡进行 Stripe 支付,而不是使用 Apple Pay 或 Goolge Pay。

第一次来,请指导

最佳答案

Tipsy 是推荐的[1] Stripe API 集成第 3 方库,它确实支持 token 化信用卡 [0]。

由于 PCI 合规性要求[2],不建议您直接调用标记化 URL,而是使用 Stripe 提供的移动 SDK[3],而 tipsi 是在此基础上构建的。

关于javascript - react native Stripe 支付网关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53003828/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com