@godaddy/react
v1.0.13
Published
The `createCheckoutSession` function creates a new checkout session with GoDaddy's commerce API.
Maintainers
Keywords
Readme
Checkout Package
Checkout Session
Creating a Checkout Session
The createCheckoutSession function creates a new checkout session with GoDaddy's commerce API.
import { createCheckoutSession } from "@godaddy/react";
const session = await createCheckoutSession(input, options);Checkout Session Input Configuration
The first parameter accepts all checkout session configuration options from the GraphQL schema:
Required Parameters
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
Optional Parameters
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
Checkout Session Options
The CheckoutSessionOptions interface allows you to configure authentication and other settings:
interface CheckoutSessionOptions {
auth?: {
clientId: string;
clientSecret: string;
};
}Authentication Options
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.
Environment Support
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)
API Scopes
The checkout session automatically requests the following OAuth2 scopes:
commerce.product:readcommerce.order:readcommerce.order:updatelocation.address-verification:execute
Codegen
For now the schema will be downloaded from the order schema.
pnpm run codegen
Todos
- [ ] 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
