Skip to content

Latest commit

 

History

History
669 lines (467 loc) · 20.4 KB

terminal.md

File metadata and controls

669 lines (467 loc) · 20.4 KB

Terminal

$terminalApi = $client->getTerminalApi();

Class Name

TerminalApi

Methods

Create Terminal Action

Creates a Terminal action request and sends it to the specified device.

function createTerminalAction(CreateTerminalActionRequest $body): ApiResponse

Parameters

Parameter Type Tags Description
body CreateTerminalActionRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type CreateTerminalActionResponse.

Example Usage

$body = CreateTerminalActionRequestBuilder::init(
    'thahn-70e75c10-47f7-4ab6-88cc-aaa4076d065e',
    TerminalActionBuilder::init()
        ->deviceId('{{DEVICE_ID}}')
        ->deadlineDuration('PT5M')
        ->type(TerminalActionActionType::SAVE_CARD)
        ->saveCardOptions(
            SaveCardOptionsBuilder::init(
                '{{CUSTOMER_ID}}'
            )
                ->referenceId('user-id-1')
                ->build()
        )
        ->build()
)->build();

$apiResponse = $terminalApi->createTerminalAction($body);

if ($apiResponse->isSuccess()) {
    $createTerminalActionResponse = $apiResponse->getResult();
} else {
    $errors = $apiResponse->getErrors();
}

// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());

Search Terminal Actions

Retrieves a filtered list of Terminal action requests created by the account making the request. Terminal action requests are available for 30 days.

function searchTerminalActions(SearchTerminalActionsRequest $body): ApiResponse

Parameters

Parameter Type Tags Description
body SearchTerminalActionsRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type SearchTerminalActionsResponse.

Example Usage

$body = SearchTerminalActionsRequestBuilder::init()
    ->query(
        TerminalActionQueryBuilder::init()
            ->filter(
                TerminalActionQueryFilterBuilder::init()
                    ->createdAt(
                        TimeRangeBuilder::init()
                            ->startAt('2022-04-01T00:00:00.000Z')
                            ->build()
                    )
                    ->build()
            )
            ->sort(
                TerminalActionQuerySortBuilder::init()
                    ->sortOrder(SortOrder::DESC)
                    ->build()
            )
            ->build()
    )
    ->limit(2)
    ->build();

$apiResponse = $terminalApi->searchTerminalActions($body);

if ($apiResponse->isSuccess()) {
    $searchTerminalActionsResponse = $apiResponse->getResult();
} else {
    $errors = $apiResponse->getErrors();
}

// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());

Get Terminal Action

Retrieves a Terminal action request by action_id. Terminal action requests are available for 30 days.

function getTerminalAction(string $actionId): ApiResponse

Parameters

Parameter Type Tags Description
actionId string Template, Required Unique ID for the desired TerminalAction.

Response Type

This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type GetTerminalActionResponse.

Example Usage

$actionId = 'action_id6';

$apiResponse = $terminalApi->getTerminalAction($actionId);

if ($apiResponse->isSuccess()) {
    $getTerminalActionResponse = $apiResponse->getResult();
} else {
    $errors = $apiResponse->getErrors();
}

// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());

Cancel Terminal Action

Cancels a Terminal action request if the status of the request permits it.

function cancelTerminalAction(string $actionId): ApiResponse

Parameters

Parameter Type Tags Description
actionId string Template, Required Unique ID for the desired TerminalAction.

Response Type

This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type CancelTerminalActionResponse.

Example Usage

$actionId = 'action_id6';

$apiResponse = $terminalApi->cancelTerminalAction($actionId);

if ($apiResponse->isSuccess()) {
    $cancelTerminalActionResponse = $apiResponse->getResult();
} else {
    $errors = $apiResponse->getErrors();
}

// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());

Dismiss Terminal Action

Dismisses a Terminal action request if the status and type of the request permits it.

See Link and Dismiss Actions for more details.

function dismissTerminalAction(string $actionId): ApiResponse

Parameters

Parameter Type Tags Description
actionId string Template, Required Unique ID for the TerminalAction associated with the action to be dismissed.

Response Type

This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type DismissTerminalActionResponse.

Example Usage

$actionId = 'action_id6';

$apiResponse = $terminalApi->dismissTerminalAction($actionId);

