Hi there guys,
I'm trying to use the API to add a free service (it's completely free of charge) to a customer when he register a domain (it must be active as soon as the domain is successfully registered, so it must be automatic). So I use the AfterRegistrarRegistration hook and everything is okay until the point I call AddOrder, like this:
$command = 'AddOrder';
$postData = array(
'clientid' => $userid,
'pid[0]' => $pid,
'paymentmethod' => 'mailin',
);
$orderIt = localAPI($command, $postData, $adminUsername);
It gives me {"result":"error","message":"No items added to cart so order cannot proceed"}.
I don't see a way to add items to the cart and there is no cart when the hook is triggered, so how should I add the service to the customer. I couldn't find a direct way to do it, so I went with adding an order, but at this moment that doesn't work.
P.S. The $postData values, in case someone might think they are causing the error somehow: {"clientid":"3","pid[0]":"4","paymentmethod":"mailin"}