pRieStaKos Posted August 12, 2016 Share Posted August 12, 2016 (edited) Hello, im trying to make an addon for adding a gateway charge but I cant make it run after the client checks the payment method and proceed to view invoice. My hook is the following: function hook_fee_InvoiceChangeGateway($vars) { include "lang/greek.php"; try { $invoiceid = $vars['invoiceid']; $paymentmethod = $vars['paymentmethod']; // Get invoice subtotal $query = Capsule::table('tblinvoices') ->where('id', $invoiceid) ->where('paymentmethod', $paymentmethod) ->get(); $totalDue = $query->subtotal; $userid = $query->userid; if ($paymentmethod == 'paypal') { // Get Gateway fee $query = Capsule::table('mod_fee')->where('gateway', $paymentmethod)->get(); // Recalculate $percentageFee = $query->percentage; $amountFee = ($percentageFee / 100) * $totalDue; // Add gateway charge to invoice as item Capsule::table('tblinvoiceitems')->insert( [ 'invoiceid' => $invoiceid, 'userid' => $userid, 'type' => 'GatewayCharge', 'relid' => '', 'description' => 'Paypal 3.40%', 'amount' => $amountFee, 'taxed' => 1, 'duedate' => 1, 'paymentmethod' => $paymentmethod, 'notes' => '', ] ); echo "Gateway Charge of {$amountFee} is added to Invoice {$invoiceid}"; } else { Capsule::table('tblinvoiceitems') ->where('type', 'GatewayCharge') ->where('invoiceid', $invoiceid) ->delete(); } } catch (\Exception $e) { echo "Uh oh! {$e->getMessage()}"; } } add_hook('InvoiceChangeGateway', 1, 'hook_fee_InvoiceChangeGateway'); Any suggestions why this hook is not running and not adding a new invoiceitem in the invoice with the charge ? Thank you in advance Edited August 12, 2016 by priestakos 0 Quote Link to comment Share on other sites More sharing options...
nperez Posted August 18, 2016 Share Posted August 18, 2016 Hello Priestakos, I am trying to do the same thing, however, I have found a module from ModulesGarden that does this for any payment gateway. It's called "Payment Gateway Charges". Have you looked into this? I'm having some issues with it so I was looking for other solutions, it seems you are developing your own addon to do the same thing, are you making it for a specific gateway? I am interested to know how it is going for you. Thanks, Nick 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 18, 2016 Share Posted August 18, 2016 there is an third-party module available from the App Store... http://www.whmcs.com/appstore/1626/Set-Gateway-Transaction-Fee.html I don't know if it's been updated for v6 (you should check with the developer before purchase), but their website (using v6) is still offering the module for a one-off $20. also, there is an open-source Gateway Fee module @ GitHub... which, going by it's age, I assume works for v5 but probably not v6 - but it may help with your coding. https://github.com/delta360/WHMCS-Gateway-Fees 0 Quote Link to comment Share on other sites More sharing options...
pRieStaKos Posted August 18, 2016 Author Share Posted August 18, 2016 (edited) Hello Priestakos, I am trying to do the same thing, however, I have found a module from ModulesGarden that does this for any payment gateway. It's called "Payment Gateway Charges". Have you looked into this? I'm having some issues with it so I was looking for other solutions, it seems you are developing your own addon to do the same thing, are you making it for a specific gateway? I am interested to know how it is going for you. Thanks, Nick I manage to make progress, with a little help from my friend zstergios but I haven't finish it completly. I'm on a summer break. Payment Gateway Charges from ModulesGarden got miss-calculate issues and on every update, I have to contact them in order to fix the calculation function again. I dont have the luxury to do it on every update. So I will do it on my own. there is an third-party module available from the App Store... http://www.whmcs.com/appstore/1626/Set-Gateway-Transaction-Fee.html I don't know if it's been updated for v6 (you should check with the developer before purchase), but their website (using v6) is still offering the module for a one-off $20. also, there is an open-source Gateway Fee module @ GitHub... which, going by it's age, I assume works for v5 but probably not v6 - but it may help with your coding. https://github.com/delta360/WHMCS-Gateway-Fees I already seen this and other open-source modules, even the WHMCS documentation (that should have been updated already, but its not). I already got the idea, but WHMCS seems not to run or log many of my functions. Note: Due to development, I already updated my module source code, so I overcome many of my issues with WHMCS not running the hook. The above function code is old and changed. Edited August 18, 2016 by priestakos 0 Quote Link to comment Share on other sites More sharing options...
nperez Posted August 19, 2016 Share Posted August 19, 2016 Priestakos, I tried private messaging you but I don't believe I have sufficient permissions as I am new on the forum. Would you be willing to possibly sell the module you're developing? I've considered purchasing the other third-party module from the App store that brian! mentioned but it has not been updated in quite some time so I am skeptical. Let me know if its even a possibility for you, we can discuss it further privately. Nick 0 Quote Link to comment Share on other sites More sharing options...
pRieStaKos Posted August 19, 2016 Author Share Posted August 19, 2016 I cannot sell a module that is not tested 100%. ModuleGarden module is on v.6.2 that was updated early this month, but got issues that the developers must fix permently with the calculations. Maybe you could check it with them, because I can't right now. 0 Quote Link to comment Share on other sites More sharing options...
pRieStaKos Posted August 22, 2016 Author Share Posted August 22, 2016 UPDATE: I finished my addon module and now im on masspay function. I cannot find any hooks that get all the invoices (or invoiceItems) in masspay page. Documentation is not helping. Any suggestions ? 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.