微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在我的本机应用程序中获取用户的虚拟付款地址

如何解决在我的本机应用程序中获取用户的虚拟付款地址

我已在我的应用程序中集成了本机支付。 RNUpiPayment组件在此处调用initializePayment方法,该方法仅为用户提供vpa。如何通过fecth api或任何其他方法数据库中的许多用户提供vpa地址?请提供任何方法或建议。

我的代码在这里

<TouchableOpacity
        style={styles.payBtn}
        activeOpacity={0.5}
        onPress={() => {
          RNUpiPayment.initializePayment(
            {
              vpa: '8856452125@ybl',// or can be john@ybl or mobileNo@upi
              payeeName: 'Stanlee',amount: '20',transactionRef: 'aasf-332-aoei-fn',},() => {
              console.log('Success');
            },() => {
              console.log('Failed');
            },);
        }}>
        <Text style={styles.payBtnTxt}>PAY</Text>
      </TouchableOpacity>

解决方法

Finally got it!

    DriverPaymentFunction = () => {
    const {DriverUPI} = this.state;
    const {DriverName} = this.state;

    fetch('http://ip/appname/payment.php',{
      method: 'POST',headers: {
        Accept: 'application/json','Content-Type': 'application/json',},body: JSON.stringify({
        upi_id: DriverUPI,driver: DriverName,}),})
      .then((response) => response.json())
      .then((responseJson) => {
        // If server response message same as Data Matched
        if (responseJson === 'Data Matched') {
          RNUpiPayment.initializePayment( //Payment API
                  {
                    vpa: DriverUPI,// or can be john@ybl or mobileNo@upi
                    payeeName: DriverName,amount: '0',transactionRef: 'AppName Ride Transaction',() => {
                    console.log('Success');
                  },() => {
                    console.log('Failed');
                  },);
        } else {
          Alert.alert(responseJson);
        }
      })
      .catch((error) => {
        console.error(error);
      });
  };

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。