(subscriptions)
- export - Export Subscriptions
- get - Get Subscription
- list - List Subscriptions
- revoke - Revoke Subscription
- update - Update Subscription
Export subscriptions as a CSV file.
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$response = $sdk->subscriptions->export(
organizationId: [
'<value>',
]
);
if ($response->any !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
organizationId |
string|array|null | ➖ | Filter by organization ID. |
?Operations\SubscriptionsExportResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Get a subscription by ID.
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$response = $sdk->subscriptions->get(
id: '<value>'
);
if ($response->subscription !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
id |
string | ✔️ | The subscription ID. |
?Operations\SubscriptionsGetResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ResourceNotFound | 404 | application/json |
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
List subscriptions.
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
use Polar\Models\Operations;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$request = new Operations\SubscriptionsListRequest();
$responses = $sdk->subscriptions->list(
request: $request
);
foreach ($responses as $response) {
if ($response->statusCode === 200) {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
$request |
Operations\SubscriptionsListRequest | ✔️ | The request object to use for the request. |
?Operations\SubscriptionsListResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Revoke a subscription, i.e cancel immediately.
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$response = $sdk->subscriptions->revoke(
id: '<value>'
);
if ($response->subscription !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
id |
string | ✔️ | The subscription ID. |
?Operations\SubscriptionsRevokeResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\AlreadyCanceledSubscription | 403 | application/json |
Errors\ResourceNotFound | 404 | application/json |
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Update a subscription.
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
use Polar\Models\Components;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$response = $sdk->subscriptions->update(
id: '<value>',
subscriptionUpdate: new Components\SubscriptionCancel()
);
if ($response->subscription !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
id |
string | ✔️ | The subscription ID. |
subscriptionUpdate |
Components\SubscriptionUpdatePrice|Components\SubscriptionCancel | ✔️ | N/A |
?Operations\SubscriptionsUpdateResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\AlreadyCanceledSubscription | 403 | application/json |
Errors\ResourceNotFound | 404 | application/json |
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |