Create, update and delete stripe webhooks with your app deployment
Project description
@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 { StringParameter } from '@aws-cdk/aws-ssm';
import { Construct, Stack, StackProps } from '@aws-cdk/core';
import { SecretKey, SecretKeyStore } from '@cloudcomponents/cdk-secret-key';
import { StripeWebhook, StripeEventBusProducer } from '@cloudcomponents/cdk-stripe-webhook';
export class StripeWebhookStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const secretKey = SecretKey.fromPlainText(process.env.SECRET_KEY as string);
const endpointSecretParameter = 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 { RestApi } from '@aws-cdk/aws-apigateway';
import { Construct, Stack, StackProps } from '@aws-cdk/core';
import { SecretKey } from '@cloudcomponents/cdk-secret-key';
import { StripeWebhook } from '@cloudcomponents/cdk-stripe-webhook';
export class StripeWebhookStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const api = new RestApi(this, 'Endpoint');
api.root.addMethod('POST');
const secretKey = SecretKey.fromPlainText(process.env.SECRET_KEY as string);
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for cloudcomponents.cdk-stripe-webhook-1.49.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f9d2081b8cc63fda1fa1b09075f3ca2a9c944d0df2c99fc9645da6430768ee2 |
|
MD5 | a90a25c8a31c5bd01cb87c2ebd0268b0 |
|
BLAKE2b-256 | 8c479b75fe9cdf2cb726d1c2a82f7953d1c41e22a8d25b381d2d7f1cb4fb1453 |
Close
Hashes for cloudcomponents.cdk_stripe_webhook-1.49.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de70bd0bfd284b0c7bb116edf1143129dde27b801ae2f0e58671a15dfcd07200 |
|
MD5 | 33e27312cdb9f5c454c5339c44d40963 |
|
BLAKE2b-256 | 1916540de52d4dbe23f309d38ea96fa0f03645724d3d7a8cad4c86e10ce01a3d |