plesk / api-php-lib

PHP library for Plesk XML-RPC interface
Other
139 stars 80 forks source link

Create subscription for a customer #115

Closed johnhart96 closed 1 year ago

johnhart96 commented 2 years ago

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

alantiller commented 1 year ago

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.

mister97 commented 1 year ago

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

alantiller commented 1 year ago

@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.

mister97 commented 1 year ago

@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' 
   );
mister97 commented 1 year ago

@alantiller I suppose you have no idea?

sibprogrammer commented 1 year ago

@mister97 It depends on your hosting plan. Hosting can be disabled in the plan, so the created subscription/webspace will have no hosting. Overwise the webspace should be created with enabled hosting.

sibprogrammer commented 1 year ago

I'll close the request because @alantiller provided a good answer to the question. The original author of the question didn't provide enough details and the issue looks stalled.

P.S. @alantiller thank you for your contribution!