Need to read/decode Payment and Txn_id from enrol paypal ipn

Need to read/decode Payment and Txn_id from enrol paypal ipn

by Cal Stan -
Number of replies: 4

Hi everyone,

 I am using Moodle 3.1.1 which works well. The Paypal sign up process works well too.

I need help to make my Affiliate Program (hosted on my same domain) capture payments and transaction data from the Paypal IPN : I would like to know how to Read/Copy/Convert or Access the "$data->payment_gross" , and "$data->Txn_id" from the Paypal IPN. I tried many approaches but no success. When I substitute $data->payment_gross for $txn_id, and $data->Txn_id for Txn_id in line below it does not work.

This is the line of code the that I need to put into the IPN to activate the Affiliate system:

file_get_contents("http://www.my_affiliate_site.org/affiliates/sale/amount/$mc_gross/trans_id/$txn_id/tracking_code/" . $_COOKIE['jamcom']);

I truly appreciate your help. (because for many Months I have been unsuccessful at trying many different methods. I am not an expert in PHP, I am a beginner)

Thanks,
Cal

Average of ratings: -
In reply to Cal Stan

Re: Need to read/decode Payment and Txn_id from enrol paypal ipn

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

I do suspect the trouble is related to the use of file_get_contents and/or cookie.

Did you try curl ?

In reply to Renaat Debleu

Re: Need to read/decode Payment and Txn_id from enrol paypal ipn

by Cal Stan -

I do not know anything much about curl.

In reply to Renaat Debleu

Re: Need to read/decode Payment and Txn_id from enrol paypal ipn

by Cal Stan -

The IPN still does not respond to output anything.

I tried CURL, Session and also Header and I still did not get any response posted to my data capture page.

I even tried those codes at the beginning of the IPN php (line 2) and get no output result to my capture page (but the student registration to moodle went ok).

see below for one of the codes I tried

I really need some help.

       ____________________________________

// cURL code for activating Affiliate $ Payment and Txn Id

$url = 'http://www.my_affiliates_data_receiving_page.php';
$fields = array(
   
    'mc_gross' => urlencode($_POST['mc_gross']),
    'txn_id' => urlencode($_POST['txn_id'])
);

//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);

//execute post
$result = curl_exec($ch);

//close connection
curl_close($ch);


In reply to Cal Stan

Re: Need to read/decode Payment and Txn_id from enrol paypal ipn

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I am struggling to see how this relates to Moodle...