Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename returnUrl to orderReturnUrl #39

Merged
merged 1 commit into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions packages/docs/stories/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ Assuming you already have a Commerce Layer account ([sign up](https://dashboard.
1. Import the library from the [CDN](https://cdn.jsdelivr.net/npm/@commercelayer/drop-in.js@1.4.0/dist/drop-in/drop-in.esm.js).
2. Declare a global variable called `commercelayerConfig` and set the following attributes.

| Attribute | Type | Required | Description |
|-----------------|--------|:--------:|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **`clientId`** | String | ✓ | Your [sales channel](https://docs.commercelayer.io/core/applications#sales-channel) client ID. You can find it in your application details page on your dashboard. |
| **`slug`** | String | ✓ | Your organization slug (i.e. the subdomain of your base endpoint, usually the slugified version of your organization's name). You can find the base endpoint in your application details page on your dashboard. |
| **`scope`** | String | ✓ | Your sales channel [scope](https://docs.commercelayer.io/core/authentication#authorization-scopes) (use it to restrict the dataset of your application). You can find the allowed scopes in your application details page on your dashboard. |
| `debug` | String | | The debug level. Can be one of `none` or `all`. Default is `none`. |
| `returnUrl` | String | | The URL the cart's *Continue shopping* button points to. This is also used in the thank you page. |
| Attribute | Type | Required | Description |
|----------------------|--------|:--------:|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **`clientId`** | String | ✓ | Your [sales channel](https://docs.commercelayer.io/core/applications#sales-channel) client ID. You can find it in your application details page on your dashboard. |
| **`slug`** | String | ✓ | Your organization slug (i.e. the subdomain of your base endpoint, usually the slugified version of your organization's name). You can find the base endpoint in your application details page on your dashboard. |
| **`scope`** | String | ✓ | Your sales channel [scope](https://docs.commercelayer.io/core/authentication#authorization-scopes) (use it to restrict the dataset of your application). You can find the allowed scopes in your application details page on your dashboard. |
| `debug` | String | | The debug level. Can be one of `none` or `all`. Default is `none`. |
| `orderReturnUrl` | String | | The URL the cart's *Continue shopping* button points to. This is also used in the thank you page. |


The final result should be similar to the code snippet below:
Expand All @@ -31,7 +31,7 @@ Assuming you already have a Commerce Layer account ([sign up](https://dashboard.
slug: 'drop-in-js',
scope: 'market:11709',
debug: 'all', // default is 'none'
returnUrl: 'https://example.com' // optional
orderReturnUrl: 'https://example.com' // optional
}
}());
</script>
Expand Down
2 changes: 1 addition & 1 deletion packages/drop-in/src/apis/commercelayer/cart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function createEmptyCart(): Promise<Order> {
const config = getConfig()
const client = await createClient(config)
const order = await client.orders.create({
return_url: config.returnUrl
return_url: config.orderReturnUrl
})

setCartId(order.id)
Expand Down
8 changes: 4 additions & 4 deletions packages/drop-in/src/apis/commercelayer/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface CommerceLayerConfig {
/**
* Url used in the Hosted Cart to point to "Continue Shopping". This is also used in the thank you page.
*/
returnUrl?: string
orderReturnUrl?: string

/**
* API domain
Expand Down Expand Up @@ -80,11 +80,11 @@ export function getConfig(): Config {
}

if (
commercelayerConfig.returnUrl !== undefined &&
typeof commercelayerConfig.returnUrl !== 'string'
commercelayerConfig.orderReturnUrl !== undefined &&
typeof commercelayerConfig.orderReturnUrl !== 'string'
) {
throw new Error(
`"window.commercelayerConfig.returnUrl" is set but not a string.\n${documentationLink}\n`
`"window.commercelayerConfig.orderReturnUrl" is set but not a string.\n${documentationLink}\n`
)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/drop-in/src/cart.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
slug: 'drop-in-js',
scope: 'market:11709',
debug: 'all',
returnUrl: 'https://example.com'
orderReturnUrl: 'https://example.com'
}
}());
</script>
Expand Down
4 changes: 2 additions & 2 deletions packages/drop-in/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
slug: 'drop-in-js-stg',
scope: 'market:545',
debug: 'all',
returnUrl: 'https://example.com'
orderReturnUrl: 'https://example.com'
// validScopes: ['market:545', 'market:1234', ''],
};

Expand All @@ -54,7 +54,7 @@
// slug: 'drop-in-js',
// scope: 'market:11709',
// debug: 'all',
// returnUrl: 'https://example.com'
// orderReturnUrl: 'https://example.com'
// }
})();
</script>
Expand Down
4 changes: 2 additions & 2 deletions packages/drop-in/src/utils/logger.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ function injectConfig({
slug = 'example',
scope = 'market:123',
debug,
returnUrl
orderReturnUrl
}: Partial<Config>): void {
Object.defineProperty(window, 'commercelayerConfig', {
value: {
clientId,
slug,
scope,
debug,
returnUrl
orderReturnUrl
}
})
}
Expand Down