Jump to content

Jake

Members
  • Posts

    10
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Jake

  1. OK...I updated that but now it gives me the following error:

     

     [lines[0][description]] => stdClass Object
            (
                [empty] => Please enter a line item description.
            )

    The documentation does not show that I need to provide that information.  How am I supposed to add that info?

  2. I have a two part question.   

    First,  I'm trying to figure out the workflow for creating a service from invoice.  My current workflow in my app is the following:

    Create user -> add Credit card data -> create a service -> create the invoice -> pay the invoice with the save CC data ->update the service to active.  

    My question is if I create a service will the system automatically create an invoice when the CRON is run or should I do it through the API.  The way I am currently doing it seems like a lot of calls and I would prefer to lower the amount of calls I am making.  Is there a better way?

     

    Secondly I am trying to create an invoice from a service but it is giving me an error 

    $BlestaCreateData    = array(
                                        
                                            'client_id'         => 23,
                                            'services_ids'      => array(26),
                                            'currency'          => 'USD',
                                            'due_date'          => date("c"),
                                            'allow_pro_rata'    => false, 
                                            'services_renew'    => true,
                                        );
                                        
          
                                        $response =  $this->blestaapi->post('invoices', 'createFromServices', $BlestaCreateData);
                                        echo '<pre>';
                                      
                                        $RetVal = $response;
                                        
                                        print_r($response->response());
                                        print_r($response->errors());

    The error is 

     

    Class Object
    (
        [error] => stdClass Object
            (
                [message] => An unexpected error occured.
                [response] => Internal error: Failed to retrieve the default value
            )
    
    )

    What am I missing?

  3. I am using the API and I have successfully connected and used it to do other tasks like creating a user.  I am trying to add a service for a user and I am running up against an error:

    I am executing the following code:

     $BlestaCreateData    = array(
                                        'vars' => array(
                                                        'client_id '        => 1512,
                                                        'use_module '       => false,
                                                        'pricing_id'        => 19,
                                                        'packages'          => array(15)
                                                    )
                                        );
           
          
                                        $response =  $this->blestaapi->post('services', 'add', $BlestaCreateData);
                                        echo '<pre>';
                                        $RetVal = $response;
                                        
                                       echo var_dump($RetVal);

    When I execute the code I am getting the following error:

     

    object(BlestaResponse)#34 (2) {
      ["raw":"BlestaResponse":private]=>
      string(143) "{"message":"The request cannot be fulfilled due to bad syntax.","errors":{"client_id":{"exists":"The client does not exist."}},"response":null}"
      ["response_code":"BlestaResponse":private]=>
      int(400)
    }

     

    I am not sure if I should pass the database id value from the clients table or the id_value.  I've tried both and I keep getting the same error. Is there something I am missing?

     

     

  4. I'm having a problem connecting to the API.  

    I have setup an API key and user.  I am trying to connect to the API via the following code:


               

                $User   = "my_user_Name";
                $Key    = "My_key";
                $Url    = "My_url";
    
                $this->blestaapi->SetVariables($Url, $User, $Key);
           
                $Response = $this->blestaapi->get("users", "get", array('user_id' => 3));
    
                print_r($Response->response());
                print_r($Response->errors());

    I had to change the API file just a bit because the way my application is setup to initialize the class before I can pass the username and key.  So I created a setter method to do that. The Blesta API class now looks like this:

     

    	public function __construct() {}
            
            public function SetVariables($url, $user, $key)
            {
                $this->url  = $url;
    			$this->user = $user;
    			$this->key  = $key;
            }


                When I run the app the error message I get is:

    stdClass Object
    (
        [user] => stdClass Object
            (
                [valid] => The API user or key appears to be invalid.
            )
    
    )

    I have verified that the object does in fact have the username and key with a var dump of the object.  Any Ideas of what the problem could be?
              

×
×
  • Create New...