(products)
- create - Create Product
- get - Get Product
- list - List Products
- update - Update Product
- updateBenefits - Update Product Benefits
Create a product.
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\ProductRecurringCreate(
name: '<value>',
prices: [
new Components\ProductPriceRecurringFixedCreate(
priceAmount: 638424,
recurringInterval: Components\SubscriptionRecurringInterval::Month,
),
],
);
$response = $sdk->products->create(
request: $request
);
if ($response->product !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
$request |
Components\ProductRecurringCreate|Components\ProductOneTimeCreate | ✔️ | The request object to use for the request. |
?Operations\ProductsCreateResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Get a product 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->products->get(
id: '<value>'
);
if ($response->product !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
id |
string | ✔️ | N/A |
?Operations\ProductsGetResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ResourceNotFound | 404 | application/json |
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
List products.
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\ProductsListRequest();
$responses = $sdk->products->list(
request: $request
);
foreach ($responses as $response) {
if ($response->statusCode === 200) {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
$request |
Operations\ProductsListRequest | ✔️ | The request object to use for the request. |
?Operations\ProductsListResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Update a product.
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();
$productUpdate = new Components\ProductUpdate();
$response = $sdk->products->update(
id: '<value>',
productUpdate: $productUpdate
);
if ($response->product !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
id |
string | ✔️ | N/A |
productUpdate |
Components\ProductUpdate | ✔️ | N/A |
?Operations\ProductsUpdateResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\NotPermitted | 403 | application/json |
Errors\ResourceNotFound | 404 | application/json |
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Update benefits granted by a product.
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();
$productBenefitsUpdate = new Components\ProductBenefitsUpdate(
benefits: [
'<value>',
],
);
$response = $sdk->products->updateBenefits(
id: '<value>',
productBenefitsUpdate: $productBenefitsUpdate
);
if ($response->product !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
id |
string | ✔️ | N/A |
productBenefitsUpdate |
Components\ProductBenefitsUpdate | ✔️ | N/A |
?Operations\ProductsUpdateBenefitsResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\NotPermitted | 403 | application/json |
Errors\ResourceNotFound | 404 | application/json |
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |