Major changes

This commit is contained in:
Miguel Nogueira 2018-06-07 14:14:25 +00:00
parent 3b0972f200
commit 7403097008
2 changed files with 66 additions and 13 deletions

View File

@ -13,12 +13,15 @@ class Customer extends Application
} }
// By default, this function sets the customer as inactive (e.g. newly created, awating payment) // By default, this function sets the customer as inactive (e.g. newly created, awating payment)
// Returns the customer's hosting password // Returns the customer's hosting passwords
public function newCustomer($Domain, $Name, $Email, $CheckoutID, $SubscriptionStatus, $Package, $PaddleSubscriptionID, $SystemStatus, $GDPRConsent, $hasVirtualServer = false, $attachedVServerID = null) public function newCustomer($Domain, $Name, $Email, $CheckoutID, $SubscriptionStatus, $Package, $PaddleSubscriptionID, $SystemStatus, $GDPRConsent, $hasVirtualServer = false, $attachedVServerID = null)
{ {
$passwordFactory = new RandomLib\Factory(); $passwordFactory = new RandomLib\Factory();
$pGen = $passwordFactory->getLowStrengthGenerator(); $pGen = $passwordFactory->getLowStrengthGenerator();
$PAC_Ptext = $pGen->generate(4);
$PAC = password_hash($PAC_Ptext, PASSWORD_BCRYPT);
$this->db->insert('Customers', [ $this->db->insert('Customers', [
'CustomerName' => $Name, 'CustomerName' => $Name,
'CustomerEmail' => $Email, 'CustomerEmail' => $Email,
@ -30,14 +33,18 @@ class Customer extends Application
'GDPRConsent' => $GDPRConsent, 'GDPRConsent' => $GDPRConsent,
'hasVirtualServer' => $hasVirtualServer, 'hasVirtualServer' => $hasVirtualServer,
'attachedVServerID' => $attachedVServerID, 'attachedVServerID' => $attachedVServerID,
'PAC' => $pGen->generate(4) 'PAC' => $PAC
]); ]);
$cPassword = $pGen->generate(16); $PanelPassword = $pGen->generate(16);
$this->Virtualmin->CreateVirtualServer($Domain, $cPassword); $this->Virtualmin->CreateVirtualServer($Domain, $PanelPassword);
return $cPassword; return
[
"PanelPassword" => $PanelPassword,
"PersonalAuthenticationCode" => $PAC_Ptext
];
} }
public function updateCustomerInformation($CustomerID, $UpdateField, $NewValue) public function updateCustomerInformation($CustomerID, $UpdateField, $NewValue)
@ -64,7 +71,7 @@ class Customer extends Application
$CEmail $CEmail
); );
return $Customer return $Customer;
} }
public function translateEmailToID($Email) public function translateEmailToID($Email)
@ -90,7 +97,7 @@ class Customer extends Application
return $Customer['GDPRConsent']; return $Customer['GDPRConsent'];
} }
public function populate

View File

@ -1,5 +1,8 @@
<?php <?php
use \Slim\Http\Request as Request;
use \Slim\Http\Response as Response;
// The hookmanager is the web-exposed class that allows you to manage a user within the billing system. // The hookmanager is the web-exposed class that allows you to manage a user within the billing system.
// This system takes care of CRUD operations on customers. It doesn't keep track of order but it does suspend // This system takes care of CRUD operations on customers. It doesn't keep track of order but it does suspend
// you if you don't pay. // you if you don't pay.
@ -7,17 +10,60 @@
class Hookmanager class Hookmanager
{ {
public function EventSubscriptionCreated() private $Customer;
private $Renderview;
private $APITools;
private $Mailer;
public function __construct()
{ {
$this->Customer = new Customer();
$this->Renderview = new EmailRenderer();
$this->APITools = new ApplicationAPI();
// Create mailer when needed
} }
public function EventSubscriptionUpdated() // Return POST variable list in a structured array, DRY
private function getStructuredVariableList(Request $request)
{
$PDATA = $request->getParsedBody();
$dArr = [];
foreach($PDATA as $key => $param)
{
$dArr[$key => $param]; // Turn parsed body into an array.
}
return $dArr;
}
public function EventSubscriptionCreated(Request $request, Response $response)
{
// Create customer with data from Paddle
// Send email with customer information
}
public function EventSubscriptionUpdated(Request $request, Response $response)
{ {
// Update user information if necessary // Update user information if necessary
} }
public function EventSubscriptionCancelled() public function EventSubscriptionCancelled(Request $request, Response $response)
{ {
// Suspend user's domain name as stated on DB // Suspend user's domain name as stated on DB
@ -25,7 +71,7 @@ class Hookmanager
} }
public function EventSubscriptionPaymentSuccess() public function EventSubscriptionPaymentSuccess(Request $request, Response $response)
{ {
// Renew user's subscription within billing system // Renew user's subscription within billing system
@ -33,7 +79,7 @@ class Hookmanager
} }
// TODO: Lenient business logic // TODO: Lenient business logic
public function EventSubscriptionPaymentFailed() public function EventSubscriptionPaymentFailed(Request $request, Response $response)
{ {
// Add payment strike to user account // Add payment strike to user account
@ -44,7 +90,7 @@ class Hookmanager
} }
public function EventSubscriptionPaymentRefunded() public function EventSubscriptionPaymentRefunded(Request $request, Response $response)
{ {
// Ban customer from billing system // Ban customer from billing system
// Delete all customer data // Delete all customer data