Skip to content

Latest commit

 

History

History
530 lines (368 loc) · 15.4 KB

terminal.md

File metadata and controls

530 lines (368 loc) · 15.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

CreateTerminalActionResponse

Example Usage

$body_idempotencyKey = 'thahn-70e75c10-47f7-4ab6-88cc-aaa4076d065e';
$body_action = new Models\TerminalAction;
$body_action->setDeviceId('{{DEVICE_ID}}');
$body_action->setDeadlineDuration('PT5M');
$body_action->setType(Models\TerminalActionActionType::SAVE_CARD);
$body_action_saveCardOptions_customerId = '{{CUSTOMER_ID}}';
$body_action->setSaveCardOptions(new Models\SaveCardOptions(
    $body_action_saveCardOptions_customerId
));
$body_action->getSaveCardOptions()->setReferenceId('user-id-1');
$body = new Models\CreateTerminalActionRequest(
    $body_idempotencyKey,
    $body_action
);

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

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

// Get more response info...
// $statusCode = $apiResponse->getStatusCode();
// $headers = $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

SearchTerminalActionsResponse

Example Usage

$body = new Models\SearchTerminalActionsRequest;
$body->setQuery(new Models\TerminalActionQuery);
$body->getQuery()->setFilter(new Models\TerminalActionQueryFilter);
$body->getQuery()->getFilter()->setCreatedAt(new Models\TimeRange);
$body->getQuery()->getFilter()->getCreatedAt()->setStartAt('2022-04-01T00:00:00.000Z');
$body->getQuery()->setSort(new Models\TerminalActionQuerySort);
$body->getQuery()->getSort()->setSortOrder(Models\SortOrder::DESC);
$body->setLimit(2);

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

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

// Get more response info...
// $statusCode = $apiResponse->getStatusCode();
// $headers = $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

GetTerminalActionResponse

Example Usage

$actionId = 'action_id6';

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

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

// Get more response info...
// $statusCode = $apiResponse->getStatusCode();
// $headers = $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

CancelTerminalActionResponse

Example Usage

$actionId = 'action_id6';

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

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

// Get more response info...
// $statusCode = $apiResponse->getStatusCode();
// $headers = $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

CreateTerminalCheckoutResponse

Example Usage

$body_idempotencyKey = '28a0c3bc-7839-11ea-bc55-0242ac130003';
$body_checkout_amountMoney = new Models\Money;
$body_checkout_amountMoney->setAmount(2610);
$body_checkout_amountMoney->setCurrency(Models\Currency::USD);
$body_checkout_deviceOptions_deviceId = 'dbb5d83a-7838-11ea-bc55-0242ac130003';
$body_checkout_deviceOptions = new Models\DeviceCheckoutOptions(
    $body_checkout_deviceOptions_deviceId
);
$body_checkout = new Models\TerminalCheckout(
    $body_checkout_amountMoney,
    $body_checkout_deviceOptions
);
$body_checkout->setReferenceId('id11572');
$body_checkout->setNote('A brief note');
$body = new Models\CreateTerminalCheckoutRequest(
    $body_idempotencyKey,
    $body_checkout
);

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

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

// Get more response info...
// $statusCode = $apiResponse->getStatusCode();
// $headers = $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

SearchTerminalCheckoutsResponse

Example Usage

$body = new Models\SearchTerminalCheckoutsRequest;
$body->setQuery(new Models\TerminalCheckoutQuery);
$body->getQuery()->setFilter(new Models\TerminalCheckoutQueryFilter);
$body->getQuery()->getFilter()->setStatus('COMPLETED');
$body->setLimit(2);

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

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

// Get more response info...
// $statusCode = $apiResponse->getStatusCode();
// $headers = $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

GetTerminalCheckoutResponse

Example Usage

$checkoutId = 'checkout_id8';

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

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

// Get more response info...
// $statusCode = $apiResponse->getStatusCode();
// $headers = $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

CancelTerminalCheckoutResponse

Example Usage

$checkoutId = 'checkout_id8';

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

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

// Get more response info...
// $statusCode = $apiResponse->getStatusCode();
// $headers = $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

CreateTerminalRefundResponse

Example Usage

$body_idempotencyKey = '402a640b-b26f-401f-b406-46f839590c04';
$body = new Models\CreateTerminalRefundRequest(
    $body_idempotencyKey
);
$body_refund_paymentId = '5O5OvgkcNUhl7JBuINflcjKqUzXZY';
$body_refund_amountMoney = new Models\Money;
$body_refund_amountMoney->setAmount(111);
$body_refund_amountMoney->setCurrency(Models\Currency::CAD);
$body_refund_reason = 'Returning items';
$body_refund_deviceId = 'f72dfb8e-4d65-4e56-aade-ec3fb8d33291';
$body->setRefund(new Models\TerminalRefund(
    $body_refund_paymentId,
    $body_refund_amountMoney,
    $body_refund_reason,
    $body_refund_deviceId
));

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

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

// Get more response info...
// $statusCode = $apiResponse->getStatusCode();
// $headers = $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

SearchTerminalRefundsResponse

Example Usage

$body = new Models\SearchTerminalRefundsRequest;
$body->setQuery(new Models\TerminalRefundQuery);
$body->getQuery()->setFilter(new Models\TerminalRefundQueryFilter);
$body->getQuery()->getFilter()->setStatus('COMPLETED');
$body->setLimit(1);

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

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

// Get more response info...
// $statusCode = $apiResponse->getStatusCode();
// $headers = $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

GetTerminalRefundResponse

Example Usage

$terminalRefundId = 'terminal_refund_id0';

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

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

// Get more response info...
// $statusCode = $apiResponse->getStatusCode();
// $headers = $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

CancelTerminalRefundResponse

Example Usage

$terminalRefundId = 'terminal_refund_id0';

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

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

// Get more response info...
// $statusCode = $apiResponse->getStatusCode();
// $headers = $apiResponse->getHeaders();