2022-06-10 16:33:15 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2022-10-06 14:48:52 +00:00
|
|
|
import {
|
|
|
|
BillingAddress,
|
|
|
|
getSetting,
|
|
|
|
ShippingAddress,
|
2024-02-06 15:16:00 +00:00
|
|
|
AdditionalValues,
|
2022-10-06 14:48:52 +00:00
|
|
|
} from '@woocommerce/settings';
|
2022-06-10 16:33:15 +00:00
|
|
|
|
|
|
|
import { CheckoutResponseSuccess } from '@woocommerce/types';
|
|
|
|
|
|
|
|
export const STORE_KEY = 'wc/store/checkout';
|
|
|
|
|
|
|
|
export enum STATUS {
|
|
|
|
// When checkout state has changed but there is no activity happening.
|
|
|
|
IDLE = 'idle',
|
|
|
|
// After the AFTER_PROCESSING event emitters have completed. This status triggers the checkout redirect.
|
|
|
|
COMPLETE = 'complete',
|
|
|
|
// This is the state before checkout processing begins after the checkout button has been pressed/submitted.
|
|
|
|
BEFORE_PROCESSING = 'before_processing',
|
2022-06-21 14:09:22 +00:00
|
|
|
// After BEFORE_PROCESSING status emitters have finished successfully. Payment processing is started on this checkout status.
|
|
|
|
PROCESSING = 'processing',
|
2022-06-10 16:33:15 +00:00
|
|
|
// After server side checkout processing is completed this status is set
|
|
|
|
AFTER_PROCESSING = 'after_processing',
|
|
|
|
}
|
|
|
|
|
2022-06-23 09:15:25 +00:00
|
|
|
const preloadedCheckoutData = getSetting(
|
|
|
|
'checkoutData',
|
|
|
|
{}
|
|
|
|
) as Partial< CheckoutResponseSuccess >;
|
2022-06-10 16:33:15 +00:00
|
|
|
|
|
|
|
export const checkoutData = {
|
|
|
|
order_id: 0,
|
|
|
|
customer_id: 0,
|
2022-10-06 14:48:52 +00:00
|
|
|
billing_address: {} as BillingAddress,
|
|
|
|
shipping_address: {} as ShippingAddress,
|
2024-02-06 15:16:00 +00:00
|
|
|
additional_fields: {} as AdditionalValues,
|
2022-06-10 16:33:15 +00:00
|
|
|
...( preloadedCheckoutData || {} ),
|
|
|
|
};
|