Top Experts [learn more]Top 4-10

9743 K

2458 K

1525 K
4. tcmeyers
5. kbata
6. Martie
7. Hammerton
8. rrenfrow
9. bneeman
10. plegler
Welcome, Guest. Please login or register.
May 04, 2015, 02:06:44 PM

Login with username, password and session length
Search:     Advanced search
Welcome to the FileMaker Web Masters Exchange.  If you have any questions about how to use this forum, please watch the getting started movie at:
27871 Posts in 6165 Topics by 1525 Members
Latest Member: alkyred
* Home Help Search Calendar Login Register
|-+  FMStudio
| |-+  FMStudio Pro
| | |-+  send email from paypal notify
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: send email from paypal notify  (Read 677 times)
Jr. Member
Offline Offline

Posts: 29

« on: March 05, 2012, 01:23:04 PM »

I am trying to get my system to send an email to a customer when paypal notifies me that the order is completed.  I want to send the email to the email they input instead of their paypal email.  In an earlier post, Micheal said that you have to modify the paypal notify function. 

"PayPal_Module/paypal.php contains a function FMStudio_PayPal_Notify. That function ends with "die("GOOD");" which just stops the code there - replace that line with "return $vars;" and the return value of that function is an array of the transaction."

Later he said that the code would be:
The return was there to separate FMStudio_PayPal_Notify from anything else, your code currently has:

FMStudio_PayPal_Notify(...some options...);

With the return line it can become:
$data = FMStudio_PayPal_Notify(....same options....);
$payer_email = $data['payer_email'];

However, no mention was made by what he meant by FMStudio_Paypal_Notify (...some options...).

Basically, I need to pull the invoice number out of the paypal notify string.  With the invoice number, I can easily do a find to get the record and then get the email from that and send the email.

The following is the Paypal_Notify portion of the code.

function FMStudio_PayPal_Notify($Connection,$Layout,$business,$Invoice,$Status,$Fields,$Values,$script,$sandbox,$rootPath) {
   $vars = array();
   foreach($_POST as $var=>$value) {
      if(get_magic_quotes_gpc()) {
         $vars[$var]  =stripslashes($_POST[$var]);
         $vars[$var] = $_POST[$var];
   if(!count($vars)) die('No post request was submitted');
   // Security checks come first
   if($vars['receiver_email'] != $business) {

   $vars['cmd'] = '_notify-validate';
   if($sandbox) {
      $vars['notify-validate'] = FMStudio_PayPal_sendPOST("", $vars);
      $vars['notify-validate'] = FMStudio_PayPal_sendPOST("", $vars);

   if($vars['notify-validate'] != 'VERIFIED') {
   if(is_a($Connection,'FileMaker')) {
      $find = $Connection->newFindCommand($Layout);
      $find->addFindCriterion($Invoice, '=='.fmsEscape($vars['invoice']));
      $result = $find->execute();
      if(FileMaker::isError($result)) die('Failed to Find the Invoice');
      $record = $result->getFirstRecord();
      $edit = $Connection->newEditCommand($Layout,$record->getRecordId());
      $edit->setField($Status, $vars['payment_status']);
      $edit->setField($Fields, implode("\r",array_keys($vars)));
      $edit->setField($Values, implode("\r",array_values($vars)));
      if($script != '') $edit->setScript($script);
      $result = $edit->execute();
      if(FileMaker::isError($result)) {
         die('FileMaker Error on Commit');
      $find = clone($Connection);
      $find->AddDBParam($Invoice, '=='.fmsEscape($vars['invoice']));
      $result = $find->FMFind();
      if($result['errorCode'] != 0) die('Failed to Find the Invoice');
      $recid = array_shift(explode('.',key($result['data'])));
      $edit = clone($Connection);
      $edit->AddDBParam('-recid', $recid);
      $edit->AddDBParam($Status, $vars['payment_status']);
      $edit->AddDBParam($Fields, implode("\r",array_keys($vars)));
      $edit->AddDBParam($Values, implode("\r",array_values($vars)));
      if($script != '') $edit->PerformFMScript($script);
      $result = $edit->FMEdit();
      if($result['errorCode'] != 0) {
         die('FileMaker Error on Commit');

What do I need to change to get a value :Inv_numb to use in this find:

$found_records_find = $maincon->newFindCommand('ray_order');
$found_records_findCriterions = array('Inv_numb'=>'=='.fmsEscape($Inv_numb),);

Thanks in advance.  I assume it is something like change the
die(good); to

However, since there is no real way to test this since it never shows up on the browser, I could use some help.
Global Moderator
Hero Member
Offline Offline

Posts: 2130
Kudos: 9743

« Reply #1 on: March 05, 2012, 01:54:30 PM »

echo and print_r commands are your friends...

echo $Inv_numb;
print_r ($result);

These should output to the screen for testing and debugging
Jr. Member
Offline Offline

Posts: 29

« Reply #2 on: March 13, 2012, 09:32:35 PM »

Yes, but the problem with the paypal notify function is that it is triggered by Paypal and thus never appears on your browser.
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!