redux reactjs中的无现金支付网关集成

qni6mghb  于 2023-04-21  发布在  React
关注(0)|答案(1)|浏览(129)

我在我的网站使用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);
6ioyuze2

6ioyuze21#

要获得响应,首先你必须添加一个返回URL,如下所示

{
    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"
    },
    order_meta: {
       return_url: "https://merchant.in/pg/process_return?cf_id={order_id}&cf_token={order_token}"
    }
  }

完成后,Cashfree将使用order_idorder_token作为URL的一部分将用户重定向到上面。然后您应该调用https://sandbox.cashfree.com/pg/orders/order_token来获取交易和订单状态。
阅读更多here

相关问题