plesk/api-php-lib

Create subscription for a customer

johnhart96 opened this issue · 7 comments

Hi Guys,

I am trying to use this api. I can create a customer successfuly but I am unable to add a subscription based on my service plans.

Please can someone explain to me how to do this?

Thanks

John

Hi @johnhart96,

If you still need how to do it please see below, I worked it out by looking at the Tests folder in the GitHub repository that gives you a great idea of what to call and how to call it.

$client->webspace()->create( [ 'name' => 'test.com', 'ip_address' => '123.456.123.456', 'owner-id' => '1234' ], [ 'ftp_login' => "user", 'ftp_password' => "password" ], 'Name of Plan' );

Kind regards,

Alan.

I was having the same issue, thanks @alantiller
It does create the webspace but it doesn't create hosting. How to fix this? I'm quite lost. Thnaks

@mister97 what code are you using, when I tested this it created the website and hosting at the same time, I had to create the customer first so I had the owner-id but otherwise it just worked.

@alantiller here's my code:

// Create a new customer account
   $customer = $client->customer()->create([
      'cname' => 'Plesk',
      'pname' => 'John Smith',
      'login' => 'john',
      'passwd' => 'password',
      'email' => 'john@smith.com',
   ]);

   // Create a new webspace for the customer
   $webspace = new \PleskX\Api\Operator\Webspace($client);
   $client->webspace()->create([ 
      'name' => 'johndoe.com', 
      'ip_address' => '123.456.789.012', 
      'owner-id' => $customer->id 
   ], 
   [ 
      'ftp_login' => "johndoeftp", 
      'ftp_password' => "password" 
   ], 
      'Default Domain' 
   );

@alantiller I suppose you have no idea?