如何解决paytm付款交易成功后如何导航到下一个屏幕在反应原生
我正在 React Native API 中集成 paytm 交易。我已经成功地集成了它。我能够进行成功的交易。但交易成功后。来自 API 的一些数据显示在那里。像这样 = "[{"message":"success","is_payment_done":"Y"}]"。但问题是如何导航到交易成功后要显示的下一个。
这是我的代码
export default class payment extends Component {
constructor(props) {
super(props);
this.state = {
order_id: "",mid: "xxxxxxxxxxxxxxxxxxxxxxxx",tranxToken: "",amount: "20",// callbackUrl:
// "https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=TESTORDER_1",isstaging: true,appInvokeRestricted: true,};
}
call_api = () => {
fetch("https://xxxxxxx.in/App_API_CI/xxxxxxxxxx",{
method: "POST",headers: {
Accept: "application/json,text/plain,*/*","Content-Type": "application/json",},body: JSON.stringify([
{
mobile_no: "xxxxxxxxx",user_id: "xx",patient_name: "xxxxxxx",]),})
.then((returnValue) => returnValue.json())
.then((response) => {
console.log(
"this checksum api esponse" +
JSON.stringify(response[0].data.txnToken)
);
this.setState({ order_id: response[0].data.order_id });
this.setState({ tranxToken: response[0].data.txnToken });
this.handleTransaction();
});
};
handleTransaction = () => {
AllInOnesdkmanager.startTransaction(
this.state.order_id,this.state.mid,this.state.tranxToken,this.state.amount,"https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=" +
this.state.order_id,this.state.isstaging,this.state.appInvokeRestricted
)
.then((result) => {
() => console.log(result);
//AsyncStorage.setItem("is_payment_done","Y");
this.props.navigation.navigate("MyDrawerRP");
})
.catch((err) => {
console.log(err);
Toast.show("Something went wrong");
});
};
render() {
return (
<View style={{ alignSelf: "center",flex: 1,justifyContent: "center" }}>
<TouchableOpacity
onPress={this.call_api}
style={{
height: 90,width: width / 1.2,backgroundColor: "#7DF8F8",justifyContent: "center",elevation: 20,}}
>
<Text style={{ alignSelf: "center",fontSize: 35,color: "#000080" }}>
PAY 20/-
</Text>
</TouchableOpacity>
</View>
);
}
}
解决方法
this.props.navigation.navigate("MyDrawerRP");
这条线应该做你的导航。你确定你的代码在这里?即交易是否成功完成?如果是,请检查“MyDrawerRP”是否已添加到您的导航器中。
,你能否在获取结果后删除 ()=> 并测试你是否能够在日志中获取结果并继续检查导航
.then((result) => {
() => console.log(result); //remove () => here
//AsyncStorage.setItem("is_payment_done","Y");
this.props.navigation.navigate("MyDrawerRP");
})
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。