Properties

$_requestAdapter

$_requestAdapter : \CheddarGetter_Http_AdapterInterface

The adapter to access cookie data and such.

By default, it will use PHP superglobals directly but an implementation based on the abstraction of a framework can be used.

Type

\CheddarGetter_Http_AdapterInterface

$_username

$_username : string

Type

string — Username credential for accessing the CheddarGetter API

$_password

$_password : string

Type

string — Password credential for accessing the CheddarGetter API

$_url

$_url : string

Type

string — URL for accessing the CheddarGetter API

$_productCode

$_productCode : string

Type

string — Product identifier

$_productId

$_productId : string

Type

string — Product identifier (not necessary if productCode is used)

$_marketingCookieName

$_marketingCookieName : string

Type

string — Name to use for the marketing cookie

$_httpClient

$_httpClient : \CheddarGetter_Client_AdapterInterface

If you don't use Zend Framework, it's ok, the client will fallback to curl (so you need curl).

Type

\CheddarGetter_Client_AdapterInterface

Methods

__construct()

__construct(mixed $url, mixed $username, mixed $password, mixed $productCode, string $productId, \CheddarGetter_Client_AdapterInterface $adapter)

Constructor

Parameters

mixed $url

string

mixed $username

string

mixed $password

string

mixed $productCode

string

string $productId
\CheddarGetter_Client_AdapterInterface $adapter

setUrl()

setUrl(mixed $url) : \CheddarGetter_Client

Set URL neccessary for for accessing the CheddarGetter API

Parameters

mixed $url

string

Returns

\CheddarGetter_Client

getUrl()

getUrl() : string

Get URL

Returns

string

setUsername()

setUsername(mixed $username) : \CheddarGetter_Client

Set username neccessary for for accessing the CheddarGetter API

Parameters

mixed $username

string

Returns

\CheddarGetter_Client

getUsername()

getUsername() : string

Get username

Returns

string

setPassword()

setPassword(mixed $password) : \CheddarGetter_Client

Set password neccessary for accessing the CheddarGetter API

Parameters

mixed $password

string

Returns

\CheddarGetter_Client

setProductCode()

setProductCode(mixed $productCode) : \CheddarGetter_Client

Set product code (required for all calls except getAllCustomers)

Parameters

mixed $productCode

string

Returns

\CheddarGetter_Client

getProductCode()

getProductCode() : string

Get current product code

Returns

string

setProductId()

setProductId(mixed $productId) : \CheddarGetter_Client

Set product id (required for all calls except getAllCustomers unless productCode is used)

Parameters

mixed $productId

string

Returns

\CheddarGetter_Client

getProductId()

getProductId() : string

Get current product id

Returns

string

setMarketingCookieName()

setMarketingCookieName(mixed $name) : \CheddarGetter_Client

Set name for marketing metrics cookie

Parameters

mixed $name

string

Returns

\CheddarGetter_Client

getMarketingCookieName()

getMarketingCookieName() : string

Get marketing cookie name

Returns

string

__call()

__call(string $method, array $args)

Magic method wrapper

Essentially just a sanity check making sure we have a productCode for those methods that require it

Parameters

string $method
array $args

getPlans()

getPlans(array|null $filters) : \CheddarGetter_Response

Get pricing plans

Get all plans in the product.

Parameters

array|null $filters

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

getPlan()

getPlan(string $code, string|null $id) : \CheddarGetter_Response

Get a single pricing plan

Parameters

string $code

Your code for the plan

string|null $id

CG id for the plan

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

deletePlan()

deletePlan(string $code, string|null $id) : \CheddarGetter_Response

Delete a plan

Parameters

string $code

Your code for the plan

string|null $id

CG id for the plan

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

getCustomers()

getCustomers(array|null $filters) : \CheddarGetter_Response

Get customers (DEPRECATED: use getCustomersList to query for multiple customers)

Get all customers in the product

Parameters

array|null $filters

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

getCustomersList()

getCustomersList(array|null $filters) : \CheddarGetter_Response

Get customers

Get all customers in the product

Parameters

array|null $filters

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

getCustomer()

getCustomer(string $code, string|null $id) : \CheddarGetter_Response

Get a single customer

Parameters

string $code

Your code for the customer

string|null $id

CG id for the customer

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

getAllCustomers()

getAllCustomers(array|null $filters) : \CheddarGetter_Response

Get all customers

Get all customers subscribed to any product

Parameters

array|null $filters

Throws

\CheddarGetter_Client_Exception
\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

newCustomer()

