Jump to content

randvegeta

Members
  • Posts

    32
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by randvegeta

  1. Not to sound ungrateful, but I don't feel I am much better off than before I started this thread. I am still a bit stuck with how to proceed. You see, all I want to do is something very simple. Flexible as Blesta, it is inaccessible to more novice developers like myself, to the point where simple things become seemingly over complicated. My WHMCS module literally took me less than 2 hours to read the documentation, implement and deploy. The code is exceedingly simple. I understand there may be more hoops to jump through with Blesta, but as it stands, I have no idea how to do that. Perhaps someone can provide a quote to port over?
  2. No I am not a developer by trade. I am more of a network/server engineer than software developer. I have some programming experience and am familiar with the concept of object-oriented programming, classes, abstract methods etc. But I have never been a developer, and the last bit of OOP programming I have done was back in my uni days in Java... which by the way I have long since forgotten. You can see from my WHMCS module, it is more procedural, and not OOP at all. And even though I am familiar with the concept of OOP, I am not at all familiar with the PHP implementation. In fact, I have found a number of integration tasks with Blesta to be exceedingly difficult compared to WHMCS. For example, getting the template to look right was exceedingly difficult using the bootstrap method. Are most hosts using Blesta developers? It would seem to be less accessible for customization. No?
  3. I'm sorry but I don't get it. Can you give me an example how I set and get a variable so I can use it in the generating of payment button? Also, what about the error I see when I just renamed the module demo... What is causing the error?
  4. I should probably explain the module a bit. For CarrotPay, there are only 2 important peices of information that need to be configured within the admin area. 1.) Merchant ID - The ID of the merchant account (equivalent to Paypal e-mail address) 2.) HashSeed - A secret code/string that is used to generate hashes for verification. ------------------------------------------------------------------------------------------------------------------------------- In the file /whmcs/modules/gateways/carrot.php The first function [carrot_config] is responsible for defining the variables that need to be set in the admin area (merchant ID, hash seed and the url to the image for the payment button) The second function [carrot_link] generates the payment button. It takes all the relavent account information to populate the Javascript function, using the merchant ID, invoice number, amount and currency. It is then passed onto CarrotPay. ------------------------------------------------------------------------------------------------------------------------------- In the file /whmcs/modules/gateways/callbackCarrotPayCB.php This file handles what happens during the call back. CarrotPay takes the variables passed to it and returns the hash of those variables. The callback file takes the original variables, and hashes it with the hash seed. It then takes the returned hash and compares it with the one it just made. If they are the same, the payment is genuine and valid. Otherwise it's not. ------------------------------------------------------------------------------------------------------------------------------- In the file /whmcs/modules/gateways/carrot/hashword.php This file contains the actual function that generates the hash.
  5. Thanks for the feedback guys. Yes I have taken a look at the documentation and the SDK sample as well as looked at the Paypal module to see how it works. However I just don't get it. The documentation, to me, is less than clear and there are many irrelevant components in the Paypal example. I have no idea what can be removed, what I can add, or how to implant HTML/Javascript code into the invoice pages. For the life of me, I cannot find any information on this in the documentation. I thought I would try and take baby steps and at first just get the demo gateway uploaded with the name changed to carrotpay. Doing this resulted in the following error:
  6. File: /whmcs/modules/gateways/carrot.php <?php function carrot_config() { $configarray = array( "FriendlyName" => array("Type" => "System", "Value"=>"CarrotPay"), "merchant" => array("FriendlyName" => "Merchant ID", "Type" => "text", "Size" => "30", "Description" => "Your Merchant ID", ), "hashSeed" => array("FriendlyName" => "Hash Seed", "Type" => "text", "Size" => "30", "Description" => "Your Secret/HashSeed", ), "btnURL" => array("FriendlyName" => "Button URL", "Type" => "text", "Size" => "30", "Value"=>"http://www.carrotpay.com/images/buttons/btn88x31.gif","Description" => "URL to Button (Do not change for default)", ), ); return $configarray; }// end function carrot_config() function carrot_link($params) { # Gateway Specific Variables $gatewayusername = $params['merchant']; $gatewayhashSeed = $params['hashSeed']; $btnURL = $params['btnURL']; # Invoice Variables $invoiceid = $params['invoiceid']; $description = $params["description"]; $amount = $params['amount']; $currency = $params['currency']; # Currency Code $word = "id".$invoiceid.$amount; // Used to create Hash //$duedate = $params['duedate']; # Client Variables $firstname = $params['clientdetails']['firstname']; $lastname = $params['clientdetails']['lastname']; $email = $params['clientdetails']['email']; $address1 = $params['clientdetails']['address1']; $address2 = $params['clientdetails']['address2']; $city = $params['clientdetails']['city']; $state = $params['clientdetails']['state']; $postcode = $params['clientdetails']['postcode']; $country = $params['clientdetails']['country']; $phone = $params['clientdetails']['phone']; # System Variables $companyname = $params['companyname']; $systemurl = $params['systemurl']; $currency = $params['currency']; # Enter your code submit to the gateway... $code = '<br/> <script src="http://cdn.carrot.org/js/carrot.js" ></script> <script type="text/javascript"> <!-- <![CDATA[ function payWithCarrots(thePrice) { Carrot.pay({ price: thePrice, merchant: "'.$gatewayusername.'", description: "'.$description.'", return_url: "'.$systemurl.'/modules/gateways/callback/carrotPayCB.php?invoiceid='.$invoiceid.'&value='.$amount.'&currency='.$currency.'&hash=['.$word.']" }); }; function showPurse() { Carrot.purse(); } $(document).ready(function() { //Only for testing - not needed with live site // Carrot.debug = 1; // Carrot.purse_url = "https://secure.test.carrot.org:8443/webPurse.do"; // Carrot.payment_url = "https://secure.test.carrot.org:8443/payment"; $("#debug").html("<p>Looking for ID ...</p>"); Carrot.get_id(function(id) { if(id==null) $("#debug").html("<p>No id found</p>"); else $("#debug").html("<p>"+id+"</p>"); }); }); // ]]> --> </script> <a href="javascript:payWithCarrots(\''.$amount.':'.$currency.'\')"><img src="'.$btnURL.'" alt="Pay with CarrotPay"/></a> '; return $code; } ?> File: /whmcs/modules/gateways/carrot/hashword.php <?php function hash_word($word, $price, $seed) { // Lower case and strip dashes from seed $seed = strtolower($seed); $seed = str_replace("-", "", $seed); // Construct hash text from seed, price and word // Note space delimited $text = "$word $price $seed"; // Get md5 (hex string) $md5 = md5($text); // Get last 8 hex chars (32 bits, unsigned) $hex = substr($md5, -8); // Replace with 'safe' alphabet $safe = strtr($hex, "0123456789abcdef", "bcdghjklmpqrsvwz"); // Trim off leading 'b' (zero) return ltrim($safe, "b"); } ?> File: /whmcs/modules/gateways/callback/carrotPayCB.php <?php # Required File Includes include("../../../dbconnect.php"); include("../../../includes/functions.php"); include("../../../includes/gatewayfunctions.php"); include("../../../includes/invoicefunctions.php"); $gatewaymodule = "carrot"; # Enter your gateway module name here replacing template $GATEWAY = getGatewayVariables($gatewaymodule); if (!$GATEWAY["type"]) die("Module Not Activated"); # Checks gateway module is active before accepting callback # Required by CarrotPay for verification include ("../carrot/hashword.php"); $hash = $_GET['hash']; $invoiceid = $_GET['invoiceid']; $amount = $_GET['value']; //Gets the actual price $currency = $_GET['currency']; $word = "id".$invoiceid.$amount; // Used to create Hash $price = $amount.":".$currency; //Converts the pirce into carrots $seed = $GATEWAY["hashSeed"]; $hashval = hash_word($word,$price,$seed); $systemurl = $params['systemurl']; #Checks if transaction is valid $status="0"; if ($hashval == $hash) { $status = "1"; // set to '1' if valid } $transid = $hash; $fee = 0; //$invoiceid = checkCbInvoiceID($invoiceid,$GATEWAY["name"]); # Checks invoice ID is a valid invoice number or ends processing //checkCbTransID($transid); # Checks transaction number isn't already in the database and ends processing if it does if ($status=="1") { # Successful echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=/billing/viewinvoice.php?id=$invoiceid\"><h2>Redirecting</h2><p>Your payment was <b>sucessful</b> and you are being redirected now.</p><p>If you page does not redirect in 5 seconds, click <a href=\"/billing/viewinvoice.php?id=$invoiceid\">here</a>.</p>"; addInvoicePayment($invoiceid,$transid,$amount,$fee,$gatewaymodule); logTransaction($GATEWAY["name"],$_POST,"Successful"); } else { # Unsuccessful echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=/billing/viewinvoice.php?id=$invoiceid\"><h2>Redirecting</h2><p>Your payment has <b>failed</b>. An error occured during payment and you are being redirected now.</p><p>If your page does not redirect in 5 seconds, click <a href=\"/billing/viewinvoice.php?id=$invoiceid\">here</a>.</p>"; logTransaction($GATEWAY["name"],$_POST,"Unsuccessful"); } ?>
  7. Hi, I'm new to Blesta. Been using WHMCS for over 10 years but as I needed some automation features of which were not developed to work on WHMCS, I thought I'd give Blesta a try. I created a payment gateway module for WHMCS that works very well, and was very easy to implement. Unfortunately I'm finding it very difficult to understand how Blesta works and have not been able to make any progress at all in porting over the module. The gateway is a non-merchant gateway type. The gateway is CarrotPay (http://carrotpay.com). It's a very simple gateway and requires only a few params. The payment requires some javascript be included on the payment page. If anyone is willing/able to help, I'm happy to provide the WHMCS module I wrote before. Thanks in advance!
×
×
  • Create New...