Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/27/2016 in all areas

  1. We're wanting to develop and release the Paypal In-Context Payment form for Blesta. We've already worked on both a plugin, a merchant gateway, and have extensively used the API from within Blesta. We're starting to get a fairly good grasp on how most things work, but there's still some confusion regarding non-merchant gateways, which is preventing us from simply building the new gateway: Question: Is there any support for non-webhook/payment notification gateways? For example the In-context gateway will perform the payment and guarantee a response immediately via a server-side request. It's somewhat similar to how some Credit cards work, where you effectively create a hold on the payment and then record the payment with a token provided from Paypal: Create payment token to Paypal, which includes sensative information regarding the payment's details (return URL, cancel url, etc) Build form with Paypal's Widget Javascript onto page User logs into Paypal without EVER leaving your website at all. The user also submits payment (or cancels the payment) with the popup UI. The user will be redirected to either the cancel url or the return payment url based on their action. Neither url is a notification url for internal use as the user's browser is used, rather than a webhook or IPN. When the payment was submitted by the user you MUST send a finalization request to Paypal to secure payment. This request will return the results of the payment, rather than an webhook/IPN. Paypal does not send an IPN for in-context payments. Question: Could the class NonmerchantGateway methods buildAuthorize, capture, & void methods be used? I noticed that the Payment gateway has methods as listed above, in the base NonmerchantGateway class, however they are currently registering unsupported errors rather than being blank functions. Based on other code in Blesta core it appears these methods are not yet supported. I just wanted to confirm that this is the case and see if there was any expectation to make them available.
    1 point
  2. it a one class file ... this is the content <?php /******************************************************************************* @name Kloxo Module (AKA LXAdmin) @author Cody Phillips @date May 12, 2009 @version 1.0 @notes For use with Blesta version 1.0.0+ *******************************************************************************/ class kloxo implements ModuleInterface { private static $module; public function __construct() { // Adds a new Kloxo that can be added, edited, or deleted self::$module = new Module("kloxo", true, true, true); // Adds the given fields to the database for this module if it has not already // been created. WARNING: if the module has already been created with the name // given in the Module constructor you must delete the old module before the // new one will be created. This may have an adverse effect on services. self::$module->addDBField("varchar(255)", "server", "Server"); self::$module->addDBField("varchar(255)", "dnstemplate", "DNS Template"); self::$module->addDBField("varchar(255)", "user", "User Name"); self::$module->addDBField("varchar(255)", "password", "Password"); self::$module->addDBField("varchar(5)", "usessl", "Use SSL", "false"); self::$module->addDBField("int(11)", "max", "Limit", "0"); self::$module->addDBField("int(11)", "cur", "Current", "0"); // Options for creating a new module row // Example: Kloxo module may store multiple different servers. The HTML Fields below // allow you to create/edit a server for the Kloxo module // NOTE: The HTML Fields will appear in the order defined here on the module setup/edit pages self::$module->addModuleHTMLField("text", "Server", "server"); self::$module->addModuleHTMLField("text", "DNS Template", "dnstemplate"); self::$module->addModuleHTMLField("text", "User Name", "user"); self::$module->addModuleHTMLField("text", "Password", "password"); self::$module->addModuleHTMLField("select", "Use SSL", "usessl"); self::$module->addModuleHTMLSelectOption("usessl", "Yes", "true"); self::$module->addModuleHTMLSelectOption("usessl", "No", "false"); self::$module->addModuleHTMLField("text", "Account Limit", "max", "^[0-9]+", "Account Limit must be an integer."); self::$module->addModuleHTMLField("text", "Current Accounts", "cur", "^[0-9]+", "Current Accounts must be an integer."); // Module Options while creating a package with this module // NOTE: Only one field is accepted of this type and must be named "mstring" self::$module->addPackageHTMLField("text", "Plan Name", "mstring", "^(.)+$", "You must enter a plan name."); // This adds a note to be displayed along with the above package field self::$module->addPackageNote("mstring", "Plan Name (ex. bronze)"); // Specify which field from the module table to display in the drop down and give it a friendly name // By default items will be shown by ID and have the friendly name of "Module ID". // This appears when adding or editing a service for a user. self::$module->setModuleRowSelect("DNS Template", "dnstemplate"); // These are shown as column names for each service of this type. self::$module->addServiceColumn("user1", "Domain"); self::$module->addServiceColumn("user2", "Username"); self::$module->addServiceColumn("pass", "Password"); self::$module->addServiceColumn("dnstemplate", "DNS Template"); // These are displayed as tags and are usable when creating/editing a package's welcome e-mail self::$module->addServiceTag("user1", "domain"); self::$module->addServiceTag("user2", "username"); self::$module->addServiceTag("pass", "pass"); self::$module->addServiceTag("term", "term"); // These are the fields that may be edited when performing a local edit on this service self::$module->addServiceEditField("user1", "Domain"); self::$module->addServiceEditField("user2", "Username"); // Client username self::$module->addServiceEditField("pass", "Password"); self::$module->addServiceEditField("plan", "Package/Term"); // Package/Term self::$module->addServiceEditField("dnstemplate", "DNS Template"); self::$module->addServiceEditField("dated", "Date Deleted"); self::$module->addServiceEditField("datep", "Date Suspended"); self::$module->addServiceEditField("dater", "Date Renews"); self::$module->addServiceEditField("notes", "Notes"); // Fields that are shown to the admins when adding a service that uses this module. self::$module->addServiceHTMLField("text", "Domain Name", "user1", "^[a-z0-9._%-]+\.[a-z]{2,6}$", "The domain you entered does not appear to be valid. It should be lowercase and in the format: domain.com."); self::$module->addServiceHTMLField("text", "Password", "pass", "^.{4,16}$", "Passwords must be between 4 and 16 characters."); // Fields that are shown to the user when adding a service that uses this module. self::$module->addUserServiceHTMLField("text", "Domain Name", "user1", "^[a-z0-9._%-]+\.[a-z]{2,6}$", "The domain you entered does not appear to be valid. It should be lowercase and in the format: domain.com."); self::$module->addUserServiceHTMLField("text", "Password", "pass", "^.{4,16}$", "Passwords must be between 4 and 16 characters."); // Creates the module, adds the module to the database if the module table does not // already exist. WARNING: if a module has already been created and you attempt to // add additional fields they WILL NOT BE ADDED, and any refrence to those fields // WILL RESULT IN AN ERROR. self::$module->createModule(); } /** * Returns the module object, this function MUST be present */ public function getModule() { return self::$module; } /** * This is the MAGIC function. This function automatically creates a service * for a user. * * IT MUST BE DEFINED HERE OR AN E-MAIL WILL BE SENT TO ALL SUBSCRIBED ADMINS * NOTIFYING THEM THAT THE SERVICE MUST BE MANUALLY CREATED. * * IF THIS FUNCTION IS DEFINED AND RETURNS TRUE IT IS ASSUMED THAT IT PERFORMS * THE NECCESSARY ACTIONS TO AUTOMATICALLY ACTIVATE THE SERVICE. */ public function promodule($action, $serviceInfo, $packageInfo) { // packageInfo comes from packagesetinfos() function $plan = $packageInfo[4][2]; $conditions = array(array("field" => "id", "value" => $serviceInfo['mid'])); $data = self::$module->getRows($conditions); $serviceInfo['dnstemplate'] = $data[0]['dnstemplate']; $serviceInfo['plan'] = $plan; switch ($action) { case "add": // Ensure we do not exceed the maximum number of accounts for this server. if ($data[0]['cur'] >= $data[0]['max']) return false; $serviceInfo['user2'] = self::makeUserName($serviceInfo['user1']); if (DEMO) return $serviceInfo; elseif ($this->addClient($serviceInfo, $data)) { // Update the current number of accounts on this server self::$module->updateDBFields("cur", $data[0]['cur']+1, $serviceInfo['mid']); return $serviceInfo; // return the info that we want to be inserted into the services table } break; case "remove": if (DEMO) return true; elseif ($this->removeClient($serviceInfo['user2'], $data)) { // Update the current number of accounts on this server self::$module->updateDBFields("cur", $data[0]['cur']-1, $serviceInfo['mid']); return true; } break; case "suspend": if (DEMO) return true; return $this->suspendClient($serviceInfo['user2'], $data); break; case "unsuspend": if (DEMO) return true; return $this->unsuspendClient($serviceInfo['user2'], $data); break; } return false; } /** * Add a client to the VPS system * */ private function addClient(&$serviceInfo, &$data) { $params = array(); $params['login-class'] = "client"; $params['login-name'] = $data[0]['user']; $params['login-password'] = $data[0]['password']; $params['output-type'] = "json"; $params['class'] = "client"; $params['name'] = $serviceInfo['user2']; $params['action'] = "add"; $params['v-password'] = $serviceInfo['pass']; $params['v-type'] = "customer"; $params['v-plan_name'] = $serviceInfo['plan']; $params['v-domain_name'] = $serviceInfo['user1']; $params['v-dnstemplate_name'] = $serviceInfo['dnstemplate']; return $this->request($data[0]['server'], $data[0]['usessl'], $params); } /** * Remove a client from the VPS system * */ private function removeClient(&$username, &$data) { $params = array(); $params['login-class'] = "client"; $params['login-name'] = $data[0]['user']; $params['login-password'] = $data[0]['password']; $params['output-type'] = "json"; $params['class'] = "client"; $params['name'] = $username; $params['action'] = "delete"; return $this->request($data[0]['server'], $data[0]['usessl'], $params); } /** * Suspend a client on the VPS system * */ private function suspendClient(&$username, &$data) { $params = array(); $params['login-class'] = "client"; $params['login-name'] = $data[0]['user']; $params['login-password'] = $data[0]['password']; $params['output-type'] = "json"; $params['class'] = "client"; $params['name'] = $username; $params['action'] = "update"; $params['subaction'] = "disable"; return $this->request($data[0]['server'], $data[0]['usessl'], $params); } /** * Unsuspend a client on the VPS system * */ private function unsuspendClient(&$username, &$data) { $params = array(); $params['login-class'] = "client"; $params['login-name'] = $data[0]['user']; $params['login-password'] = $data[0]['password']; $params['output-type'] = "json"; $params['class'] = "client"; $params['name'] = $username; $params['action'] = "update"; $params['subaction'] = "enable"; return $this->request($data[0]['server'], $data[0]['usessl'], $params); } /* * Prepares and executes a CURL request that performs Kloxo API request * @return response */ private function request($host, &$usessl, &$params) { // Log data received from Kloxo self::$module->logData($params, "input", true); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http" . ($usessl == "true" ? "s" : "") . "://" . $host . "/webcommand.php"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $response = (array)json_decode(curl_exec($ch)); curl_close($ch); // Log data received from Kloxo self::$module->logData($response, "output", ($response['return'] == "success" ? true : false)); if ($response['return'] == "success") return true; return false; } // Creates a username that is between 5 and 8 characters long // Usernames that are generated randomly are 7 characters in length private static function makeUserName($domain) { // Remove everything except letters from the domain $temp = preg_replace('/[^a-zA-Z]/', '', $domain); // If what we have left to build the username is less than 5 characters // add in some random characters to create a unique username. if (strlen($temp) < 5) { // Add 3-random characters followed by the rest of temp. $chars = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t', 'u','v','w','x','y','z'); $count = count($chars) - 1; for ($i=0; $i<3; $i++) $temp = $chars[rand(0, $count)] . $temp; } return substr($temp, 0, 8); } } ?>
    1 point
  3. timnboys

    Openstack Modules

    so no billing software supports openstack? well since I found a free openstack auto installer for one server I will start to work on the openstack provisioning module then. though the module when it is done won't be free though.
    1 point
×
×
  • Create New...