Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
Hello KK,
I was able to successfully integrate a payment platform into my Couch powered website and got back a response. Now I need to use the response for some further processing but I keep getting an error from couch tag:
This is how I am doing it in Couch:
Code: Select all
<cms:php>
     $ref = "<cms:show tx_ref />";
     $trans_id = "<cms:show returned_transaction_id />";
     
     $query = array(
           "SECKEY" => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "tx_ref" => $ref
        );
     $data_string = json_encode($query);

    $curl = curl_init();

  curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.flutterwave.com/v3/transactions/" . $trans_id . "/verify",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_POSTFIELDS => $data_string,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
var_dump($response);
</cms:php>


But I keep getting this error:
Code: Select all
C:\Program Files (x86)\Ampps\www\dotmatrix\couch-admin\tags.php(3231) : eval()'d code:32:boolean false


What could I be doing wrong? Thank you
Hi,

I have mentioned this is several posts (e.g. viewtopic.php?f=2&t=9882#p22669), it is easier to debug raw PHP by placing the bulk of your code in a real PHP function - the <cms:php> Couch tag then serves to only call that function with the required params e.g. in your case -
Code: Select all
<?php
    // move all the relevant code to within a function (could be placed in kfunctions.php) ..
    function my_func( $ref, $trans_id ){
        $query = array(
           "SECKEY" => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "tx_ref" => $ref
        );
        ..
        ..
    }
?>

<cms:php>
    // invoke the function from within Couch ..
    my_func( '<cms:show tx_ref />', '<cms:show returned_transaction_id />' );
</cms:php>

This new arrangement should help you in debugging the problem (regarding which my guess is that the 'tx_ref' or 'returned_transaction_id' values are not getting set as expected).

Hope this helps,
Thanks KK. Your suggestion helped a lot.
3 posts Page 1 of 1