![](/img/trans.png)
[英].then(result) block not executing after paytm payment successful. in react native
[英]how to navigate to next screen after successful of paytm payment transaction. in react native
我正在 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");
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.