refactor: update external checkout and docs

This commit is contained in:
Bolaji Ayodeji 2021-09-16 15:10:10 +01:00 committed by Alessandro Casazza
parent 7cc48a9d35
commit 16a9862b53
No known key found for this signature in database
GPG Key ID: 3AF41B06C6495D3D
4 changed files with 18 additions and 12 deletions

View File

@ -16,9 +16,7 @@ Next, add the application credentials from your organization's application dashb
## Checkout
Demo checkout in this provider is powered by the open-sourced [Commmerce Layer Checkout](https://github.com/commercelayer/commercelayer-checkout) application that provides you with a PCI-compliant, PSD2-compliant, and production-ready checkout flow that lets you easily place orders through the Commerce Layer API. In addition, you can set up your checkout app and deploy it to Vercel with one click below:
[![Deploy to Vercel](https://vercel.co/button)](https://vercel.co/new/project?template=https://github.com/commercelayer/commercelayer-checkout)
Demo checkout in this provider is powered by the open-sourced [Commmerce Layer Checkout](#) application that provides you with a PCI-compliant, PSD2-compliant, and production-ready checkout flow that lets you easily place orders through the Commerce Layer API.
## Future upgrades

View File

@ -22,7 +22,7 @@ const checkout: CheckoutEndpoint['handlers']['checkout'] = async ({
const checkoutUrl = clOrder.data.attributes.checkout_url
if (checkoutUrl) {
res.redirect(checkoutUrl)
res.redirect(`${checkoutUrl}?accessToken=${accessToken}`)
} else {
res.redirect('/cart')
}

View File

@ -33,10 +33,12 @@ const operations = {
export const provider = { config, operations }
export type Provider = typeof provider
export type CommercelayerAPI<P extends Provider = Provider> = CommerceAPI<P | any>
export type CommercelayerAPI<P extends Provider = Provider> = CommerceAPI<
P | any
>
export function getCommerceApi<P extends Provider>(
customProvider: P = provider as any
): CommercelayerAPI<P> {
return commerceApi(customProvider as any)
}
}

View File

@ -22,18 +22,24 @@ export default function getSiteInfoOperation({}: OperationContext<any>) {
} = {}): Promise<GetSiteInfoResult> {
return Promise.resolve({
categories: [
{
id: 'new-arrivals',
name: 'New Arrivals',
slug: 'new-arrivals',
path: '/new-arrivals',
},
{
id: 'featured',
name: 'Featured',
slug: 'featured',
path: '/featured',
},
{
id: 'clothings',
name: 'Clothings',
slug: 'clothings',
path: '/clothings',
},
{
id: 'household',
name: 'Household',
slug: 'household',
path: '/household',
},
],
brands: [],
})