This is a task aiming to validate basic understanding of :
- AWS services: Lambda/DynamoDB/EventBridge/API Gateway
- Serverless framework
The goal of this task is to create a Payment API. The API takes a Payment as input (see spec below) and propagates it to an event bus (EventBridge).
Depending on the paymentSource
field of that event, we'll then invoke one of 2 Lambda handlers and store the Payment in a database.
All the code should be in Typescript
Service should be deployable using sls deploy
POST /pay
{
paymentSource:'client/vendor'
destination:'orbital'
currency: 'USD'
amount: '123.45'
}
This function takes an API gateway request and sends it to Eventbridge as a PaymentCreated
event.
For deduplication purposes, the event should contain the awsRequestId
of the API Gateway event.
Alternatively, you may use an API Gateway proxy integration and skip the lambda function.
{
detail: 'PaymentCreated'
detail-type: {
paymentSource:'client/vendor'
destination:'orbital'
currency: 'USD'
amount: '123.45'
requestId: xxx-yyyy-zzzz
}
}
On events where source is Orbital, we add a a processedBy:'vendorHandler'
field to our payment and save it in a DynamoDB table
On events where source is client, we add a processedBy:'clientHandler'
field to our payment and save it in a DynamoDB table