Skip to content

Customers

waqastanoli10 edited this page Feb 12, 2020 · 2 revisions

Customers allow you to perform charges or authorize and track multiple charges or authorize that are associated with the same customer. The SDK allows you to create, delete, and update your customers.

Create Customer

Creates a new customer by passing the customer information as an array. Returns a customer object.

$customer_created = GoSell\Customers::create([
  "first_name"=> "test",
  "middle_name"=> "test",
  "last_name"=> "test",
  "email"=> "test@test.com",
  "phone"=> [
    "country_code"=> "965",
    "number"=> "00000000"
  ],
  "description"=> "test",
  "metadata"=> [
    "udf1"=> "test"
  ],
  "currency"=> "KWD"
]);

echo '<pre>';var_dump($customer_created);

Retrieve a Customer

Retrieves the details of an existing customer. You need only supply the unique customer identifier that was returned upon customer creation.

$retrieved_customer = GoSell\Customers::retrieve($customer_created->id);

var_dump($retrieved_customer);

Update Customer

Updates the specified customer by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

This request accepts mostly the same arguments as the customer create call. First parameter of update method is unique identifier string of the customer to be updated.

$updated_customer = GoSell\Customers::update($retrieved_customer->id,[
  "first_name"=> "test",
  "middle_name"=> "test",
  "last_name"=> "test",
  "email"=> "test@test.com",
  "phone"=> [
    "country_code"=> "965",
    "number"=> "00000000"
  ],
  "description"=> "test",
  "metadata"=> [
    "udf1"=> "test update"
  ],
  "currency"=> "KWD"
]);

var_dump($updated_customer);

Delete a Customer

Permanently deletes a customer. It cannot be undone. Unique identifier string of the customer is the only parameter required.

$deleted_customer = GoSell\Customers::delete($updated_customer->id);

var_dump($deleted_customer);

List all Customers

Returns a list of your customers. The customers are returned sorted by creation date, with the most recent customers appearing first.

$all_customers = GoSell\Customers::all([
  "period"=> [
    "date"=> [
      "from"=> time() - (30 * 24 * 60 * 60),//last 30 days
      "to"=> time()//today
    ]
  ],
  "status"=> "",
  "starting_after"=> "",
  "limit"=> 25
]);

var_dump($all_customers);