diff --git a/source/dbtools/Customer.php b/source/dbtools/Customer.php index 16def46..1a499f7 100644 --- a/source/dbtools/Customer.php +++ b/source/dbtools/Customer.php @@ -13,12 +13,15 @@ class Customer extends Application } // 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) { $passwordFactory = new RandomLib\Factory(); $pGen = $passwordFactory->getLowStrengthGenerator(); + $PAC_Ptext = $pGen->generate(4); + $PAC = password_hash($PAC_Ptext, PASSWORD_BCRYPT); + $this->db->insert('Customers', [ 'CustomerName' => $Name, 'CustomerEmail' => $Email, @@ -30,14 +33,18 @@ class Customer extends Application 'GDPRConsent' => $GDPRConsent, 'hasVirtualServer' => $hasVirtualServer, 'attachedVServerID' => $attachedVServerID, - 'PAC' => $pGen->generate(4) + 'PAC' => $PAC ]); - $cPassword = $pGen->generate(16); - $this->Virtualmin->CreateVirtualServer($Domain, $cPassword); + $PanelPassword = $pGen->generate(16); + $this->Virtualmin->CreateVirtualServer($Domain, $PanelPassword); - return $cPassword; + return + [ + "PanelPassword" => $PanelPassword, + "PersonalAuthenticationCode" => $PAC_Ptext + ]; } public function updateCustomerInformation($CustomerID, $UpdateField, $NewValue) @@ -64,7 +71,7 @@ class Customer extends Application $CEmail ); - return $Customer + return $Customer; } public function translateEmailToID($Email) @@ -90,7 +97,7 @@ class Customer extends Application return $Customer['GDPRConsent']; } - public function populate + diff --git a/source/defs/Hookmanager/Hookmanager.php b/source/defs/Hookmanager/Hookmanager.php index cdd8278..ae4c23d 100644 --- a/source/defs/Hookmanager/Hookmanager.php +++ b/source/defs/Hookmanager/Hookmanager.php @@ -1,5 +1,8 @@ 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 } - public function EventSubscriptionCancelled() + public function EventSubscriptionCancelled(Request $request, Response $response) { // 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 @@ -33,7 +79,7 @@ class Hookmanager } // TODO: Lenient business logic - public function EventSubscriptionPaymentFailed() + public function EventSubscriptionPaymentFailed(Request $request, Response $response) { // 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 // Delete all customer data