Validate new AWS customers
- Dominant language
- JavaScript
- Stars
- 400
- Forks
- 89
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 149
Description
## Describtion
Create a service to validate new AWS customers for FF-Cloud, by handling the subscription process as detailed in the [AWS documentation](https://docs.aws.amazon.com/marketplacemetering/latest/APIReference/API_ResolveCustomer.html). This process includes exchanging the registration token for customer information, persisting the customer information.
## Requirements
- Implement a route to handle the HTTP POST request with the x-amzn-marketplace-token received during the customer subscription process.
- Call the ResolveCustomer API operation in the AWS Marketplace Metering Service to exchange the token for a CustomerIdentifier, CustomerAWSAccountId, and ProductCode.
- Store the CustomerIdentifier, CustomerAWSAccountId, ProductCode, and subscription status.
- Disable Stripe for AWS customers, instead use https://github.com/flowforge/flowforge/issues/1943
### Epic/Story
https://github.com/flowforge/flowforge/issues/1927
### JS Example
```javascript
// Import AWS SDK for JavaScript and querystring
const AWS = require('aws-sdk');
const querystring = require('querystring');
// Parse the POST body to get the registration token
const postBody = '...'; // Replace with the actual POST body
const formFields = querystring.parse(postBody);
const regToken = formFields['x-amzn-marketplace-token'];
// If regToken is present in the POST request, exchange it for customerID
if (regToken) {
const marketplaceClient = new AWS.MarketplaceMetering({ apiVersion: '2016-01-14' });
const params = {
RegistrationToken: regToken,
};
marketplaceClient.resolveCustomer(params, (err, customerData) => {
if (err) {
console.error(err, err.stack);
} else {
const productCode = customerData.ProductCode;
const customerID = customerData.CustomerIdentifier;
const customerAWSAccountId = customerData.CustomerAWSAccountId;
// TODO: Store customer information
// TODO: Validate no other accounts share the same customerID
console.log('Example response:', customerData);
}
});
}
```
#### Response
```json
{
"CustomerIdentifier": "string",
"CustomerAWSAccountId": "string",
"ProductCode": "string",
}
```
Contributor guide
Assessment
This issue has not been assessed yet.