newCustomer(array $data) : \CheddarGetter_Response

Create new customer

Parameters

array $data

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

importCustomers()

importCustomers(array $data) : \CheddarGetter_Response

Import customers in bulk

Parameters

array $data

An array of arrays

Throws

\CheddarGetter_Client_Exception
\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

editCustomer()

editCustomer(string $code, string|null $id, array $data) : \CheddarGetter_Response

Change customer and subscription information

Parameters

string $code

Your code for the customer

string|null $id

CG id for the customer

array $data

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

editCustomerOnly()

editCustomerOnly(string $code, string|null $id, array $data) : \CheddarGetter_Response

Change customer information only

Parameters

string $code

Your code for the customer

string|null $id

CG id for the customer

array $data

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

deleteCustomer()

deleteCustomer(string $code, string|null $id) : \CheddarGetter_Response

Delete a customer

Parameters

string $code

Your code for the customer

string|null $id

CG id for the customer

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

deleteCustomers()

deleteCustomers() : \CheddarGetter_Response

Delete all customers

WARNING: This will delete all customers and all related data in CheddarGetter and will delete all customer data at the gateway if a gateway is configured.

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

editSubscription()

editSubscription(string $code, string|null $id, array $data) : \CheddarGetter_Response

Change subscription information

Parameters

string $code

Your code for the customer

string|null $id

CG id for the customer

array $data

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

cancelSubscription()

cancelSubscription(string $code, string|null $id) : \CheddarGetter_Response

Cancel subscription

Parameters

string $code

Your code for the customer

string|null $id

CG id for the customer

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

paypalRevert()

paypalRevert(string $code, string|null $id) : \CheddarGetter_Response

PayPal Revert (workaround)

This is an experimental workaround for some PayPal shortcomings. It should be unecessary in the near future.

Parameters

string $code

Your code for the customer

string|null $id

CG id for the customer

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

addItemQuantity()

addItemQuantity(string $code, string|null $id, array $data) : \CheddarGetter_Response

Increment a usage item quantity

Parameters

string $code

Your code for the customer

string|null $id

CG id for the customer

array $data

Your (itemCode or CG itemId) and [quantity]

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

removeItemQuantity()

removeItemQuantity(string $code, string|null $id, array $data) : \CheddarGetter_Response

Decrement a usage item quantity

Parameters

string $code

Your code for the customer

string|null $id

CG id for the customer

array $data

Your (itemCode or CG itemId) and [quantity]

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

setItemQuantity()

setItemQuantity(string $code, string|null $id, array $data) : \CheddarGetter_Response

Set a usage item quantity

Parameters

string $code

Your code for the customer

string|null $id

CG id for the customer

array $data

Your (itemCode or CG itemId) and quantity

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

addCharge()

addCharge(string $code, string|null $id, array $data) : \CheddarGetter_Response

Add a custom charge (debit) or credit to the current invoice

A positive 'eachAmount' will result in a debit. If negative, a credit.

Parameters

string $code

Your code for the customer

string|null $id

CG id for the customer

array $data

chargeCode, quantity, eachAmount[, description]

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

deleteCharge()

deleteCharge(string $code, string|null $id, array $data) : \CheddarGetter_Response

Delete a custom charge (debit) or credit from the customer's current invoice

CG's chargeId is required (found in the customers/get response)

Parameters

string $code

Your code for the customer

string|null $id

CG id for the customer

array $data

chargeId

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

newOneTimeInvoice()

newOneTimeInvoice(string $code, string|null $id, array $data) : \CheddarGetter_Response

Create a new one-time invoice

One-time invoices take one or more charges in the same format as newCustomer(). One-time invoices are executed immediately using the customer's existing subscription payment method. One-time invoices do not directly effect the subscription pending invoice or billing period.

Parameters

string $code

Your code for the customer

string|null $id

CG id for the customer

array $data

an array of arrays each with: chargeCode, quantity, eachAmount[, description]

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

voidOrRefundInvoice()

voidOrRefundInvoice(string $number, string|null $id) : \CheddarGetter_Response

Void or refund invoice

