Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/12/2019 in all areas

  1. Michael

    BlestaForums in pre-beta

    I started BlestaForums to get a community forum part of Blesta and make it more integrated and amazing. I've been very busy lately working in my new job as-well and I've been doing other things. Timothy (@timnboys) has been helping complete the forums as he wanted to get it to work on his site instead of the paid and free ones. So together we've been doing the Blesta Forums and we're proud to announce that it's now in Pre-beta! This means we're testing it with our own customers so we can ensure it's as bug free as we can before the private beta emerges. Both of us will be selling the product with our own licensing servers and we'll both support it's growth together. it will be open code minus the encoding for licensing purposes and we have so much planned. I've got a to-do list here: https://atlantis.plutio.com/p/blestaforums He's a small preview for our non customers: Our site: https://blesta.store/client/plugin/blesta_forums/ Timothy's site: https://cubedata.net/client/plugin/blesta_forums/
    1 point
  2. re-uploaded the files again and is working now .
    1 point
  3. I think it's first important to understand the payment flow here. When a payment is made using a non-merchant gateway, the gateway is unaware of how the invoice it is intending to pay is created, or even if there is an invoice at all. You can make a payment using the non-merchant gateway to pay for nothing. In your case, however, you want to pay for an invoice created from an order in the order system using the Order plugin. This is a special case, and should be treated as such. Which means, you should not rely on this to always be true, and must setup logic to handle the cases where it is not. In your non-merchant gateway's class, you should have defined a buildProcess method. This method accepts, optionally, an array of invoice amounts as its third parameter. In that array is a list of IDs representing the invoices being paid. If you are paying an invoice on the order form, you should only have one invoice ID in the list. You need to take this invoice ID and find the associated order ID from the order system. Considering the order system is a plugin, it may not be installed for the company. You should check that it is first. Loader::loadModels($this, array("PluginManager")); $order_number = "N/A"; // Is the Order plugin installed? if ($this->PluginManager->isInstalled("order", Configure::get("Blesta.company_id"))) { ... } The Order plugin associates an invoice with the order, so you must find the correct order that matches the invoice ID you were given. However, the Order plugin does not provide a method to find an order by invoice, so you must write your own. First, make sure you have an invoice number. $invoice_id = null; if (isset($invoice_amounts[0])) { $invoice_id = $invoice_amounts[0]['id']; } Now you need to find the order number associated with the invoice. Since the Order plugin does not have a method for doing this, you can either 1) add a method for it to do it from the OrderOrders model by updating the source code yourself, or use the Record component to query the database for it manually. The later is more difficult as you will need to manually connect to the database by passing valid credentials yourself. See here for an example of someone that has. I will skip that part and simply assume the Record component is setup to perform a query. Loader::loadComponents($this, array("Record")); # # TODO: create a connection to the database # try { $order = $this->Record->select()->from("order_orders") ->where("invoice_id", "=", $invoice_id)->fetch(); if ($order) { $order_number = $order->order_number; } } catch (Exception $e) { // Unable to fetch the order number } Putting it all together now: Loader::loadModels($this, array("PluginManager")); Loader::loadComponents($this, array("Record")); $order_number = "N/A"; // Is the Order plugin installed? if ($this->PluginManager->isInstalled("order", Configure::get("Blesta.company_id"))) { // Do we have one invioce? $invoice_id = null; if (isset($invoice_amounts[0]) && count($invoice_amounts) === 1) { $invoice_id = $invoice_amounts[0]['id']; # # TODO: create a connection to the database so we can run a query # // Can we fetch an order for this invoice? try { $order = $this->Record->select()->from("order_orders") ->where("invoice_id", "=", $invoice_id)->fetch(); if ($order) { $order_number = $order->order_number; } } catch (Exception $e) { // Unable to fetch the order number } } } // Use the $order_number
    1 point
×
×
  • Create New...