From 16a9862b53cbb44d3a0047769e77278a0a6492dd Mon Sep 17 00:00:00 2001 From: Bolaji Ayodeji Date: Thu, 16 Sep 2021 15:10:10 +0100 Subject: [PATCH] refactor: update external checkout and docs --- framework/commercelayer/README.md | 4 +--- .../api/endpoints/checkout/checkout.ts | 2 +- framework/commercelayer/api/index.ts | 6 ++++-- .../api/operations/get-site-info.ts | 18 ++++++++++++------ 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/framework/commercelayer/README.md b/framework/commercelayer/README.md index 8826d280c..e77351a1d 100644 --- a/framework/commercelayer/README.md +++ b/framework/commercelayer/README.md @@ -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 diff --git a/framework/commercelayer/api/endpoints/checkout/checkout.ts b/framework/commercelayer/api/endpoints/checkout/checkout.ts index 68dbc5f6f..516909764 100644 --- a/framework/commercelayer/api/endpoints/checkout/checkout.ts +++ b/framework/commercelayer/api/endpoints/checkout/checkout.ts @@ -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') } diff --git a/framework/commercelayer/api/index.ts b/framework/commercelayer/api/index.ts index 709159777..50b1195e8 100644 --- a/framework/commercelayer/api/index.ts +++ b/framework/commercelayer/api/index.ts @@ -33,10 +33,12 @@ const operations = { export const provider = { config, operations } export type Provider = typeof provider -export type CommercelayerAPI

= CommerceAPI

+export type CommercelayerAPI

= CommerceAPI< + P | any +> export function getCommerceApi

( customProvider: P = provider as any ): CommercelayerAPI

{ return commerceApi(customProvider as any) -} +} \ No newline at end of file diff --git a/framework/commercelayer/api/operations/get-site-info.ts b/framework/commercelayer/api/operations/get-site-info.ts index b7f3b6226..6af7fbe78 100644 --- a/framework/commercelayer/api/operations/get-site-info.ts +++ b/framework/commercelayer/api/operations/get-site-info.ts @@ -22,18 +22,24 @@ export default function getSiteInfoOperation({}: OperationContext) { } = {}): Promise { 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: [], })