-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
559 additions
and
644 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
.github/workflows/promo-codes.yaml → ...hub/workflows/stripe-promotion-codes.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const DEBUG_PREFIX = '11ty-plugin:stripe' | ||
|
||
export const ERROR_PREFIX = '[💰 11ty-plugin:stripe]' | ||
|
||
export const DEFAULT_STRIPE_CONFIG = {} | ||
|
||
export const DEFAULT_PLUGIN_CONFIG = { | ||
stripeConfig: DEFAULT_STRIPE_CONFIG | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import defDebug from 'debug' | ||
import Stripe from 'stripe' | ||
import { DEBUG_PREFIX, ERROR_PREFIX } from './constants.mjs' | ||
import { plugin_options, stripe_price_lookup_key } from './schemas.mjs' | ||
import { paymentLinksByPriceLookupKey } from './utils.mjs' | ||
|
||
const debug = defDebug(`${DEBUG_PREFIX}:index`) | ||
|
||
// TIP: give the plugin configuration function a name, so it can be easily | ||
// spotted in EleventyErrorHandler. | ||
export const stripePlugin = (eleventyConfig, options) => { | ||
const result = plugin_options.safeParse(options) | ||
if (!result.success) { | ||
throw new Error( | ||
`${ERROR_PREFIX} invalid configuration: ${result.error.message}` | ||
) | ||
} | ||
|
||
const { apiKey, stripeConfig } = result.data | ||
|
||
const matches = apiKey.match(/^sk_test_./) | ||
const is_test = matches ? true : false | ||
|
||
const client = new Stripe(apiKey, stripeConfig) | ||
|
||
eleventyConfig.addAsyncFilter('stripePaymentLinks', async (lookup_key) => { | ||
stripe_price_lookup_key.parse(lookup_key) | ||
|
||
// My plugin is an alternative solution to the original Stripe buy button | ||
// https://stripe.com/docs/payment-links/share#embed-button | ||
const plinks = await paymentLinksByPriceLookupKey({ | ||
stripe: client, | ||
is_test, | ||
lookup_key | ||
}) | ||
|
||
return plinks | ||
}) | ||
debug(`added async filter stripePaymentLinks`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { z } from 'zod' | ||
import { DEFAULT_STRIPE_CONFIG } from './constants.mjs' | ||
|
||
// https://stripe.com/docs/api/prices/object#price_object-lookup_key | ||
export const stripe_price_lookup_key = z.string().min(1).max(200) | ||
|
||
export const plugin_options = z.object({ | ||
// optional, so it can be set with an environment variable | ||
apiKey: z.string().min(1).optional(), | ||
|
||
stripeConfig: z.any().default(DEFAULT_STRIPE_CONFIG) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
export const DEBUG_PREFIX = '11ty-plugin:webmentions' | ||
|
||
export const ERROR_PREFIX = '[💬 11ty-plugin-webmentions]' | ||
|
||
export const DEFAULT_BLACKLISTED = [] | ||
|
||
export const DEFAULT_CACHE_DIRECTORY = '.cache-webmentions' | ||
export const DEFAULT_CACHE_DURATION = '3600s' | ||
export const DEFAULT_CACHE_VERBOSE = false | ||
|
||
export const DEFAULT_DOMAIN = undefined | ||
|
||
// https://github.com/apostrophecms/sanitize-html#default-options | ||
export const DEFAULT_SANITIZE_OPTIONS = { | ||
allowedTags: ['b', 'i', 'em', 'strong', 'a', 'p'], | ||
allowedAttributes: { | ||
a: ['href'] | ||
} | ||
} | ||
|
||
export const DEFULT_TOKEN = undefined | ||
|
||
export const DEFAULT_PLUGIN_CONFIG = { | ||
blacklisted: DEFAULT_BLACKLISTED, | ||
cacheDirectory: DEFAULT_CACHE_DIRECTORY, | ||
cacheDuration: DEFAULT_CACHE_DURATION, | ||
cacheVerbose: DEFAULT_CACHE_VERBOSE, | ||
domain: DEFAULT_DOMAIN, | ||
sanitizeOptions: DEFAULT_SANITIZE_OPTIONS, | ||
token: DEFULT_TOKEN | ||
} |
Oops, something went wrong.