Major changes - Ready app for initial testings
This commit is contained in:
@@ -19,6 +19,20 @@ class Hookmanager
|
||||
private $Mailer;
|
||||
|
||||
|
||||
// Can be overloaded by child classes in order to add new features.W
|
||||
protected $alertTypes =
|
||||
[
|
||||
"subscription_created",
|
||||
"subscription_updated",
|
||||
"subscription_cancelled",
|
||||
"subscription_payment_succeeded",
|
||||
"subscription_payment_failed",
|
||||
"subscription_payment_refunded",
|
||||
"payment_refunded",
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -48,13 +62,50 @@ class Hookmanager
|
||||
}
|
||||
|
||||
|
||||
public function EventSubscriptionCreated(Request $request, Response $response)
|
||||
private function keyValidate($keyFromURI)
|
||||
{
|
||||
// Create customer with data from Paddle
|
||||
// Send email with customer information
|
||||
// FIXME: Theoretically, this method does not work.
|
||||
// TODO: Devise a new way to validate keys without user ID
|
||||
if($this->APITools->keysMatch($keyFromURI))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function detectPayloadIntent(Request $request, Response $response, $args)
|
||||
{
|
||||
if ($this->keyValidate($keyFromURI))
|
||||
{
|
||||
|
||||
$data = $this->getStructuredVariableList($Request);
|
||||
|
||||
foreach ($this->alertTypes as $types => $value)
|
||||
{
|
||||
if ($types == $data['alert_name'])
|
||||
{
|
||||
$sVal = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Redirect request to approriate route.
|
||||
// Use translator helper method to translate developer name to readable route name for redirect
|
||||
|
||||
|
||||
}
|
||||
|
||||
throw new LogicException("Illegal API key");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function EventSubscriptionCreated(Request $request, Response $response, $args)
|
||||
{
|
||||
|
||||
return $response->write($this->getStructuredVariableList($Request))->withStatus(200);
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user