我在我的网站使用cashfree支付网关,它的工作正常,但我不知道如何获得cashfree交易的响应,我使用的重定向链接是https://payments-test.cashfree.com/order/orderToken打开cashfree用户界面,所以帮助我和我的代码在这里...
import React from 'react';
import { useState, useEffect } from 'react';
import { connect } from "react-redux";
import { cash_data } from "../../../../store/Action/UserFatchData";
import { dropinComponents } from "./dropinComponents.js";
const Cashfree1 = ({ dispatch, res }) => {
const [orderToken, setOrderToken] = useState("3D3S3KLoiTRp9lVwzUvo");
const [components, setComponents] = useState([]);
const [payment, setpayment] = useState({
order_id: "4158",
order_amount: 15.00,
order_currency: "INR",
order_note: "Additional order info",
customer_details: {
customer_id: "12345",
customer_email: "abc@cashfree.com",
customer_phone: "9816512345"
}
})
useEffect(() => {
let comp = []
dropinComponents.map((name, index) => {
return (
comp.push(name.id)
)
})
setComponents(comp)
// dispatch(cash_data(payment))
window.location.href = "https://payments-test.cashfree.com/order/#3D3S3KLoiTRp9lVwzUvo"
}, [])
return (
<>
</>
)
}
const mapStateToProps = (state) => ({
res: state.Cash,
});
export default connect(mapStateToProps)(Cashfree1);
1条答案
按热度按时间6ioyuze21#
要获得响应,首先你必须添加一个返回URL,如下所示
完成后,Cashfree将使用
order_id
和order_token
作为URL的一部分将用户重定向到上面。然后您应该调用https://sandbox.cashfree.com/pg/orders/order_token
来获取交易和订单状态。阅读更多here