Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

lemonSqueezySetup

Caven edited this page Jan 29, 2024 · 1 revision

lemonSqueezySetup

Initialization configuration.

Only three functions (activateLicense,validateLicense,deactivateLicense) operate without requiring an API key. To use other functions, you must employ lemonSqueezySetup to configure the apiKey before utilization.

Create a new API key: https://app.lemonsqueezy.com/settings/api.

Usage

Configure the API Key

import { lemonSqueezySetup } from '@heybrostudio/lemonsqueezy.js'

lemonSqueezySetup({
  apiKey: 'Your Lemon Squeezy API Key',
})

Configure the global fetch response error handling method:

import { lemonSqueezySetup } from '@heybrostudio/lemonsqueezy.js'

lemonSqueezySetup({
  apiKey: import.meta.env.LEMON_SQUEEZY_API_KEY,
  onError(error) {
    console.log(error)
  },
})

Type Declarations

type Config = {
  /**
   * `Lemon Squeezy` API Key
   */
  apiKey?: string
  /**
   * Fires after a fetch response error
   *
   * @param error Error
   * @returns void
   */
  onError?: (error: Error) => void
}

/**
 * Lemon squeezy setup.
 *
 * @param config The config.
 * @returns User configuration.
 */
declare function lemonSqueezySetup(config: Config): Config

Source

Source ~ Type ~ Test

Clone this wiki locally