简体   繁体   English

Flutterwave 支付 API 与 PHP 和 Mysql 集成

[英]Flutterwave payment API integration with PHP and Mysql

How do I update mysql db payment status from pending to success in the flutterwave api please find the code snippet below.如何在 Flutterwave api 中将 mysql db 支付状态从挂起更新为成功,请在下面找到代码片段。 the db connection is included from a controller.php file db 连接包含在 controller.php 文件中

<php? <php?

if($amountPaid >= $amountToPay) {如果($amountPaid >= $amountToPay){

                echo 'Payment successful';

                //* Continue to give item to the user
                $res = json_decode($response);
                $array= json_decode($response,true);
               
            $payment_id = $array["data"]["id"];
            $transaction_amount = $array["data"]["amount"];
            $payment_status = $array["status"];
            $tx_ref = $array["data"]["tx_ref"];
            
      
            $query3 = "UPDATE transaction_details SET payment_id=$payment_id , payment_status= 
            $payment_status WHERE tx_ref=$tx_ref";
            

            if ($conn->query($query3) === TRUE) {
              echo "Record updated successfully";
            } else {
              echo "Error updating record: " . $conn->error;
            }
            
            $conn->close();
                
     
                
             
                 header('location: congratulations.php');
             }  else {
                echo 'unusual transaction detected';
            }
          
    }else
    {
        echo 'Can not process payment';
    }
}

}?> }?>

Ok thanks everyone just figured it out.好的,谢谢大家刚刚想通了。 Had the problem because I sort of mixed up my coding styles using OOP and procedural in same codelines.有这个问题是因为我在相同的代码行中使用 OOP 和程序混淆了我的编码 styles。 solved it by using mysqli procedural prepared statement.通过使用 mysqli 过程准备语句解决了它。 This helped me to bind the variables to mysql db fields这帮助我将变量绑定到 mysql 数据库字段

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM