Skip to content

Customers

Customers

1
2
3
4
5
6
7
8
{
  "id": "cust_9Cle7TXKkjhwqcWx4Kl5cQYk",
  "email": "david@example.net",
  "mobile": "+33639980102",
  "name": "David Coaster",
  "created": 1538562174,
  "live_mode": false
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
package Stancer::Customer;

use Moo;
use Stancer::Core::Types qw(:all);

has created => (is => 'ro', isa => InstanceOf['DateTime']);

has email => (is => 'rw', isa => Varchar[5, 64]);

has id => (is => 'ro', isa => Char[29]);

has mobile => (is => 'rw', isa => Varchar[8, 16]);

has name => (is => 'rw', isa => Varchar[4, 64]);

1;
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
<?php
namespace Stancer;

use DateTime;

class Customer
{
  protected ?DateTime $created;
  protected ?string $email;
  protected ?string $id;
  protected ?string $mobile;
  protected ?string $name;

  public function __construct(string $id = null) {}
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from datetime import datetime

class Customer(object):
  _ENDPOINT = 'customers'

  @property
  def created(self) -> datetime:
    pass

  @property
  def email(self) -> str:
    pass

  @email.setter
  def email(self, value: str):
    pass

  @property
  def id(self) -> str:
    pass

  @property
  def mobile(self) -> str:
    pass

  @mobile.setter
  def mobile(self, value: str):
    pass

The customer object is defined as follows:

Field Description Type
id Customer's id String, fixed size = 29
email Customer's email String, min = 5, max = 64
mobile Customer's mobile phone String, min = 8, max = 16
name Customer's name String, min = 4, max = 64
created The Unix timestamp representing creation date of the object in local time Int
live_mode Test or Live mode Boolean inherited from a payment object if linked, default False

Customers objects created in Test mode cannot be used in Live mode. Likewise, objects created in Live mode cannot be used in Test mode.

Create a customer

HTTP request

/v1/customers/

Data parameters

Parameter Field
email Optional
mobile Optional
name Optional
live_mode Optional

Code examples

1
2
3
4
5
6
7
curl -X POST "https://api.stancer.com/v1/customers/" \
  --header "Content-Type: application/json" \
  --data '{
    "name": "David Coaster",
    "email": "david@coaster.net",
    "mobile": "+33684858687"
}'
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#! /bin/perl -w
use Stancer::Customer;

my $customer = Stancer::Customer->new();

$customer->email('david@example.net');
$customer->mobile('+33639980102');
$customer->name('David Coaster');

$customer->send();
1
2
3
4
5
6
7
8
<?php
$customer = new Stancer\Customer();

$customer->setEmail('david@example.net');
$customer->setMobile('+33639980102');
$customer->setName('David Coaster');

$customer->send();
1
2
3
4
5
6
7
8
import stancer

customer = stancer.Customer()
customer.email = 'david@example.net'
customer.mobile = '+33639980102'
customer.name = 'David Coaster'

customer.send()

The above command returns JSON structured as follows:

1
2
3
4
5
6
7
8
{
  "created": 1538562174,
  "email": "david@example.net",
  "id": "cust_9Cle7TXKkjhwqcWx4Kl5cQYk",
  "live_mode": false,
  "mobile": "+33639980102",
  "name": "David Coaster"
}

Get customer data

HTTP request

/v1/customers/
id_customer

Query parameters

Parameter Description
id_customer Customer's id

Return parameters

The request will return the customer object asssociated with the id_customer you provided. If the id_customer does not exist, the API will return a 404 HTTP response code.

Code examples

1
curl "https://api.stancer.com/v1/customers/cust_9Cle7TXKkjhwqcWx4Kl5cQYk"
1
2
3
4
#! /bin/perl -w
use Stancer::Customer;

my $customer = Stancer::Customer->new('cust_9Cle7TXKkjhwqcWx4Kl5cQYk');
1
2
<?php
$customer = new Stancer\Customer('cust_9Cle7TXKkjhwqcWx4Kl5cQYk');
1
2
3
import stancer

customer = stancer.Customer('cust_9Cle7TXKkjhwqcWx4Kl5cQYk')

The above command returns JSON structured as follows:

1
2
3
4
5
6
7
8
{
  "created": 1538562174,
  "email": "david@example.net",
  "id": "cust_9Cle7TXKkjhwqcWx4Kl5cQYk",
  "live_mode": false,
  "mobile": "+33639980102",
  "name": "David Coaster"
}

Update a customer

HTTP request

/v1/customers/
id_customer

Query parameters

Parameter Description
id_customer Customer's id

Data parameters

Parameter Field
email Optional
mobile Optional
name Optional

Return parameters

The above command returns an HTTP 204 code if correctly processed or an HTTP 404 code if the customer does not exist.

Code examples

1
2
3
4
5
curl -X PATCH "https://api.stancer.com/v1/customers/cust_9Cle7TXKkjhwqcWx4Kl5cQYk" \
  --header "Content-Type: application/json" \
  --data '{
    "email": "david@coaster.com"
}'
1
2
3
4
5
6
7
8
#! /bin/perl -w
use Stancer::Customer;

my $customer = Stancer::Customer->new('cust_9Cle7TXKkjhwqcWx4Kl5cQYk');

$customer->email('david@example.net');

$customer->send();
1
2
3
4
5
6
<?php
$customer = new Stancer\Customer('cust_9Cle7TXKkjhwqcWx4Kl5cQYk');

$customer->setEmail('david@coaster.com');

$customer->send();
1
2
3
4
5
import stancer

customer = stancer.Customer('cust_9Cle7TXKkjhwqcWx4Kl5cQYk')
customer.email = 'david@example.com'
customer.send()

Delete a customer

HTTP request

/v1/customers/
id_customer

Query parameters

Parameter Description
id_customer Customer's id

Return parameters

The above command returns an HTTP 204 code if correctly processed or an HTTP 404 code if the customer does not exist.

Code examples

1
curl -X DELETE "https://api.stancer.com/v1/customers/cust_9Cle7TXKkjhwqcWx4Kl5cQYk"