1-You call internal API of whmcs within a hook file under /includes/hooks/
folder.
And how to that is the following :
http://docs.whmcs.com/API:Internal_API
2- You need to call "AfterShoppingCartCheckout" hook to do that.
Simply, create a php file under /includes/hooks/
folder, and within this file you can use the sample code below :
<?php
function myActionHookFunctionvars($vars) {
$orderId= $vars['OrderID'];
//Run code to dı what you want here,
// you can even call internal api here.
}
add_hook("AfterShoppingCartCheckout",1,"myActionHookFunctionvars");
?>