Custom Action to send email with license key

5 posts in this topic

Posted

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;

}

Share this post


Link to post
Share on other sites

Posted

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 -.-).

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Posted

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.

Share this post


Link to post
Share on other sites

Posted


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.

Share this post


Link to post
Share on other sites

  • Recently Browsing   0 members

    No registered users viewing this page.