Voiding and refunding can be a bit tricky. Some billing solutions do not allow refunding while a transaction is "voidable". Transactions are usually voidable only for a short time (less than 24 hours). Some billing solutions do not allow voids. Check out the knowledge base article on the subject for more information: {@link http://support.cheddargetter.com/kb/operational-how-tos/credits-and-refunds-and-voids-oh-my}

Parameters

string $number

The unique number of the invoice to be voided/refunded generated by CheddarGetter.

string|null $id

CG id of the invoice

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

voidInvoice()

voidInvoice(string $number, string|null $id) : \CheddarGetter_Response

Void invoice

Voiding and refunding can be a bit tricky. Some billing solutions do not allow refunding while a transaction is "voidable". Transactions are usually voidable only for a short time (less than 24 hours). Some billing solutions do not allow voids. Check out the knowledge base article on the subject for more information: {@link http://support.cheddargetter.com/kb/operational-how-tos/credits-and-refunds-and-voids-oh-my}

Parameters

string $number

The unique number of the invoice to be voided/refunded generated by CheddarGetter.

string|null $id

CG id of the invoice

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

refundInvoice()

refundInvoice(string $number, string|null $id, array $amount) : \CheddarGetter_Response

Refund invoice

Voiding and refunding can be a bit tricky. Some billing solutions do not allow refunding while a transaction is "voidable". Transactions are usually voidable only for a short time (less than 24 hours). Some billing solutions do not allow voids. Check out the knowledge base article on the subject for more information: {@link http://support.cheddargetter.com/kb/operational-how-tos/credits-and-refunds-and-voids-oh-my}

Parameters

string $number

The unique number of the invoice to be voided/refunded generated by CheddarGetter.

string|null $id

CG id of the invoice

array $amount

The amount to be refunded if a partial refund. If the invoice is to be fully refunded, do not pass the amount.

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

runOutstandingInvoice()

runOutstandingInvoice(string $code, string|null $id, array $data) : \CheddarGetter_Response

Run an outstanding invoice

An outstanding invoice might be one that hasn't been transacted yet or one that has been attempted unsucessfully.

Parameters

string $code

Your code for the customer

string|null $id

CG id for the customer

array $data

[ccCardCode] (optional)

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

sendEmailReceipt()

sendEmailReceipt(string $number, string|null $id) : \CheddarGetter_Response

Send an invoice receipt email

Resend an invoice receipt email. For any transacted invoice. Relevant email notification must be enabled in CG config.

Parameters

string $number

The unique number of the invoice.

string|null $id

CG id of the invoice

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

getPromotions()

getPromotions(array|null $filters) : \CheddarGetter_Response

Get promotions

Get all promotions in the product.

Parameters

array|null $filters

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

getPromotion()

getPromotion(string $code, string|null $id) : \CheddarGetter_Response

Get a single promotion

Parameters

string $code

Coupon code

string|null $id

CG id for the promotion

Throws

\CheddarGetter_Response_Exception

Returns

\CheddarGetter_Response

setHttpClient()

setHttpClient(\CheddarGetter_Client_AdapterInterface|\Zend_Http_Client|resource $client) : \CheddarGetter_Client

Set http client

Parameters

\CheddarGetter_Client_AdapterInterface|\Zend_Http_Client|resource $client

Either a Zend_Http_Client or curl resource.

Throws

\CheddarGetter_Client_Exception

Returns

\CheddarGetter_Client

setMarketingCookie()

setMarketingCookie(string $cookieName, int $expire, string $path, string $domain, bool $secure, bool $httpOnly)

Convenience wrapper of setcookie() for setting a persistent cookie containing marketing metrics compatible with CheddarGetter's marketing metrics tracking.

Running this method on every request to your marketing site sets or refines the marketing cookie data over time. There is no performance disadvantage to running this method on every request.

If a lead has this cookie set at the time of signup, CheddarGetter_Client::newCustomer() will automatically add the data to the customer record. In other words, simply run this method on every request and there's nothing else to do to take advantage of the metrics tracking in CheddarGetter.

{@link http://support.cheddargetter.com/faqs/marketing-metrics/marketing-metrics More about CheddarGetter's marketing metrics tracking }

Parameters

string $cookieName
int $expire
string $path
string $domain
bool $secure
bool $httpOnly

Throws

\CheddarGetter_Client_Exception

if headers are already sent

request()

request(string $path, array|null $args) : string

Execute CheddarGetter API request

Parameters

string $path

Path to the API action

array|null $args

HTTP post key value pairs

Throws

\CheddarGetter_Client_Exception

Returns

string —

Body of the response from the CheddarGetter API

_getPassword()

_getPassword() : string

Get current password

Returns

string

_requireIdentifier()

_requireIdentifier(string $code, string $id) : bool

Convenience method for requiring an identifier

Parameters

string $code
string $id

Throws

\CheddarGetter_Client_Exception

if neither identifier exists

Returns

bool —

true if $code or $id exists