Skip to content

Latest commit

 

History

History
418 lines (292 loc) · 18 KB

File metadata and controls

418 lines (292 loc) · 18 KB

Checkouts

Overview

Available Operations

  • list - List Checkout Sessions
  • create - Create Checkout Session
  • get - Get Checkout Session
  • update - Update Checkout Session
  • clientGet - Get Checkout Session from Client
  • clientUpdate - Update Checkout Session from Client
  • clientConfirm - Confirm Checkout Session from Client

list

List checkout sessions.

Scopes: checkouts:read checkouts:write

Example Usage

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\CheckoutsListRequest(
    organizationId: '1dbfc517-0bbf-4301-9ba8-555ca42b9737',
);

$responses = $sdk->checkouts->list(
    request: $request
);


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

Parameters

Parameter Type Required Description
$request Operations\CheckoutsListRequest ✔️ The request object to use for the request.

Response

?Operations\CheckoutsListResponse

Errors

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

create

Create a checkout session.

Scopes: checkouts:write

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Polar;
use Polar\Models\Components;

$sdk = Polar\Polar::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();

$request = new Components\CheckoutCreate(
    customerName: 'John Doe',
    customerBillingAddress: new Components\AddressInput(
        country: Components\AddressInputCountryAlpha2Input::Us,
    ),
    locale: 'en',
    products: [
        '<value 1>',
        '<value 2>',
        '<value 3>',
    ],
);

$response = $sdk->checkouts->create(
    request: $request
);

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

Parameters

Parameter Type Required Description
$request Components\CheckoutCreate ✔️ The request object to use for the request.

Response

?Operations\CheckoutsCreateResponse

Errors

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

get

Get a checkout session by ID.

Scopes: checkouts:read checkouts:write

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Polar;

$sdk = Polar\Polar::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();



$response = $sdk->checkouts->get(
    id: '<value>'
);

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

Parameters

Parameter Type Required Description
id string ✔️ The checkout session ID.

Response

?Operations\CheckoutsGetResponse

Errors

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

update

Update a checkout session.

Scopes: checkouts:write

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Polar;
use Polar\Models\Components;

$sdk = Polar\Polar::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();

$checkoutUpdate = new Components\CheckoutUpdate(
    customerName: 'John Doe',
    customerBillingAddress: new Components\AddressInput(
        country: Components\AddressInputCountryAlpha2Input::Us,
    ),
    locale: 'en',
);

$response = $sdk->checkouts->update(
    id: '<value>',
    checkoutUpdate: $checkoutUpdate

);

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

Parameters

Parameter Type Required Description
id string ✔️ The checkout session ID.
checkoutUpdate Components\CheckoutUpdate ✔️ N/A

Response

?Operations\CheckoutsUpdateResponse

Errors

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

clientGet

Get a checkout session by client secret.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Polar;

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



$response = $sdk->checkouts->clientGet(
    clientSecret: '<value>'
);

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

Parameters

Parameter Type Required Description
clientSecret string ✔️ The checkout session client secret.

Response

?Operations\CheckoutsClientGetResponse

Errors

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

clientUpdate

Update a checkout session by client secret.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Polar;
use Polar\Models\Components;

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

$checkoutUpdatePublic = new Components\CheckoutUpdatePublic(
    customerName: 'John Doe',
    customerBillingAddress: null,
    locale: 'en',
);

$response = $sdk->checkouts->clientUpdate(
    clientSecret: '<value>',
    checkoutUpdatePublic: $checkoutUpdatePublic

);

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

Parameters

Parameter Type Required Description
clientSecret string ✔️ The checkout session client secret.
checkoutUpdatePublic Components\CheckoutUpdatePublic ✔️ N/A

Response

?Operations\CheckoutsClientUpdateResponse

Errors

Error Type Status Code Content Type
Errors\AlreadyActiveSubscriptionError 403 application/json
Errors\NotOpenCheckout 403 application/json
Errors\PaymentNotReady 403 application/json
Errors\TrialAlreadyRedeemed 403 application/json
Errors\ResourceNotFound 404 application/json
Errors\ExpiredCheckoutError 410 application/json
Errors\HTTPValidationError 422 application/json
Errors\APIException 4XX, 5XX */*

clientConfirm

Confirm a checkout session by client secret.

Orders and subscriptions will be processed.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Polar;
use Polar\Models\Components;

$sdk = Polar\Polar::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();

$checkoutConfirmStripe = new Components\CheckoutConfirmStripe(
    customerName: 'John Doe',
    customerBillingAddress: new Components\AddressInput(
        country: Components\AddressInputCountryAlpha2Input::Us,
    ),
    locale: 'en',
);

$response = $sdk->checkouts->clientConfirm(
    clientSecret: '<value>',
    checkoutConfirmStripe: $checkoutConfirmStripe

);

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

Parameters

Parameter Type Required Description
clientSecret string ✔️ The checkout session client secret.
checkoutConfirmStripe Components\CheckoutConfirmStripe ✔️ N/A

Response

?Operations\CheckoutsClientConfirmResponse

Errors

Error Type Status Code Content Type
Errors\PaymentError 400 application/json
Errors\AlreadyActiveSubscriptionError 403 application/json
Errors\NotOpenCheckout 403 application/json
Errors\PaymentNotReady 403 application/json
Errors\TrialAlreadyRedeemed 403 application/json
Errors\ResourceNotFound 404 application/json
Errors\ExpiredCheckoutError 410 application/json
Errors\HTTPValidationError 422 application/json
Errors\APIException 4XX, 5XX */*