A Lambda function for creating customers and orders to complete a Stripe Relay flow.
Set your Stripe secret key in the .env
file. Copy the sample to get started:
$ cp .env.sample .env
$ sed -i '' "s/<YOUR_SECRET_KEY>/$SECRET_KEY/g" .env
Use the script to create your zip archive:
$ npm run zip
Integrate with the AWS API Gateway to access the function via HTTP POST:
$ curl -X POST -H "Content-Type: application/json" \
-d '{ \
"source": $SOURCE, \
"email": "test@example.com", \
"parent": $SKU_ID, \
"shipping": { \
"name": "John Doe", \
"address": { \
"line1": "123 Fake St.", \
"city": "New York", \
"state": "NY", \
"postal_code": "10001" \
} \
} \
}' \
$API_GATEWAY_URL
Obtain the source
using Checkout and the parent
from the Stripe API, or stripe-products-lambda.
It returns an error, if one is present, or the order object under the root key of order
:
{
"order": {
...order details
}
}