docs: update provider docs and cleanup

This commit is contained in:
Bolaji Ayodeji 2021-09-09 08:38:34 +01:00 committed by Alessandro Casazza
parent 187739c951
commit 7cc48a9d35
No known key found for this signature in database
GPG Key ID: 3AF41B06C6495D3D
3 changed files with 8 additions and 7 deletions

View File

@ -1,12 +1,10 @@
# Commerce Layer Provider # Commerce Layer Provider
⚠️ This provider is still a work in progress.
Before getting started, you should do the following: Before getting started, you should do the following:
- Create a Commerce Layer [developer account](https://commercelayer.io). - Create a Commerce Layer [developer account](https://commercelayer.io).
- Create a new [organization](https://commercelayer.io/docs/data-model/users-and-organizations/) for your business. - Create a new [organization](https://commercelayer.io/docs/data-model/users-and-organizations/) for your business.
- Create an application with `sales_channel` kind. - Create an application with the `sales_channel` kind.
Next, copy the `.env.template` file in this directory to `.env.local` in the main directory (which will be ignored by Git): Next, copy the `.env.template` file in this directory to `.env.local` in the main directory (which will be ignored by Git):
@ -14,14 +12,18 @@ Next, copy the `.env.template` file in this directory to `.env.local` in the mai
cp framework/commercelayer/.env.template .env.local cp framework/commercelayer/.env.template .env.local
``` ```
Next, add the application credentials from your organization application dashboard in `.env.local`. Next, add the application credentials from your organization's application dashboard in `.env.local`.
## Checkout ## 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. You can setup your own checkout app and deploy to Vercel with one click: 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) [![Deploy to Vercel](https://vercel.co/button)](https://vercel.co/new/project?template=https://github.com/commercelayer/commercelayer-checkout)
## Future upgrades
For now, this provider supports a single market. In the future, we would add multi-market support by default so you can add more than one market from your organization to your application. Also, note that the demo is configured to serve a European market; hence you need to checkout with an address in Europe to get the available shipping methods. You can learn more about how to create markets in different categorized geographical regions for your organization [here](https://commercelayer.io/docs/data-model/markets-and-business-models).
## Contribute ## Contribute
Our commitment to Open Source can be found [here](https://vercel.com/oss). Our commitment to Open Source can be found [here](https://vercel.com/oss).

View File

@ -10,7 +10,6 @@ const checkout: CheckoutEndpoint['handlers']['checkout'] = async ({
const name = 'CL_TOKEN' + "="; const name = 'CL_TOKEN' + "=";
const cookiesArr = decodeURIComponent(accessToken = typeof accessToken === 'string' ? accessToken : '').split('; '); const cookiesArr = decodeURIComponent(accessToken = typeof accessToken === 'string' ? accessToken : '').split('; ');
accessToken = typeof accessToken
cookiesArr.forEach(val => { cookiesArr.forEach(val => {
if (val.indexOf(name) === 0) accessToken = val.substring(name.length) if (val.indexOf(name) === 0) accessToken = val.substring(name.length)
}) })

View File

@ -13,7 +13,7 @@ export const handler: SWRHook<CustomerHook> = {
url: `${ENDPOINT}/api/customers/${customerId}`, url: `${ENDPOINT}/api/customers/${customerId}`,
method: 'GET', method: 'GET',
}, },
async fetcher({ input, options, fetch }) { async fetcher({ options, fetch }) {
const data = await fetch({...options}) const data = await fetch({...options})
return data ? ({ return data ? ({