Jump to content


Photo

Custom Action to send email with license key


  • Please log in to reply
4 replies to this topic

#1 BraCa

BraCa

    IPB Newbie

  • +Clients
  • 14 posts

Posted 13 July 2012 - 04:54 PM

Hi,

I would like to make IP.Nexus send an email to my users with their license key as soon as they buy something from my store..

I've tried to achieve this with a custom action using the 'onPurchaseGenerated' method.

The problem seems to be that the 'onPurchaseGenerated' method is called before the license generator, so when I try to get the license from the nexus_licensekeys table It won't get anything as the key for that purchase wasn't generated yet..

Is there anyway, I could implement this?

This is the code I've been using to test this out

public function onPurchaseGenerated( $member, $package, $invoice, $purchase )
{
  $DB =  ipsRegistry::DB(); 
  $purchaseID = $purchase['ps_id'];
  $licenseRow = $DB->buildAndFetch( array( 'select' => '*', 'from' => 'nexus_licensekeys', 'where' => "lkey_purchase=" . $purchaseID ) );
 
  IPSDebug::addLogMessage("onPurchaseGenerated", "actionLog", array( "purchaseID" => $purchaseID, "licenseRow" => $licenseRow, "member" => $member, "package" => $package, "invoice" => $invoice, "purchase" => $purchase), true, false);
  return;
}


#2 Marcher Technologies

Marcher Technologies

    $life=FALSE;$code=TRUE;$time--;

  • +Clients
  • 11,695 posts

Posted 13 July 2012 - 05:08 PM

are you certain(have a nearly finished script laying untested and that would balls it bad)? the redirect would kill the return of that debug statement.
You are logging it to file... crud, now I've got to dig for another entry point.... thanks for the unrealized heads-up on this(license not generated yet there -.-).

#3 BraCa

BraCa

    IPB Newbie

  • +Clients
  • 14 posts

Posted 13 July 2012 - 07:28 PM

You can close this, I found a way to do what I want..

It's probably not the best way to do this, but it works..
I just had to create my own key generator by implementing the
public static function generate( $member, $purchase )
function, then before returning the newly generated key, I send the email to the user with his license key.

Thanks anyway

#4 DavidAM

DavidAM

    Advanced Member

  • +Clients
  • 495 posts

Posted 14 July 2012 - 02:47 AM

I have also coded own keygen which I call from the action file and then I insert the output to IPB's table for keys. Best solution in current situation.

#5 Marcher Technologies

Marcher Technologies

    $life=FALSE;$code=TRUE;$time--;

  • +Clients
  • 11,695 posts

Posted 14 July 2012 - 02:49 AM

I have also coded own keygen which I call from the action file and then I insert the output to IPB's table for keys. Best solution in current situation.

I have a wild idea..... going talk to a fellow dev and add a new twist to an old toy, things we need licenses to do they do not, and may not for some time, if at all natively.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users