@cloudcomponents/cdk-stripe-webhook
Create, update and delete stripe webhooks with your app deployment
Install
TypeScript/JavaScript:
npm i @cloudcomponents/cdk-stripe-webhook
Python:
pip install cloudcomponents.cdk-stripe-webhook
How to use
EventBus Producer
import { SecretKey, SecretKeyStore } from '@cloudcomponents/cdk-secret-key';
import { StripeWebhook, StripeEventBusProducer } from '@cloudcomponents/cdk-stripe-webhook';
import { Stack, StackProps, aws_ssm } from 'aws-cdk-lib';
import { Construct } from 'constructs';
export class StripeWebhookEventBusStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
if (typeof process.env.SECRET_KEY === 'undefined') {
throw new Error('environment variable SECRET_KEY undefined');
}
const secretKey = SecretKey.fromPlainText(process.env.SECRET_KEY);
const endpointSecretParameter = aws_ssm.StringParameter.fromSecureStringParameterAttributes(this, 'Param', {
parameterName: 'stripe',
version: 1,
});
const producer = new StripeEventBusProducer(this, 'Producer', {
secretKey,
endpointSecret: SecretKey.fromSSMParameter(endpointSecretParameter),
});
const events = ['charge.failed', 'charge.succeeded'];
const endpointSecretStore = SecretKeyStore.fromSSMParameter(endpointSecretParameter);
new StripeWebhook(this, 'StripeWebhook', {
secretKey,
url: producer.url,
events,
logLevel: 'debug',
endpointSecretStore,
});
}
}
Custom Handler
import { SecretKey } from '@cloudcomponents/cdk-secret-key';
import { StripeWebhook } from '@cloudcomponents/cdk-stripe-webhook';
import { Stack, StackProps, aws_apigateway } from 'aws-cdk-lib';
import { Construct } from 'constructs';
export class StripeWebhookStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const api = new aws_apigateway.RestApi(this, 'Endpoint');
api.root.addMethod('POST');
if (typeof process.env.SECRET_KEY === 'undefined') {
throw new Error('environment variable SECRET_KEY undefined');
}
const secretKey = SecretKey.fromPlainText(process.env.SECRET_KEY);
const events = ['charge.failed', 'charge.succeeded'];
new StripeWebhook(this, 'StripeWebhook', {
secretKey,
url: api.url,
events,
logLevel: 'debug',
});
}
}
API Reference
See API.md.
Example
See more complete examples.
License
Metadata
Release files for cloudcomponents.cdk-stripe-webhook 2.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cloudcomponents.cdk-stripe-webhook-2.4.0.tar.gz | 703.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cloudcomponents.cdk_stripe_webhook-2.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.4 MB
Release files / cloudcomponents.cdk-stripe-webhook-2.4.0.tar.gz
| Download URL | cloudcomponents.cdk-stripe-webhook-2.4.0.tar.gz |
|---|---|
| Size | 703.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04f84d805eda0083d764ae899862050bd95206b44f77e97da5e65e35382649c4
|
|
BLAKE2b-256 checksum How to use checksums |
47423ac2aa75dfba42dcb254c709733459c55e0ba0d23854dfc209b919c23b19
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|
Release files / cloudcomponents.cdk_stripe_webhook-2.4.0-py3-none-any.whl
| Download URL | cloudcomponents.cdk_stripe_webhook-2.4.0-py3-none-any.whl |
|---|---|
| Size | 702.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9f7b3da8e62c80c662fd684e29e311f6f333815346759128c1ca593133853efb
|
|
BLAKE2b-256 checksum How to use checksums |
3da2f9eb46a12ca13405ff714f2a55511b0332de9f7ff88e8c80fa337589641a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|