mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
Initial work, copied from the Shopify provider
This commit is contained in:
26
framework/saleor/utils/checkout-create.ts
Normal file
26
framework/saleor/utils/checkout-create.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import Cookies from 'js-cookie'
|
||||
|
||||
import checkoutCreateMutation from './mutations/checkout-create'
|
||||
import { CheckoutCreatePayload } from '../schema'
|
||||
|
||||
export const checkoutCreate = async (
|
||||
fetch: any
|
||||
): Promise<CheckoutCreatePayload> => {
|
||||
const data = await fetch({
|
||||
query: checkoutCreateMutation,
|
||||
})
|
||||
|
||||
const checkout = data.checkoutCreate?.checkout
|
||||
const checkoutId = checkout?.id
|
||||
|
||||
if (checkoutId) {
|
||||
const options = {
|
||||
expires: 60 * 60 * 24 * 30,
|
||||
}
|
||||
Cookies.set('saleorCheckoutID', checkoutId, options)
|
||||
}
|
||||
|
||||
return checkout
|
||||
}
|
||||
|
||||
export default checkoutCreate
|
Reference in New Issue
Block a user