<< Home

Does it support custom fields?

Use this forum for issues related to TriniTronic's Nice PayPal Downloads Extension.

Moderator: jamesSBT

Does it support custom fields?

Postby sandeep » Thu Jun 23, 2011 12:20 pm

Hi everyone,

I'm thinking about buying this extension for my software download website.

The thing is I would like to send the user their serial number in the confirmation email, does this extension allow me to generate a serial from my own algorithm then send it to the user on successful payment?

Thanks
sandeep
Stratos
Stratos
 
Posts: 19
Joined: Thu Jun 23, 2011 12:18 pm

Re: Does it support custom fields?

Postby Michael » Thu Jun 23, 2011 12:26 pm

Hi,

That is a good question. Unfortunately, the extension does not support the feature you are describing. At best, you could specify a special message per product, but not per buyer.

~ All the best
Contributed by Michael Babcock
User avatar
Michael
Cosmos
Cosmos
 
Posts: 2473
Joined: Thu Aug 14, 2008 12:30 am

Re: Does it support custom fields?

Postby sandeep » Thu Jun 23, 2011 12:28 pm

Michael wrote:Hi,

That is a good question. Unfortunately, the extension does not support the feature you are describing. At best, you could specify a special message per product, but not per buyer.

~ All the best


That's a shame, is there any way that I can edit the code and change the email message for the buyer to include my serial, by editing the extensions files?
sandeep
Stratos
Stratos
 
Posts: 19
Joined: Thu Jun 23, 2011 12:18 pm

Re: Does it support custom fields?

Postby Michael » Thu Jun 23, 2011 12:50 pm

Yes, if you are familiar with PHP. There is a method that prepares the email message for sending. Prior to sending, the email message may contain certain tokens %examlpe%. The method replaces those tokens with dynamic information and then sends the email out.

Example
"%date%" is replaced with "06/24/2011".

You could hook into the replacement method and use a token in your email message, like %activationcode%.

Then when the system sees %activationcode% it will replace it with the appropriate information.

It will take a bit of doing (customizing) on your part, but the frame work is there to support your needs. If you have questions during your modifications, I would be happy to help answer them.

As a side note, I will be away between 6/24 - 6/28.

~ Best regards
Contributed by Michael Babcock
User avatar
Michael
Cosmos
Cosmos
 
Posts: 2473
Joined: Thu Aug 14, 2008 12:30 am

Re: Does it support custom fields?

Postby sandeep » Thu Jun 23, 2011 12:55 pm

Michael wrote:Yes, if you are familiar with PHP. There is a method that prepares the email message for sending. Prior to sending, the email message may contain certain tokens %examlpe%. The method replaces those tokens with dynamic information and then sends the email out.

Example
"%date%" is replaced with "06/24/2011".

You could hook into the replacement method and use a token in your email message, like %activationcode%.

Then when the system sees %activationcode% it will replace it with the appropriate information.

It will take a bit of doing (customizing) on your part, but the frame work is there to support your needs. If you have questions during your modifications, I would be happy to help answer them.

As a side note, I will be away between 6/24 - 6/28.

~ Best regards


