@square/web-payments-sdk-types
Version:
Types for Square's Web Payments SDK
94 lines (93 loc) • 2.54 kB
TypeScript
/**
* Details object of an error that occurred throughout the Web Payment SDK.
*/
export interface ApplicationError {
/**
* Error message.
*/
message: string;
/**
* Type of error thrown.
*/
type: string;
/**
* Particular field that caused the error, if applicable. E.g. Card Number
*/
field?: string;
/**
* Additional detail about the error, if applicable.
*/
detail?: string;
}
/**
* Format of error details returned from verifyBuyer
*/
export interface VerifyBuyerErrorDetails {
code?: string;
type: string;
message: string;
}
/**
* @internal
*/
export type ErrorCategory = 'API_ERROR' | 'AUTHENTICATION_ERROR' | 'INVALID_REQUEST_ERROR' | 'PAYMENT_METHOD_ERROR' | 'RATE_LIMIT_ERROR' | 'REFUND_ERROR';
/**
* Square API Error Format.
*/
export interface SquareApiError {
/**
* Indicates which high-level category of error has occurred during a request to the Connect API.
* https://developer.squareup.com/reference/square/enums/ErrorCategory
*/
category: ErrorCategory;
/**
*
* Indicates the specific error that occurred during a request to a Square API.
* https://developer.squareup.com/reference/square/enums/ErrorCode
*/
code: string;
detail?: string;
field?: string;
}
/**
* @ignore
*/
export interface SqErrorI {
message: string;
name: string;
errors: Array<SquareApiError | ApplicationError | VerifyBuyerErrorDetails | SqErrorI>;
}
export type SubError = SquareApiError | ApplicationError | VerifyBuyerErrorDetails | SqErrorI;
/**
* @internal
*/
export interface SerializedError {
_isSerializedError: true;
name: string;
message: string;
errors?: Array<SquareApiError | ApplicationError | SqErrorI>;
}
/**
* @internal
* SquareError is a base error class for all errors thrown by the Web Payment SDK.
*/
export declare class SqError extends Error {
/**
* @internal
*
* @param {string} message - A message describing the error that occurred
*/
readonly errors: SubError[];
/**
* @internal
* Internal version of the Square Error, providing serialization helpers.
* @param {string} message - A message describing the error that occurred
* @param {SubError} errors
*/
constructor(message?: string, errors?: SubError[]);
/**
* @internal
* @param error SerializedError to deserialize into the current error.
*/
fromSerializedError(error: SerializedError): void;
}