Skip to content

Latest commit

 

History

History
229 lines (153 loc) · 15.6 KB

File metadata and controls

229 lines (153 loc) · 15.6 KB

CustomerPortal.Subscriptions

Overview

Available Operations

  • list - List Subscriptions
  • get - Get Subscription
  • cancel - Cancel Subscription
  • update - Update Subscription

list

List subscriptions of the authenticated customer.

Scopes: customer_portal:read customer_portal:write

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Polar;
use Polar\Models\Operations;

$sdk = Polar\Polar::builder()->build();

$request = new Operations\CustomerPortalSubscriptionsListRequest();
$requestSecurity = new Operations\CustomerPortalSubscriptionsListSecurity(
    customerSession: '<YOUR_BEARER_TOKEN_HERE>',
);

$responses = $sdk->customerPortal->subscriptions->list(
    request: $request,
    security: $requestSecurity
);


foreach ($responses as $response) {
    if ($response->statusCode === 200) {
        // handle response
    }
}

Parameters

Parameter Type Required Description
$request Operations\CustomerPortalSubscriptionsListRequest ✔️ The request object to use for the request.
security Operations\CustomerPortalSubscriptionsListSecurity ✔️ The security requirements to use for the request.

Response

?Operations\CustomerPortalSubscriptionsListResponse

Errors

Error Type Status Code Content Type
Errors\HTTPValidationError 422 application/json
Errors\APIException 4XX, 5XX */*

get

Get a subscription for the authenticated customer.

Scopes: customer_portal:read customer_portal:write

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Polar;
use Polar\Models\Operations;

$sdk = Polar\Polar::builder()->build();


$requestSecurity = new Operations\CustomerPortalSubscriptionsGetSecurity(
    customerSession: '<YOUR_BEARER_TOKEN_HERE>',
);

$response = $sdk->customerPortal->subscriptions->get(
    security: $requestSecurity,
    id: '<value>'

);

if ($response->customerSubscription !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
security Operations\CustomerPortalSubscriptionsGetSecurity ✔️ The security requirements to use for the request.
id string ✔️ The subscription ID.

Response

?Operations\CustomerPortalSubscriptionsGetResponse

Errors

Error Type Status Code Content Type
Errors\ResourceNotFound 404 application/json
Errors\HTTPValidationError 422 application/json
Errors\APIException 4XX, 5XX */*

cancel

Cancel a subscription of the authenticated customer.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Polar;
use Polar\Models\Operations;

$sdk = Polar\Polar::builder()->build();


$requestSecurity = new Operations\CustomerPortalSubscriptionsCancelSecurity(
    customerSession: '<YOUR_BEARER_TOKEN_HERE>',
);

$response = $sdk->customerPortal->subscriptions->cancel(
    security: $requestSecurity,
    id: '<value>'

);

if ($response->customerSubscription !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
security Operations\CustomerPortalSubscriptionsCancelSecurity ✔️ The security requirements to use for the request.
id string ✔️ The subscription ID.

Response

?Operations\CustomerPortalSubscriptionsCancelResponse

Errors

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

Update a subscription of the authenticated customer.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Polar;
use Polar\Models\Components;
use Polar\Models\Operations;

$sdk = Polar\Polar::builder()->build();


$requestSecurity = new Operations\CustomerPortalSubscriptionsUpdateSecurity(
    customerSession: '<YOUR_BEARER_TOKEN_HERE>',
);

$response = $sdk->customerPortal->subscriptions->update(
    security: $requestSecurity,
    id: '<value>',
    customerSubscriptionUpdate: new Components\CustomerSubscriptionCancel()

);

if ($response->customerSubscription !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
security Operations\CustomerPortalSubscriptionsUpdateSecurity ✔️ The security requirements to use for the request.
id string ✔️ The subscription ID.
customerSubscriptionUpdate Components\CustomerSubscriptionUpdateProduct|Components\CustomerSubscriptionUpdateSeats|Components\CustomerSubscriptionCancel ✔️ N/A

Response

?Operations\CustomerPortalSubscriptionsUpdateResponse

Errors

Error Type Status Code Content Type
Errors\PaymentFailed 402 application/json
Errors\AlreadyCanceledSubscription 403 application/json
Errors\ResourceNotFound 404 application/json
Errors\HTTPValidationError 422 application/json
Errors\APIException 4XX, 5XX */*