Thanks a lot for the lengthy response! The only doubt I have is if I do buy it and the customizations do not go according to plan, then I would have an extension that I paid a lot for (since I haven't got an income yet) and left to purchase another code. The reason I want to purchase this one is the fact it is lightweight and apparently nicely coded.
sandeep
Stratos
Stratos
 
Posts: 19
Joined: Thu Jun 23, 2011 12:18 pm

Re: Does it support custom fields?

Postby Michael » Thu Jun 23, 2011 12:58 pm

No worries, if the extension cannot be modified to fit your needs, I will personally make sure you are refunded for the purchase. However, I am 99% sure that you will be successful in the modification and/or we will be able to guide you to an appropriate solution using the extension.

~ Enjoy
Contributed by Michael Babcock
User avatar
Michael
Cosmos
Cosmos
 
Posts: 2473
Joined: Thu Aug 14, 2008 12:30 am

Re: Does it support custom fields?

Postby sandeep » Thu Jun 23, 2011 1:05 pm

Michael wrote:No worries, if the extension cannot be modified to fit your needs, I will personally make sure you are refunded for the purchase. However, I am 99% sure that you will be successful in the modification and/or we will be able to guide you to an appropriate solution using the extension.

~ Enjoy


OK thank you very much, I'll go ahead and make the purchase and see what I can get up to. Thanks again!
sandeep
Stratos
Stratos
 
Posts: 19
Joined: Thu Jun 23, 2011 12:18 pm

Re: Does it support custom fields?

Postby Michael » Thu Jun 23, 2011 1:25 pm

That sounds great!

To get you started, you will want to take a look at the script found here joomla_root_directory/component/com_nicepaypaldownloads/models/ipn.php. Find the "getEmailData()" function. It handles the %token% replacement process that I was speaking of earlier.

You will also want to take a look at the getdata() function in joomla_root_directory/component/com_nicepaypaldownloads/models/nicepaypaldownloads.php. It handles all of the %token% replacement processing for the download landing page messages and other pages.

~ Best regards
Contributed by Michael Babcock
User avatar
Michael
Cosmos
Cosmos
 
Posts: 2473
Joined: Thu Aug 14, 2008 12:30 am

Re: Does it support custom fields?

Postby sandeep » Thu Jun 23, 2011 6:11 pm

Michael wrote:That sounds great!

To get you started, you will want to take a look at the script found here joomla_root_directory/component/com_nicepaypaldownloads/models/ipn.php. Find the "getEmailData()" function. It handles the %token% replacement process that I was speaking of earlier.

You will also want to take a look at the getdata() function in joomla_root_directory/component/com_nicepaypaldownloads/models/nicepaypaldownloads.php. It handles all of the %token% replacement processing for the download landing page messages and other pages.

~ Best regards


Thanks a lot for you help, I'll take a look at the areas you posted and get to it and see what I can get done. Thanks again.
sandeep
Stratos
Stratos
 
Posts: 19
Joined: Thu Jun 23, 2011 12:18 pm

Re: Does it support custom fields?

Postby sandeep » Fri Jun 24, 2011 3:23 am

OK I'm having a little trouble identifying where I can put my custom code into your current code. I have created the %productkey% token in the array along with a $productkey variable. Also another thing I found was that I need to actually include more than one file for the user to download, how can I do this? I understand you are away atm, I'll await your response. Thanks.
sandeep
Stratos
Stratos
 
Posts: 19
Joined: Thu Jun 23, 2011 12:18 pm

Re: Does it support custom fields?

Postby sandeep » Sun Jun 26, 2011 3:34 am

Worked on it some more and here are a few problems I'm facing:

1) I have set my Url to sandbox.paypal.... and I've tried using two sandboxed email addresses, the payment states that it's gone through and the IPN Log reflects this, but the transactions page shows the transaction as pending. I have set the item price to 1.00 and nothing happens.

2) Due to the error above the download email does not submit, leaving me no idea on a way to test to see if the product key gets included in the email. I have set my email settings correctly; where both the paypal email and system email are the same, and I am using my servers SMTP settings instead of PHP Mail or Sendmail.

If you could take a look at the configuration directly it would be great, sinvise you'll be back on the 28th I'll hear from you then, was just providing updates on my findings.
sandeep
Stratos
Stratos
 
Posts: 19
Joined: Thu Jun 23, 2011 12:18 pm

Re: Does it support custom fields?

Postby sandeep » Sun Jun 26, 2011 5:28 am

And on a final note, I managed to get the test transactions to completed, I had to accept the paypal review. Once that was done I still did not get any email with the details. I have even tried it with a real account.
sandeep
Stratos
Stratos
 
Posts: 19
Joined: Thu Jun 23, 2011 12:18 pm

Re: Does it support custom fields?

Postby Michael » Tue Jun 28, 2011 12:26 pm

Hi,

Thanks for your patience. I am back now and available to assist you in this matter. Ok, lets walk through this.

Distributing multiple files

A very effective method for providing your customers with multiple files is to package them up into a single ZIP file. Using this method you can provide as many files as you would like.

Custom code

You have successfully added the token replacement code. What aspect are you having difficulty with? I will need more information in order to help you with this.

PayPal Sandbox

The PayPal sandbox is tricky. It takes some getting used to. Depending on your set up, you may need to log in to your sandbox buyer account and manually change the status of the transaction from "Pending" to "Completed". Also, another method for testing, that I find very useful, is to use the IPN test tool. Once you have logged into your developer.paypal.com account, click on the "Test Tools" link in the left hand column. You will see another link called "Instant Payment Notification (IPN) Simulator." This tool takes some fiddling around to get your setting straight, but is amazing in that it will allow you to fire off one IPN message after another. It is my preferred method for IPN testing.

