📜 ⬆️ ⬇️

How to create your own VPS hosting from scratch and start making money on it? Simple billing with Virtuemart


Hello, dear readers of Habr. This material is a continuation of a series of articles on how to build a VPS hosting from scratch based on the RUVDS White Label API. And today we look at the popular Joomla CMS and one of the most popular ecommerce solutions for it - VirtueMart .

Virtuemart


Generally speaking, the extension exists quite a long time ago (the first version was released in 2005).
The product grew and developed together with CMS Joomla and currently has quite a wide functionality.

Let's take a look at the pros and cons of the Virtuemart 3 plugin.

pros



')

Minuses




Features adaptation for vps-hosting


Payment acceptance


The procedure is the same as when using other bundles, such as wordpress and woocommerce . In order to integrate with the paymaster aggregator already familiar to us , download the free extension . The paymaster extension setting is described in detail at the same link.

Deactivate guest purchase mechanism


Go to Virtuemart> Configuration> Checkout and set the flag "Only registered users can checkout".

Setting pages


After installing the Virtuemart plugin, we have the opportunity to use specialized pages in the menu. In order to make a showcase from the main page, go to Menus> Manage and edit the menu with the home alias. We need to change the Menu Item Type to one of the types provided by Virtuemart:

We chose Category Layout and standard Joomla design (version 3.5) and, after adding the main VPS configurations, the main page looks like this:



Processing paid orders


So, we have the same tasks:


What is available for integration



Let's stop on the last version. After installing this plugin, the following SOAP services are available:


Their wsdl are available by url (an example for a service that manages product categories):
http: // host / administrator / components / com_vm_soa / services /VM_CategoriesWSDL.php

We will need 3 - VM_Order, VM_Product and VM_SQLQueries.

Unfortunately, when using this integration method, the hooks mechanism is not available to us. Therefore, we will periodically select orders with the appropriate status and initiate the creation of servers of the desired configuration.

Let's write a simple script in PHP, which will create the server after paying for the order:
<?php function getApplicationSettings() { return [ 'login' =>'admin', 'password'=>'admin', 'orderServiceWsdl'=>'http://localhost/administrator/components/com_vm_soa/services/VM_OrderWSDL.php', 'productServiceWsdl' =>'http://localhost/administrator/components/com_vm_soa/services/VM_ProductWSDL.php' ]; } function getCompleteOrders($limitStart = 0, $limitEnd=1000) { $applicationSettings = getApplicationSettings(); $loginInfo = new stdClass; $loginInfo->login=$applicationSettings['login']; $loginInfo->password=$applicationSettings['password']; $loginInfo->isEncrypted="Y"; $loginInfo->lang=null; $orderServiceClient = new SoapClient($applicationSettings['orderServiceWsdl']); $getOrderFromStatusRequest = new stdClass; $getOrderFromStatusRequest->limite_start = $limitStart; $getOrderFromStatusRequest->limite_end = $limitEnd; $getOrderFromStatusRequest->status = 'F'; //  $getOrderFromStatusRequest->loginInfo = $loginInfo; try { //      "" return [$orderServiceClient->GetOrdersFromStatus($getOrderFromStatusRequest)]; }catch(\SoapFault $e){ echo $e->getMessage(); return false; } } function processPayedOrder($orderId) { $applicationSettings = getApplicationSettings(); $loginInfo = new stdClass; $loginInfo->login=$applicationSettings['login']; $loginInfo->password=$applicationSettings['password']; $loginInfo->isEncrypted="Y"; $loginInfo->lang=null; $productServiceClient = new SoapClient($applicationSettings['productServiceWsdl']); $getProductsFromOrderIdRequest = new stdClass; $getProductsFromOrderIdRequest->order_id = $orderId; $getProductsFromOrderIdRequest->include_prices = true; $getProductsFromOrderIdRequest->loginInfo = $loginInfo; try { //    $products = [$productServiceClient->GetProductsFromOrderId($getProductsFromOrderIdRequest)]; } catch(\SoapFault $e){ echo $e->getMessage(); return false; } //       foreach($products as $product) createRuvdsServer($product); return true; } function createRuvdsServer($product) { //     RUVDS White-Label Api     } $orders = getCompleteOrders(); if (!$orders || count($orders)==0) return 1; foreach ($orders as $order) { $orderId=$order->Order->id; $res = processPayedOrder($orderId); if(!$res) echo 'Processing order with id '.$orderId.' failed!'; } 


Next, using any task scheduler, for example, cron, we set up the launch of this script with the necessary periodicity.

Results


In general, a bunch of Joomla 3 + Virtuemart 3 looks like a fairly functional and powerful tool as a basis for organizing your VPS hosting. Immediately "out of the box" is available a lot of settings of everything that you can imagine. But is it required when reselling, say, 3-10 popular configurations of virtual servers ?

In the next article, we will look at CMS Drupal and one of its most popular eCommerce extensions, and perhaps the new CMS is more suitable for you for this task. See you again!

Source: https://habr.com/ru/post/305284/


All Articles