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.50.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b0f470367ac15418831ef4d0c0bc8adf74b34718e782da7df2a1d65d4d3a9d0 |
|
MD5 | b6da3c36f354501c1274594be9a2ed68 |
|
BLAKE2b-256 | 186f4f0f56ae306e15f453ccdf077d86b44d6c0e264b10b15f6a83887dbbcea6 |
Close
Hashes for cloudcomponents.cdk_stripe_webhook-1.50.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a81201945602d78fe1e28b682d38f9e3e84312186fdc86a3aa6d08a6bf731fee |
|
MD5 | 32fce2c2b2fa033e96fad1af94523d63 |
|
BLAKE2b-256 | 3c5d9712bf9c4f3c30789165571f73ca6e33aec3a5bee051a0de89a82ac48d89 |