Debugging Scripts and IPN Processing

Yes, debugging the IPN process can be problematic in that much of the process is behind the scenes. Meaning that you are not able to experience the process through the browser. I handle this by adding two special functions to the script I am debugging. These functions allow me to put trace statements into the script at strategic spots, the the functions then write the trace statements to a flat file that I can monitor.

Here is what to do.

1. create a empty text file in your Joomla root directory. Name it mytrace.log

2. Add these functions to the script you want to debug. Place them as the last functions in the class. Replace the file path "path/to/joomla_root_directory/mytrace.log", in each function, with the correct path to the mytrace.log file.

Code: Select all
function mytrace($data)
{
   $file = 'path/to/joomla_root_directory/mytrace.log';
   $handle = fopen($file, 'a') or die("can't open file");
   fwrite($handle, $data."\n");
   fclose($handle);
}
   
function mytrace_r($data)
{
   ob_start();
   print_r( $data );
   $output = ob_get_clean();
   $file = 'path/to/joomla_root_directory/mytrace.log';
   file_put_contents( $file, file_get_contents( $file ) . $output );
   
}


3. Wherever you want to add a trace statement or glean information about a script process add one of the following finction calls.

Code: Select all
$this->mytrace("your string here.");


or

Code: Select all
$this->mytrace_r($yourArray);


Then you can run the script/IPN process and see the statements in the mytrace.log file using your favorite text editor. If you have SSH access to your site and your on a Linux server, you can use this command to watch the mytrace.log in real time:

Code: Select all
tail -f path/to/joomla_root_directory/mytrace.log


To quit/escape tail, I believe you press the "Break" button on your keyboard.

Email Notifications

The Nice PayPal Downloads uses Joomla's native email class. So, if you can get your Joomla site to email correctly, like through Mass Mail, the Nice PayPal Downloads should be able to send out emails without difficulty.

Let me know what other questions you have and I will be happy to assist.

~ Best regards
Contributed by Michael Babcock
User avatar
Michael
Cosmos
Cosmos
 
Posts: 2473
Joined: Thu Aug 14, 2008 12:30 am

Re: Does it support custom fields?

Postby sandeep » Tue Jun 28, 2011 12:37 pm

Hi,

Thanks for the reply, I really want to get my payment system working by today so I can get everything going, can't afford to lose any revenue especially when my program is gaining popularity very quickly.

1. I don't know where to put the trace functions in the class, what file would I put them into?

2. As for multiple downloads, I would rather not put all the files in one due to the fact I'm giving links to a 32 bit, 64 bit version and also portable versions, what I did was just remove the downloadlink token from the email message and entered my own information to give direct links, it won't really matter since my users will need a key to activate the program which they will need to download anyway.

3. I have tried sending a mass mail and it did work and I did receive an email, so my joomla email is working fine.

4. I have entered my code into ipn.php

In getEmailData function where the token assignment goes I had entered productkey at the end given below:

Code: Select all
      //lets set up for replacing all those message tokens
      $repKey = array(
            '%firstname%',
            '%lastname%',
            '%itemname%',
            '%itemnumber%',
            '%transactionid%',
            '%paymentstatus%',
            '%downloadcount%',
            '%downloadsallowed%',
            '%firstdate%',
            '%timeallowed%',
            '%downloaduntil%',
            '%downloadlink%',
            '%productkey%'
            );
      $repVal = array(
            $this->_emaildata->first_name,
            $this->_emaildata->last_name,
            $this->_emaildata->item_name,
            $this->_emaildata->id,
            $this->_emaildata->txn_id,
            $this->_emaildata->payment_status,
            $this->_emaildata->dload_count,
            $this->_emaildata->hitstoexpiry,
            $firstdate,
            $timeallowed,
            $untildate,
            $downloadlink,
            $productkey
            );


Also before the assign of the tokens I had created custom variables:

Code: Select all
      $buyerName = $this->_emaildata->first_name + " " + $this->_emaildata->last_name;
      $buyerItemName = $this->_emaildata->item_name;
      $buyerDate = date("d/m/Y", time());
      $buyerEmail = $this->_emaildata->payer_email;


