PHP code example of cheddar-getter / client

1. Go to this page and download the library: Download cheddar-getter/client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cheddar-getter / client example snippets



	$client = new CheddarGetter_Client(
		'https://[theurlforcheddargetter.com]',
		'[yourusername]',
		'[yourpassword]',
		'[yourproductcode]'
	);


  $data = array(
    'code'      => 'EXAMPLE_CUSTOMER',
    'firstName' => 'Example',
    'lastName'  => 'Customer',
    'email'     => '[email protected]',
    'subscription' => array(
      'planCode'      => 'THE_PLAN_CODE',
      'ccFirstName'   => 'Example',
      'ccLastName'    => 'Customer',
      'ccNumber'      => '4111111111111111',
      'ccExpiration'  => '04/2011'
    )
  );

  $customer = $client->newCustomer($data);
	print_r($customer->toArray());
	echo $customer->toJson();


	$customer = $client->getCustomer('EXAMPLE_CUSTOMER');
	print_r($customer->toArray());
	echo $customer->toJson();


$data = array(
  'code'      => 'EXAMPLE_CUSTOMER',
  'firstName' => 'Example',
  'lastName'  => 'Customer',
  'email'     => '[email protected]',
  'subscription' => array(
    'planCode' => 'A_PAID_PLAN',
    'ccFirstName'   => 'Example',
    'ccLastName'        => 'Customer',
    'ccNumber'      => '4111111111111111',
    'ccExpiration'  => '04/2011'
  )
);
try {
	$customer = $client->newCustomer($data);
	// under some circumstances, the customer is created but
	// contains an embedded error that needs to be handled
	$customer->handleEmbeddedErrors();
} catch (CheddarGetter_Response_Exception $re) {
  die($re->getCode() . '-' . $re->getAuxCode() . ': ' . $re->getMessage());
}


	$client = new CheddarGetter_Client(
		'https://theurlforcheddargetter.com',
		'[yourusername]',
		'[yourpassword]',
		'[yourproductcode]',
		new MyHTTPAdapter()
	);
	$customers = $client->getCustomers();
	print_r($customers->toArray());
	echo $customers->toJson();


	CheddarGetter_Client::setHttpClient(
		new MyCustomClient()
	);


	CheddarGetter_Client::setRequestAdapter(
		new MyCustomAdapter()
	);