if ($apiResponse->isSuccess()) {
    $dismissTerminalActionResponse = $apiResponse->getResult();
} else {
    $errors = $apiResponse->getErrors();
}

// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());

Create Terminal Checkout

Creates a Terminal checkout request and sends it to the specified device to take a payment for the requested amount.

function createTerminalCheckout(CreateTerminalCheckoutRequest $body): ApiResponse

Parameters

Parameter Type Tags Description
body CreateTerminalCheckoutRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type CreateTerminalCheckoutResponse.

Example Usage

$body = CreateTerminalCheckoutRequestBuilder::init(
    '28a0c3bc-7839-11ea-bc55-0242ac130003',
    TerminalCheckoutBuilder::init(
        MoneyBuilder::init()
            ->amount(2610)
            ->currency(Currency::USD)
            ->build(),
        DeviceCheckoutOptionsBuilder::init(
            'dbb5d83a-7838-11ea-bc55-0242ac130003'
        )->build()
    )
        ->referenceId('id11572')
        ->note('A brief note')
        ->build()
)->build();

$apiResponse = $terminalApi->createTerminalCheckout($body);

if ($apiResponse->isSuccess()) {
    $createTerminalCheckoutResponse = $apiResponse->getResult();
} else {
    $errors = $apiResponse->getErrors();
}

// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());

Search Terminal Checkouts

Returns a filtered list of Terminal checkout requests created by the application making the request. Only Terminal checkout requests created for the merchant scoped to the OAuth token are returned. Terminal checkout requests are available for 30 days.

function searchTerminalCheckouts(SearchTerminalCheckoutsRequest $body): ApiResponse

Parameters

Parameter Type Tags Description
body SearchTerminalCheckoutsRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type SearchTerminalCheckoutsResponse.

Example Usage

$body = SearchTerminalCheckoutsRequestBuilder::init()
    ->query(
        TerminalCheckoutQueryBuilder::init()
            ->filter(
                TerminalCheckoutQueryFilterBuilder::init()
                    ->status('COMPLETED')
                    ->build()
            )
            ->build()
    )
    ->limit(2)
    ->build();

$apiResponse = $terminalApi->searchTerminalCheckouts($body);

if ($apiResponse->isSuccess()) {
    $searchTerminalCheckoutsResponse = $apiResponse->getResult();
} else {
    $errors = $apiResponse->getErrors();
}

// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());

Get Terminal Checkout

Retrieves a Terminal checkout request by checkout_id. Terminal checkout requests are available for 30 days.

function getTerminalCheckout(string $checkoutId): ApiResponse

Parameters

Parameter Type Tags Description
checkoutId string Template, Required The unique ID for the desired TerminalCheckout.

Response Type

This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type GetTerminalCheckoutResponse.

Example Usage

$checkoutId = 'checkout_id8';

$apiResponse = $terminalApi->getTerminalCheckout($checkoutId);

if ($apiResponse->isSuccess()) {
    $getTerminalCheckoutResponse = $apiResponse->getResult();
} else {
    $errors = $apiResponse->getErrors();
}

// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());

Cancel Terminal Checkout

Cancels a Terminal checkout request if the status of the request permits it.

function cancelTerminalCheckout(string $checkoutId): ApiResponse

Parameters

Parameter Type Tags Description
checkoutId string Template, Required The unique ID for the desired TerminalCheckout.

Response Type

This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type CancelTerminalCheckoutResponse.

Example Usage

$checkoutId = 'checkout_id8';

$apiResponse = $terminalApi->cancelTerminalCheckout($checkoutId);

if ($apiResponse->isSuccess()) {
    $cancelTerminalCheckoutResponse = $apiResponse->getResult();
} else {
    $errors = $apiResponse->getErrors();
}

// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());

Dismiss Terminal Checkout

Dismisses a Terminal checkout request if the status and type of the request permits it.

function dismissTerminalCheckout(string $checkoutId): ApiResponse

Parameters

Parameter Type Tags Description
checkoutId string Template, Required Unique ID for the TerminalCheckout associated with the checkout to be dismissed.

Response Type

This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type DismissTerminalCheckoutResponse.

Example Usage

$checkoutId = 'checkout_id8';

$apiResponse = $terminalApi->dismissTerminalCheckout($checkoutId);

if ($apiResponse->isSuccess()) {
    $dismissTerminalCheckoutResponse = $apiResponse->getResult();
} else {
    $errors = $apiResponse->getErrors();
}

// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());

Create Terminal Refund

Creates a request to refund an Interac payment completed on a Square Terminal. Refunds for Interac payments on a Square Terminal are supported only for Interac debit cards in Canada. Other refunds for Terminal payments should use the Refunds API. For more information, see Refunds API.

function createTerminalRefund(CreateTerminalRefundRequest $body): ApiResponse

Parameters

Parameter Type Tags Description
body CreateTerminalRefundRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type CreateTerminalRefundResponse.

Example Usage

$body = CreateTerminalRefundRequestBuilder::init(
    '402a640b-b26f-401f-b406-46f839590c04'
)
    ->refund(
        TerminalRefundBuilder::init(
            '5O5OvgkcNUhl7JBuINflcjKqUzXZY',
            MoneyBuilder::init()
                ->amount(111)
                ->currency(Currency::CAD)
                ->build(),
            'Returning items',
            'f72dfb8e-4d65-4e56-aade-ec3fb8d33291'
        )->build()
    )->build();

$apiResponse = $terminalApi->createTerminalRefund($body);

if ($apiResponse->isSuccess()) {
    $createTerminalRefundResponse = $apiResponse->getResult();
} else {
    $errors = $apiResponse->getErrors();
}

// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());

Search Terminal Refunds

Retrieves a filtered list of Interac Terminal refund requests created by the seller making the request. Terminal refund requests are available for 30 days.

function searchTerminalRefunds(SearchTerminalRefundsRequest $body): ApiResponse

Parameters

Parameter Type Tags Description
body SearchTerminalRefundsRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type SearchTerminalRefundsResponse.

Example Usage

$body = SearchTerminalRefundsRequestBuilder::init()
    ->query(
        TerminalRefundQueryBuilder::init()
            ->filter(
                TerminalRefundQueryFilterBuilder::init()
                    ->status('COMPLETED')
                    ->build()
            )
            ->build()
    )
    ->limit(1)
    ->build();

$apiResponse = $terminalApi->searchTerminalRefunds($body);

if ($apiResponse->isSuccess()) {
    $searchTerminalRefundsResponse = $apiResponse->getResult();
} else {
    $errors = $apiResponse->getErrors();
}

// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());

Get Terminal Refund

Retrieves an Interac Terminal refund object by ID. Terminal refund objects are available for 30 days.

function getTerminalRefund(string $terminalRefundId): ApiResponse

Parameters

Parameter Type Tags Description
terminalRefundId string Template, Required The unique ID for the desired TerminalRefund.

Response Type

This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type GetTerminalRefundResponse.

Example Usage

$terminalRefundId = 'terminal_refund_id0';

$apiResponse = $terminalApi->getTerminalRefund($terminalRefundId);

if ($apiResponse->isSuccess()) {
    $getTerminalRefundResponse = $apiResponse->getResult();
} else {
    $errors = $apiResponse->getErrors();
}

// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());

Cancel Terminal Refund

Cancels an Interac Terminal refund request by refund request ID if the status of the request permits it.

function cancelTerminalRefund(string $terminalRefundId): ApiResponse

Parameters

Parameter Type Tags Description
terminalRefundId string Template, Required The unique ID for the desired TerminalRefund.

Response Type

This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type CancelTerminalRefundResponse.

Example Usage

$terminalRefundId = 'terminal_refund_id0';

$apiResponse = $terminalApi->cancelTerminalRefund($terminalRefundId);

if ($apiResponse->isSuccess()) {
    $cancelTerminalRefundResponse = $apiResponse->getResult();
} else {
    $errors = $apiResponse->getErrors();
}

// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());

Dismiss Terminal Refund

Dismisses a Terminal refund request if the status and type of the request permits it.

function dismissTerminalRefund(string $terminalRefundId): ApiResponse

Parameters

Parameter Type Tags Description
terminalRefundId string Template, Required Unique ID for the TerminalRefund associated with the refund to be dismissed.

Response Type

This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type DismissTerminalRefundResponse.

Example Usage

$terminalRefundId = 'terminal_refund_id0';

$apiResponse = $terminalApi->dismissTerminalRefund($terminalRefundId);

if ($apiResponse->isSuccess()) {
    $dismissTerminalRefundResponse = $apiResponse->getResult();
} else {
    $errors = $apiResponse->getErrors();
}

// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());