Also I had created all my code calculations populating into $productkey

Have I gone through the correct steps?
sandeep
Stratos
Stratos
 
Posts: 19
Joined: Thu Jun 23, 2011 12:18 pm

Re: Does it support custom fields?

Postby Michael » Tue Jun 28, 2011 1:41 pm

1. I don't know where to put the trace functions in the class, what file would I put them into?


Well, the trace function method is a bit crude, but I love it for its simplicity. So, let's say you are working on modifing the models/ipn.php file, which you are. You would put the trace functions at the end of it. See the exerpt below.

The code below is end of the models/ipn.php class with the trace functions added.
Code: Select all
   // Build the string
      foreach ($segments as $key => $value) {
         $segment_name = substr($key, 0, -1);
         $segment = $value . ' ' . $segment_name;
         if ($value != 1) {
            $segment .= 's';
         }
         $array[] = $segment;
      }

      $str = implode(', ', $array);
      return $str;
   }

function mytrace($data)
{
   $file = 'path/to/joomla_root_directory/mytrace.log';
   $handle = fopen($file, 'a') or die("can't open file");
   fwrite($handle, $data."\n");
   fclose($handle);
}
   
function mytrace_r($data)
{
   ob_start();
   print_r( $data );
   $output = ob_get_clean();
   $file = 'path/to/joomla_root_directory/mytrace.log';
   file_put_contents( $file, file_get_contents( $file ) . $output );
   
}


}


Below is a bit where I am sending a string to the trace function and a bit where I am checking an array.

Code: Select all
$buyerName = $this->_emaildata->first_name + " " + $this->_emaildata->last_name;
$buyerItemName = $this->_emaildata->item_name;
$buyerDate = date("d/m/Y", time());
$buyerEmail = $this->_emaildata->payer_email;

$this->mytrace('buyerEmail: '.$buyerEmail);


Code: Select all
      //lets set up for replacing all those message tokens
      $repKey = array(
            '%firstname%',
            '%lastname%',
            '%itemname%',
            '%itemnumber%',
            '%transactionid%',
            '%paymentstatus%',
            '%downloadcount%',
            '%downloadsallowed%',
            '%firstdate%',
            '%timeallowed%',
            '%downloaduntil%',
            '%downloadlink%',
            '%productkey%'
            );
      $repVal = array(
            $this->_emaildata->first_name,
            $this->_emaildata->last_name,
            $this->_emaildata->item_name,
            $this->_emaildata->id,
            $this->_emaildata->txn_id,
            $this->_emaildata->payment_status,
            $this->_emaildata->dload_count,
            $this->_emaildata->hitstoexpiry,
            $firstdate,
            $timeallowed,
            $untildate,
            $downloadlink,
            $productkey
            );
$this->mytrace_r($repVal);


*Remember, once you are ready to go live with your script you should remove all elements of the trace statements and functions from your script.

2. As for multiple downloads, I would rather not put all the files in one due to the fact I'm giving links to a 32 bit, 64 bit version and also portable versions, what I did was just remove the downloadlink token from the email message and entered my own information to give direct links, it won't really matter since my users will need a key to activate the program which they will need to download anyway.


It sounds like you have found a suitable workaround for this, yes?

3. I have tried sending a mass mail and it did work and I did receive an email, so my joomla email is working fine.


Ok, then there is probably an error that is causing the script to abort prior to the email being sent out. What I do in these cases is add a number of trace statements to the script that I am modifying:

Code: Select all
$this->mytrace("step 1");
...
$this->mytrace("step 2");
...
$this->mytrace("step 3");


This gives me the ability to see where the script stops. If in the mytrace.log file I see:

-------
step 1
step 2
-------

Then I know the script is stopping before step 3 and I can narrow in on the issue.

4. I have entered my code into ipn.php

This looks correct. The replacement function takes the first array and in order replaces the values with the corresponding values (in order) from the second array. So as long as $productKeys has the correct information in it, %productkey% should get replaced.
Contributed by Michael Babcock
User avatar
Michael
Cosmos
Cosmos
 
Posts: 2473
Joined: Thu Aug 14, 2008 12:30 am

Next

Return to Joomla: Nice PayPal Downloads

Who is online

Users browsing this forum: No registered users and 1 guest