@scayle/checkout-types
v2.1.73
Published
TypeScript definitions for SCAYLE Checkout
Maintainers
Readme
@scayle/checkout-types
Documentation | Website
The SCAYLE Checkout Types library offers comprehensive TypeScript type definitions for developing SCAYLE applications and components.
What is Scayle ?
SCAYLE is a full-featured e-commerce software solution that comes with flexible APIs. Within SCAYLE, you can manage all aspects of your shop, such as products, stocks, customers, and transactions.
Learn more about SCAYLE's architecture and commerce modules in the Docs.
Installation
npm i -S @scayle/checkout-typesUsage
All types
import * as types from '@scayle/checkout-types';
// Use the types in your application
const checkoutState: types.CheckoutState = {
// ... your checkout state
};Individual types
import { CheckoutState, PaymentMethod, AddressForm, DynamicField } from '@scayle/checkout-types';
// Use specific types
const checkoutState: CheckoutState = {
// ... your checkout state
};SDK & Authentication Types
import type {
Scayle, // Main SDK type for window.scayle
RefreshTokenHook, // Token refresh hook
ExchangeAuthCodeHook, // Auth code exchange hook
AuthEvents, // Authentication events
DeviceType // Express checkout device type
} from '@scayle/checkout-types';
// Type the global window.scayle
declare global {
interface Window {
scayle: Scayle;
}
}
// Implement custom auth hooks
const refreshTokenHook: RefreshTokenHook = async params => {
// Your implementation
return { accessToken: 'new-token' };
};
// Use SDK with full type safety
window.scayle.auth.V3.init({
clientId: 123,
hooks: { refreshTokenHook, exchangeAuthCodeHook }
});
// Listen to events
window.scayle.auth.V3.events.listen(AuthEvents.AUTH_SUCCESS, payload => {
console.log('Authenticated:', payload.accessToken);
});Available Types
This package provides comprehensive TypeScript definitions for:
Checkout & Configuration
- Checkout: Checkout state, steps, and flow types
- Payment: Payment methods, providers, and processing
- Address: Address forms and validation
- Basket: Shopping cart and basket management
- Configuration: App configuration and settings
- Validation: Form validation and field types
- Dynamic Fields: Dynamic form field definitions
SDK Types (NEW)
- Scayle SDK: Main SDK type for
window.scayle - Authentication: Auth hooks, requests, responses, events, and error types
- Express Checkout: Express SDK types and device types
- Internal API: Internal endpoints and event types
- Event System: Event bus and event listener types
Other channels
- Jobs
- SCAYLE
License
Licensed under the MIT
