Jump to content

Davor

Member
  • Content Count

    30
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Davor

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hello, I'm trying to make my Paddle Gateway to work. In Paddle sandbox it works but when I change to production I'm an error "Something wrong" The problem is in this that I need to change this code: $htmlOutput .= '<form style="width:50px;margin-top:10px;" method="get" action="https://checkout.paddle.com/checkout/custom/abc123...">'; $htmlOutput .= '<input type="submit" value="Subscribe" />'; $htmlOutput .= '</form>'; To as they say in documentation and also as the support is telling: "pass the URL into Paddle.js using the override parameter. <a href="#!" class="paddle_button" data-override="https://checkout.paddle.com/checkout/custom/abc123...">Buy Now!</a> Here is the link to this docs on Paddle help: https://developer.paddle.com/guides/how-tos/checkout/pass-parameters#generating-pay-link-via-api Does anyone have an idea how to build the $htmlOutput? Thanks, Davor
  2. wow, thanks @pRieStaKos will try it as I return to office. Once again thanks, Davor
  3. Hello, if I understand correctly this help doc: https://developers.whmcs.com/advanced/db-interaction/ that the WHMCS is deprecating the Select. Could someone help me with converting this "Capsule::select" to "Capsule::table"? Here is the code: $currency = Capsule::select(Capsule::raw('SELECT t3.rate FROM tblinvoices AS t1 LEFT JOIN tblclients AS t2 ON t1.userid = t2.id LEFT JOIN tblcurrencies AS t3 ON t2.currency = t3.id WHERE t1.id = "' . $vars['invoiceid'] . '" AND t3.default = "0" LIMIT 1'))[0];
  4. Thanks @steven99 for your reply. It is correct that I want to add the taxes to the invoice, and this is after Paddle gets the payment from the customer and I'm updating the invoice with the correct numbers, if Paddle collected taxes I add taxes to the invoice. I have managed to find the solution. All of this is happening in the Gateway Callback after I get the webhook from Paddle that the transaction has been sucesful. The ting was that I was adding the payment (addInvoicePayment) before I was updating the invoices. Now that I have added the addInvoicePayment after this, everything is ok and the system updates the invoice items and also triggers the summary client data update. Thanks for taking the time and for responding @steven99 Davor
  5. Hello, How to update the Credit Balance for a client after changing the Invoice and InvoiceItems? I'm using Paddle for processing my payments. When sending the invoice data to Paddle I send it without taxes. Then Paddle handles the taxes and at the Subscription Payment Success webhook I get if there are any taxes. Then I change the Invoice Items and the Invoice. ((((Don't know if UpdateClientProduct autorecalc is not working in v8.2 or it is used for something else)))) At the end I also update the Invoice with tax amount and the new total with taxes. I'm new with WHMCS (2 months now) and PHP (3 months). Now, I can't find the way how to update or trigger something to update the Credit Balance on the Summary for Client. It is still the old value that was before adding taxes to Invoices. Is there an API to update the Clients amounts, including Credit Balance and do I need to update something else after my changes to the Invoices? Here the part of the code that is doing this: $withoutTax = $fields['balance_fee'] + $fields['balance_earnings']; $taxAmount = $fields['balance_tax']; $withTax = $fields['balance_gross']; if ( $withoutTax <> 0 ) { $taxPercent = round(($taxAmount / $withoutTax) * 100, 2); } else { $taxPercent = 0; } if ( $taxPercent <> 0 ) { $itemTaxed = 1; } else { $itemTaxed = 0; } $command = 'GetInvoice'; $values = array( 'invoiceid' => $invoiceId, ); //$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later // Call the localAPI function $invoice = localAPI($command, $values, $adminUsername); logModuleCall('paddle_checkout_gateway_callback', 'UpdateInvoice_localAPI_invoice', $invoice, ""); if ($invoice['result'] == 'success') { foreach ($invoice['items']['item'] as $item) { //error_log($vars['invoiceid'].' item '.$item['id'].' has description of "'.$item['description'].'"'); $text = $item['description']; $updatedInfo = array( 'invoiceid' => $invoiceId, 'taxrate' => $taxPercent, 'itemdescription' => array($item['id'] => $text), 'itemamount' => array($item['id'] => $item['amount']), 'itemtaxed' => array($item['id'] => $itemTaxed) ); $updatedInvoice = localAPI('UpdateInvoice', $updatedInfo, $adminUsername); logModuleCall('paddle_checkout_gateway_callback', 'UpdateInvoice', $updatedInfo, $updatedInvoice); } } else { //echo "An Error Occurred: " . $results['result']; } // let's now trigger the recalculate of each hostingId from this updated invoiceid // I think that this is not working in v8.2 or the UpdateClientProduct autorecalc is used for something else $invoiceitems = Capsule::table('tblinvoiceitems') ->where('invoiceid', $invoiceId) ->where('type', 'Hosting')->get(); //->first(); foreach( $invoiceitems as $invoiceitem ){ //$invoiceitem->relid this is the id from the tblHosting table $resultOfAPI = localAPI('UpdateClientProduct', array('serviceid' => $invoiceitem->relid, 'autorecalc' => true), $adminUsername); logModuleCall('paddle_checkout_gateway_callback', 'recalculateProductItems', $invoiceitem->relid, $resultOfAPI); } // 20210927 maybe a bug in v8.2 // not updating the tax and the total amount of the invoice with UpdateClientProduct 'autorecalc' // manualy updating the table tblinvoices try { Capsule::table('tblinvoices') ->where('id', $invoiceId) ->update([ "tax" => $taxAmount, "total" => $withTax ]); } catch (\Exception $e) { logModuleCall('paddle_checkout_gateway_callback', 'recalculateProductItems_ERROR', "tax " .$taxAmount . " total " .$withtax ,$e); echo "Error in updating tblInvoices. {$e->getMessage()}"; }
  6. Thanks @steven99 for interesting view of possible workaround and for taking the time. I need to think about it and test it heavily. Davor
  7. Hello, I'm creating for myself the Payment Gateway for Paddle and now I have some doubts how to proceed with refunds because refunds with Paddle are not automatic, but they need to be approved by Paddle team. So, now, when I make a refund in WHMCS, in the Payment Gateway code in the "paddle_refund" I send this request to the Paddle API and I don't get success or denied response immediately, but I need to return true or false from this function. And if I return false in the WHMCS portal it is displayed the error message that is something wrong, but if I return true the refund gets accepted in WHMCS, but the refund is not yet processed by Paddle. What is the best practice in this case? Or can I return some status like "Processing" in the function "paddle_refund" in the Payment Gateway code? Then in the WHMCS hook I'm waiting for the response from Paddle. This is not the problem, but what to do, what to return in "paddle_refund" function? Thanks, Davor
  8. Sorry to open up this 8 years old topic. But I would like to ask if, 8 years after, is there any change on this problem or is the only solution that the @WHMCS John proposed when a user want's to switch the period of his subscription? Thanks, Davor
  9. For my reference in future or if anyone also needs this. Here is the hook that works: # remove the "Quick Shorcuts" from the Client Portal > Product Details add_hook('ClientAreaProductDetailsOutput', 1, function($vars) { return "<style> #cPanelQuickShortcutsPanel {display: none;} </style>"; });
  10. I want to remove the "Quick Shortcuts" from: Client Area > My Products & Services > Product Details I'm trying with this hook code, but no luck: # remove the "Quick Shorcuts" from the Client Portal > Product Details add_hook('ClientAreaPageProductDetails', 1, function($vars) { return "<style> .cPanelQuickShortcutsPanel {display: none;} </style>" });
  11. Found what it was. If anyone also is having this problem (or for my future me). My solution was to ditch the Select and get the whole row and then get the id. Here is the working code: $orderId = Capsule::table('tblorders') ->where('invoiceid', $invoiceId) ->first(); //in the code use this to get the id $myID = $invoiceId->id
  12. Hello, I want to get the orderId from the database based on the invoiceId directly from database using Capsule. I don't get anything, also with try catch I don't get any errors. Here is the code that I'm using: use WHMCS\Database\Capsule; $orderId = Capsule::table('tblorders')->select('id') ->where('invoiceid', $invoiceId) ->first(); The $invoiceId is for example 74 and there is a record in the database table tblorders that contains this invoiceId. Can anyone see what I'm doing wrong? Thanks, Davor
  13. Maybe this can help, it is from 2016, but it maybe still works. I didn't used this or tested it. https://whmcs.community/topic/262429-adding-facebook-share-button-in-knowledgebase-articles/
  14. And to see where are you, there is "You are here:" that displays where are you in the hiearchy and to go back in the previous category or to the KB homepahe
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated