aamdmn

payload polar

by aamdmn
Payments
v3
^3.37.0

Overview

Summary generated from the README

A work-in-progress plugin intended to connect Payload CMS with It is built from the standard Payload plugin template and targets Payload 3.37 or newer. The actual Polar functionality is not yet described.

Features

  • Built from the Payload plugin template
  • Registers through the plugins array in the Payload config
  • Targets Payload 3.37 and newer

Use cases

  • Follow early development of a integration for Payload

From the author

A blank template to get started with Payload 3.0

Installation

npm i payload-polar

0

Stars

0

Forks

0

Open Issues

1 years ago

Last Updated

6

Weekly Downloads

v1.0.0

npm Version

26.2 KB

Unpacked Size

0

Dependencies

GitHub stars

00 since Sep 6

Show data
GitHub stars by day (UTC)
DateStars
Dec 5, 20260
Dec 4, 20260
Dec 3, 20260
Dec 2, 20260
Dec 1, 20260
Nov 30, 20260
Nov 29, 20260
Nov 28, 20260
Nov 27, 20260
Nov 26, 20260
Nov 25, 20260
Nov 24, 20260
Nov 23, 20260
Nov 22, 20260
Nov 21, 20260
Nov 20, 20260
Nov 19, 20260
Nov 18, 20260
Nov 17, 20260
Nov 16, 20260
Nov 15, 20260
Nov 14, 20260
Nov 13, 20260
Nov 12, 20260
Nov 11, 20260
Nov 10, 20260
Nov 9, 20260
Nov 8, 20260
Nov 7, 20260
Nov 6, 20260
Nov 5, 20260
Nov 4, 20260
Nov 3, 20260
Nov 2, 20260
Nov 1, 20260
Oct 31, 20260
Oct 30, 20260
Oct 29, 20260
Oct 28, 20260
Oct 27, 20260
Oct 26, 20260
Oct 25, 20260
Oct 24, 20260
Oct 23, 20260
Oct 22, 20260
Oct 21, 20260
Oct 20, 20260
Oct 19, 20260
Oct 18, 20260
Oct 17, 20260
Oct 16, 20260
Oct 15, 20260
Oct 14, 20260
Oct 13, 20260
Oct 12, 20260
Oct 11, 20260
Oct 10, 20260
Oct 9, 20260
Oct 8, 20260
Oct 7, 20260
Oct 6, 20260
Oct 5, 20260
Oct 4, 20260
Oct 3, 20260
Oct 2, 20260
Oct 1, 20260
Sep 30, 20260
Sep 29, 20260
Sep 28, 20260
Sep 27, 20260
Sep 26, 20260
Sep 25, 20260
Sep 24, 20260
Sep 23, 20260
Sep 22, 20260
Sep 21, 20260
Sep 20, 20260
Sep 19, 20260
Sep 18, 20260
Sep 17, 20260
Sep 16, 20260
Sep 15, 20260
Sep 14, 20260
Sep 13, 20260
Sep 12, 20260
Sep 11, 20260
Sep 10, 20260
Sep 9, 20260
Sep 8, 20260
Sep 7, 20260
Sep 6, 20260
npm weekly downloads

4−2 since Sep 6

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 20264
Dec 4, 20264
Dec 3, 20262
Dec 2, 20262
Dec 1, 20264
Nov 30, 20264
Nov 29, 20264
Nov 28, 20264
Nov 27, 20264
Nov 26, 20264
Nov 25, 20264
Nov 24, 20262
Nov 23, 20262
Nov 22, 20262
Nov 21, 20262
Nov 20, 20261
Nov 19, 20262
Nov 18, 20263
Nov 17, 20263
Nov 16, 20265
Nov 15, 20264
Nov 14, 20264
Nov 13, 20266
Nov 12, 20267
Nov 11, 20266
Nov 10, 20267
Nov 9, 20265
Nov 8, 20266
Nov 7, 20266
Nov 6, 20264
Nov 5, 20262
Nov 4, 20262
Nov 3, 20261
Nov 2, 20265
Nov 1, 20264
Oct 31, 20264
Oct 30, 20264
Oct 29, 20264
Oct 28, 20264
Oct 27, 20265
Oct 26, 20262
Oct 25, 20262
Oct 24, 20264
Oct 23, 20264
Oct 22, 20265
Oct 21, 20265
Oct 20, 20264
Oct 19, 20263
Oct 18, 20264
Oct 17, 20263
Oct 16, 20263
Oct 15, 20263
Oct 14, 20263
Oct 13, 20263
Oct 12, 20263
Oct 11, 20263
Oct 10, 20262
Oct 9, 20262
Oct 8, 20261
Oct 7, 20261
Oct 6, 20261
Oct 5, 20261
Oct 4, 20260
Oct 3, 20261
Oct 2, 20263
Oct 1, 20263
Sep 30, 20263
Sep 29, 20264
Sep 28, 20264
Sep 27, 20265
Sep 26, 20267
Sep 25, 20265
Sep 24, 20265
Sep 23, 20265
Sep 22, 20265
Sep 21, 20265
Sep 20, 20265
Sep 19, 20262
Sep 18, 20262
Sep 17, 20263
Sep 16, 20264
Sep 15, 20263
Sep 14, 20265
Sep 13, 20264
Sep 12, 20267
Sep 11, 20267
Sep 10, 20266
Sep 9, 20266
Sep 8, 20266
Sep 7, 20266
Sep 6, 20266

Each point is npm's rolling 7-day download count.

Health Score

29/100Fair

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1080412127-root.svg)](https://payloaddirectory.dev/plugins/1080412127-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1080412127-root"><img src="https://payloaddirectory.dev/badge/1080412127-root.svg" alt="Payload Directory"></a>
Updated Oct 21, 2025Created Oct 21, 2025Published Oct 21, 2025

README

WIP: This repo is a work in progress for the polar.sh plugin for PayloadCMS

Payload Plugin Template

A template repo to create a Payload CMS plugin.

Payload is built with a robust infrastructure intended to support Plugins with ease. This provides a simple, modular, and reusable way for developers to extend the core capabilities of Payload.

To build your own Payload plugin, all you need is:

  • An understanding of the basic Payload concepts
  • And some JavaScript/Typescript experience

Background

Here is a short recap on how to integrate plugins with Payload, to learn more visit the plugin overview page.

How to install a plugin

To install any plugin, simply add it to your payload.config() in the Plugin array.

import myPlugin from 'my-plugin'

export const config = buildConfig({
  plugins: [
    // You can pass options to the plugin
    myPlugin({
      enabled: true,
    }),
  ],
})

Initialization

The initialization process goes in the following order:

  1. Incoming config is validated
  2. Plugins execute
  3. Default options are integrated
  4. Sanitization cleans and validates data
  5. Final config gets initialized

Building the Plugin

When you build a plugin, you are purely building a feature for your project and then abstracting it outside of the project.

Template Files

In the Payload plugin template, you will see a common file structure that is used across all plugins:

  1. root folder
  2. /src folder
  3. /dev folder
Root

In the root folder, you will see various files that relate to the configuration of the plugin. We set up our environment in a similar manner in Payload core and across other projects, so hopefully these will look familiar:

  • README.md* - This contains instructions on how to use the template. When you are ready, update this to contain instructions on how to use your Plugin.
  • package.json* - Contains necessary scripts and dependencies. Overwrite the metadata in this file to describe your Plugin.
  • .eslint.config.js - Eslint configuration for reporting on problematic patterns.
  • .gitignore - List specific untracked files to omit from Git.
  • .prettierrc.json - Configuration for Prettier code formatting.
  • tsconfig.json - Configures the compiler options for TypeScript
  • .swcrc - Configuration for SWC, a fast compiler that transpiles and bundles TypeScript.
  • vitest.config.js - Config file for Vitest, defining how tests are run and how modules are resolved

IMPORTANT*: You will need to modify these files.

Dev

In the dev folder, you’ll find a basic payload project, created with npx create-payload-app and the blank template.

IMPORTANT: Make a copy of the .env.example file and rename it to .env. Update the DATABASE_URI to match the database you are using and your plugin name. Update PAYLOAD_SECRET to a unique string. You will not be able to run pnpm/yarn dev until you have created this .env file.

myPlugin has already been added to the payload.config() file in this project.

plugins: [
  myPlugin({
    collections: {
      posts: true,
    },
  }),
]

Later when you rename the plugin or add additional options, make sure to update it here.

You may wish to add collections or expand the test project depending on the purpose of your plugin. Just make sure to keep this dev environment as simplified as possible - users should be able to install your plugin without additional configuration required.

When you’re ready to start development, initiate the project with pnpm/npm/yarn dev and pull up http://localhost:3000 in your browser.

Src

Now that we have our environment setup and we have a dev project ready to - it’s time to build the plugin!

index.ts

The essence of a Payload plugin is simply to extend the payload config - and that is exactly what we are doing in this file.

export const myPlugin =
  (pluginOptions: MyPluginConfig) =>
  (config: Config): Config => {
    // do cool stuff with the config here

    return config
  }

First, we receive the existing payload config along with any plugin options.

From here, you can extend the config as you wish.

Finally, you return the config and that is it!

Spread Syntax

Spread syntax (or the spread operator) is a feature in JavaScript that uses the dot notation (...) to spread elements from arrays, strings, or objects into various contexts.

We are going to use spread syntax to allow us to add data to existing arrays without losing the existing data. It is crucial to spread the existing data correctly – else this can cause adverse behavior and conflicts with Payload config and other plugins.

Let’s say you want to build a plugin that adds a new collection:

config.collections = [
  ...(config.collections || []),
  // Add additional collections here
]

First we spread the config.collections to ensure that we don’t lose the existing collections, then you can add any additional collections just as you would in a regular payload config.

This same logic is applied to other properties like admin, hooks, globals:

config.globals = [
  ...(config.globals || []),
  // Add additional globals here
]

config.hooks = {
  ...(incomingConfig.hooks || {}),
  // Add additional hooks here
}

Some properties will be slightly different to extend, for instance the onInit property:

import { onInitExtension } from './onInitExtension' // example file

config.onInit = async (payload) => {
  if (incomingConfig.onInit) await incomingConfig.onInit(payload)
  // Add additional onInit code by defining an onInitExtension function
  onInitExtension(pluginOptions, payload)
}

If you wish to add to the onInit, you must include the async/await. We don’t use spread syntax in this case, instead you must await the existing onInit before running additional functionality.

In the template, we have stubbed out some addition onInit actions that seeds in a document to the plugin-collection, you can use this as a base point to add more actions - and if not needed, feel free to delete it.

Types.ts

If your plugin has options, you should define and provide types for these options.

export type MyPluginConfig = {
  /**
   * List of collections to add a custom field
   */
  collections?: Partial<Record<CollectionSlug, true>>
  /**
   * Disable the plugin
   */
  disabled?: boolean
}

If possible, include JSDoc comments to describe the options and their types. This allows a developer to see details about the options in their editor.

Testing

Having a test suite for your plugin is essential to ensure quality and stability. Vitest is a fast, modern testing framework that works seamlessly with Vite and supports TypeScript out of the box.

Vitest organizes tests into test suites and cases, similar to other testing frameworks. We recommend creating individual tests based on the expected behavior of your plugin from start to finish.

Writing tests with Vitest is very straightforward, and you can learn more about how it works in the Vitest documentation.

For this template, we stubbed out int.spec.ts in the dev folder where you can write your tests.

describe('Plugin tests', () => {
  // Create tests to ensure expected behavior from the plugin
  it('some condition that must be met', () => {
   // Write your test logic here
   expect(...)
  })
})

Best practices

With this tutorial and the plugin template, you should have everything you need to start building your own plugin. In addition to the setup, here are other best practices aim we follow:

  • Providing an enable / disable option: For a better user experience, provide a way to disable the plugin without uninstalling it. This is especially important if your plugin adds additional webpack aliases, this will allow you to still let the webpack run to prevent errors.
  • Include tests in your GitHub CI workflow: If you’ve configured tests for your package, integrate them into your workflow to run the tests each time you commit to the plugin repository. Learn more about how to configure tests into your GitHub CI workflow.
  • Publish your finished plugin to NPM: The best way to share and allow others to use your plugin once it is complete is to publish an NPM package. This process is straightforward and well documented, find out more creating and publishing a NPM package here..
  • Add payload-plugin topic tag: Apply the tag **payload-plugin **to your GitHub repository. This will boost the visibility of your plugin and ensure it gets listed with existing payload plugins.
  • Use Semantic Versioning (SemVar) - With the SemVar system you release version numbers that reflect the nature of changes (major, minor, patch). Ensure all major versions reference their Payload compatibility.

Questions

Please contact Payload with any questions about using this plugin template.

Tags

Similar plugins