Paypal, donor's email adres not sent.

  • Christian_Belgien
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
12 years 8 months ago #11134 by Christian_Belgien
Paypal, donor's email adres not sent. was created by Christian_Belgien
The request for paypal to process a payment is, as far as I can see, sent off from the class os_paypal function submitPost(). The request goes off with 22 parameters. One of these is "business" which contains the seller's email adress. Paypal seems to recognise this parameter as the seller's paypall account.

However, the email adres of the buyer, the donor, is not included in the 22 parameters. Donors must therefore, when they get the paypal page, fill in the email adres/paypal account.

Is there a parameter that paypal recognises as the buyer's paypal account? If so, I could expand os_paypal submitPost() with this parameter and fill it with the email adres the donor enters on the donation form.

I ask, because I am trying to (mis)use Joom Donation to process loans, which will eventually have to be reimbursed. I am aware that the email adres the donors show on the donation form are saved in #__jd_donors. But if it cannot be guaranteed that this is the email adres the donors use to identify themselves to paypal, then the reimbursement cannot be automated. The organisation must for each reimbursement examine their paypal account to get the paypal account of the donor to reimburse. (Or am I wrong?)

Please Log in or Create an account to join the conversation.

More
12 years 8 months ago #11145 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: Paypal, donor's email adres not sent.
Hi

You can modify the code of the file os_paypal.php alitle to send the email address of donor to Paypal . The steps are :

1. Find the function processPayment in the file (around line 102)

2. Add the line of code below before the line of code $this->submitPost(); :
Code:
$this->setParam('email', $row->email);

After that, everything should work as expected !

Regards,

Tuan

Please Log in or Create an account to join the conversation.

  • Christian_Belgien
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
12 years 8 months ago #11159 by Christian_Belgien
Replied by Christian_Belgien on topic Re: Paypal, donor's email adres not sent.
Tuan, thanks. But problems:

1. I have inserted the line of code as you said. Nevertheless, when I press the button 'Process donation' I get a paypal screen with (among others) a form for the donor to log in to the paypal account by filling in an email adress. Paypal does not use the email adress in the email parameter. It is thus possible that the the donor uses a different email for the paypal account than the in the table jd_donors. Do I have a wrong setup? Or had I not explained my problem properly (maybe is it not the purpose of the email parameter to be used to identify the donor's paypal account?) I have checked that the email parameter with the correct value is indeed included in the outgoing post in the following manner:

In os_paypal.php the function submitPost() I in the foreach ($this->_params as $key=>$val) loop I inserted this code:

foreach ($this->_params as $key=>$val)
{
echo "KEY = "; var_dump($key); echo " - VALUE = "; var_dump($val); echo "<br>"; echo '<input type="hidden" name="'.$key.'" value="'.$val.'" />'; echo "\n";
}
break;

I then get all the parameters displayed on the screen, among these:
KEY = string(5) "email" - VALUE = string(29) "abc.def@skynet.be"

2. If I get it to work so that the value in the email parameter is used for the donor's paypal account, then I encounter this problem: The value in row->email comes from the jd_donors table, but that table is not filled in until after the donation is sent off. Therefore, for a first-time donor, or a donor not logged in, the value of the email parameter is null. This may be a lesser problem - I just have to capture the email adress from the donation form instead.

3. Since I could not figure out how to have Joom Donation tell Paypal which donor paypal account to use, I have tried to have Paypal tell Joom Donation which paypal account the donor used. In the seller's paypal account I have set the preferences Auto Return and Payment Data Transfer to On. Auto Return works - I am returned to the website after the donation is processed, but I do not get the payment data shown (so that I could have tried to capture the donor paypal account.)

What I am trying to do is to use (or abuse) a donation module to process loans that will have to be reimbursed. I know that I can open my paypal account and see the donor's paypal account. But I am hoping to have this info, the donor's paypal account, saved somewhere within Joom Donations.

Now, if this is all way outside of what is the subject for this forum, then tell me to shut up. Maybe it is wild to use a donation component for loans (but I did not find any joomla components for loans.) But I am trying very hard (and have succeeded partially) to come to grips with the inner workings of Joomla and Joom Donation. I would not mind, for example, to contribute to coding extensions for loan processing. That would be the ultimate learning experience.

Please Log in or Create an account to join the conversation.

  • Christian_Belgien
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
12 years 8 months ago #11201 by Christian_Belgien
Replied by Christian_Belgien on topic Re: Paypal, donor's email adres not sent.
I got it! But it was a hard one. As I said, my approach is to have paypal tell me which account the donor used. On my paypal account I set Auto Return and Payment Data Transfer on. Paypal then sends a token to the return address that I must return to paypal, and then paypal sends name-value pairs with info about the donor. The paypal account of the donor is in the parameter 'payer_email'.

So the code in com_jdonation/views/complete/view.html.php I overwrote with the following (adapted from code generated by paypal). As a result I get, among others, a variable $email that I can use in my further coding.

// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-synch';
$tx_token = $_GET;
$auth_token = [a token generated on my paypal account when I set Payment Data Transfer on];
$req .= "&tx=$tx_token&at=$auth_token";

// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen (' www.sandbox.paypal.com ', 80, $errno, $errstr, 30);
fputs ($fp, $header . $req);
// read the body data
$res = '';
$headerdone = false;
while (!feof($fp))
{
$line = fgets ($fp, 1024);
if (strcmp($line, "\r\n") == 0)
{
// read the header
$headerdone = true;
}
else if ($headerdone)
{
// header has been read. now read the contents
$res .= $line;
}
}

// parse the data
$lines = explode("\n", $res);
$keyarray = array();
if (strcmp ($lines[0], "SUCCESS") == 0)
{
for ($i=1; $i<count($lines);$i++)
{
list($key,$val) = explode("=", $lines[$i]);
$keyarray[urldecode($key)] = urldecode($val);
}
$firstname = $keyarray;
$lastname = $keyarray;
$itemname = $keyarray;
$amount = $keyarray;
$email = $keyarray;

echo ("<p><h3>Thank you for your purchase!</h3></p>");

echo ("<b>Payment Details</b><br>\n");
echo ("<li>Name: $firstname $lastname</li>\n");
echo ("<li>Item: $itemname</li>\n");
echo ("<li>Amount: $amount</li>\n");
echo ("<li>Email: $email</li>\n");
echo ("");
}
else if (strcmp ($lines[0], "FAIL") == 0)
{
// log for manual investigation
}

}

fclose ($fp);

echo "Your transaction has been completed, and a receipt for your purchase has been emailed to you.<br>You may log into your account at <a href=' www.paypal.com '> www.paypal.com to view details of this transaction.
";

}

Please Log in or Create an account to join the conversation.

Moderators: Mr. DamDũng Nguyễn Việt