Jump to content

Is there a hook to disable automatic service setup/domain registration for a particular payment method "Stripe"


Recommended Posts

Hello,

I need a solution to disable the auto-provision of services and domains for a particular payment method "Stripe". I need it to review all the orders from Stripe to prevent fraud. I know whmcs offers to disable the automatic setup on the product/service page by default. However, that is not a solution because I want to disable automatic setup for a particular gateway only.

I have prepared a hook but it's not working. May someone help me to fix that?

 

<?php
use WHMCS\Database\Capsule;

add_hook('PreModuleCreate', 1, function($vars) {
    // Get the service ID from the hook
    $serviceId = $vars['serviceid'];

    // Fetch the order associated with the service
    $order = Capsule::table('tblhosting')
        ->join('tblorders', 'tblhosting.orderid', '=', 'tblorders.id')
        ->where('tblhosting.id', $serviceId)
        ->select('tblorders.paymentmethod', 'tblorders.id as orderid')
        ->first();

    // Check if the payment method is Stripe
    if ($order->paymentmethod == 'stripe') {
        // Log activity to indicate auto-setup was prevented
        logActivity("Module creation prevented for order #{$order->orderid} due to Stripe payment method.");

        // Abort the module creation (prevent auto-setup)
        return ['abortcmd' => true];
    }
});

 

Link to comment
Share on other sites

Hello,

1) The hook looks okay for me, can you print the array $order and make sure that the paymentmethod value is saved as "stripe" for the orders using stripe?

2) Another solution is, you can create an addon module to configure the gateways you want to prevent auto accept of orders,

then those orders won't be accepted manually. 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • 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