(customers)
- create - Create Customer
- delete - Delete Customer
- get - Get Customer
- list - List Customers
- update - Update Customer
Create a customer.
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
use Polar\Models\Components;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Polar\Polar::builder()->setSecurity($security)->build();
$request = new Components\CustomerCreate(
email: '[email protected]',
);
$response = $sdk->customers->create(
request: $request
);
if ($response->customer !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
$request |
Components\CustomerCreate | ✔️ | The request object to use for the request. |
?Operations\CustomersCreateResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Delete a customer.
Immediately cancels any active subscriptions and revokes any active benefits.
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Polar\Polar::builder()->setSecurity($security)->build();
$response = $sdk->customers->delete(
id: '<value>'
);
if ($response->statusCode === 200) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
id |
string | ✔️ | The customer ID. |
?Operations\CustomersDeleteResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ResourceNotFound | 404 | application/json |
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Get a customer by ID.
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Polar\Polar::builder()->setSecurity($security)->build();
$response = $sdk->customers->get(
id: '<value>'
);
if ($response->customer !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
id |
string | ✔️ | The customer ID. |
?Operations\CustomersGetResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ResourceNotFound | 404 | application/json |
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
List customers.
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
use Polar\Models\Operations;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Polar\Polar::builder()->setSecurity($security)->build();
$request = new Operations\CustomersListRequest();
$responses = $sdk->customers->list(
request: $request
);
foreach ($responses as $response) {
if ($response->statusCode === 200) {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
$request |
Operations\CustomersListRequest | ✔️ | The request object to use for the request. |
?Operations\CustomersListResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Update a customer.
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
use Polar\Models\Components;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Polar\Polar::builder()->setSecurity($security)->build();
$customerUpdate = new Components\CustomerUpdate();
$response = $sdk->customers->update(
id: '<value>',
customerUpdate: $customerUpdate
);
if ($response->customer !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
id |
string | ✔️ | The customer ID. |
customerUpdate |
Components\CustomerUpdate | ✔️ | N/A |
?Operations\CustomersUpdateResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ResourceNotFound | 404 | application/json |
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |