The createCheckoutSession function creates a new checkout session with GoDaddy's commerce API.
import { createCheckoutSession } from "@godaddy/react";
const session = await createCheckoutSession(input, options);The first parameter accepts all checkout session configuration options from the GraphQL schema:
channelId(string): The ID of the sales channel that originated this sessionstoreId(string): The ID of the store this checkout session belongs todraftOrderId(string): The ID of the draft orderreturnUrl(string): URL to redirect to when user cancels checkoutsuccessUrl(string): URL to redirect to after successful checkout
customerId(string): Customer ID for the checkout sessionstoreName(string): The name of the store this checkout session belongs tourl(string): Custom URL for the checkout sessionenvironment(enum): Environment -ote,prodexpiresAt(DateTime): When the session expiresenableBillingAddressCollection(boolean): Enable billing address collectionenableLocalPickup(boolean): Enable local pickup optionenableNotesCollection(boolean): Enable order notes collectionenablePaymentMethodCollection(boolean): Enable payment method collectionenablePhoneCollection(boolean): Enable phone number collectionenablePromotionCodes(boolean): Enable promotion/discount codesenableShippingAddressCollection(boolean): Enable shipping address collectionenableSurcharge(boolean): Enable surcharge feesenableTaxCollection(boolean): Enable tax collectionenableTips(boolean): Enable tip/gratuity optionsenabledLocales([String!]): List of enabled localesenabledPaymentProviders([String!]): List of enabled payment providerslocations([CheckoutSessionLocationInput!]): Available pickup locationsoperatingHours(CheckoutSessionOperatingHoursMapInput): Store operating hours configurationpaymentMethods(CheckoutSessionPaymentMethodsInput): Payment method configurations
The CheckoutSessionOptions interface allows you to configure authentication and other settings:
interface CheckoutSessionOptions {
auth?: {
clientId: string;
clientSecret: string;
};
}auth.clientId(string): OAuth2 client ID for GoDaddy API authenticationauth.clientSecret(string): OAuth2 client secret for GoDaddy API authentication
When provided, these credentials will be used to obtain an access token for API requests. If not provided, the function will use empty strings which may result in authentication failures.
The checkout session supports multiple environments through the input parameter:
prod: Production environment (https://api.godaddy.com)ote: OTE environment (https://api.ote-godaddy.com)
The checkout session automatically requests the following OAuth2 scopes:
commerce.product:readcommerce.order:readcommerce.order:updatelocation.address-verification:execute
For now the schema will be downloaded from the order schema.
pnpm run codegen
- Add tests
- Refactor some external libs
- graphql-request
- arktype - try valibot instead for bundle size sad to lose devx but can be mmuch smaller
- floating ui dependencies