@stepanjakl/apostrophe-stripe-products v0.0.3
This module adds a piece module and utility operation to automatically synchronize Stripe Products with the database. Saved products can be easily accessed and viewed via the admin UI.
Installation
Use your preferred package manager to install the module. You'll also need to install the read-only-field package alongside it:
npm install stripe-products@npm:@stepanjakl/apostrophe-stripe-products
npm install read-only-field@npm:@stepanjakl/apostrophe-read-only-field
Examples
It is highly recommended to explore the apostrophe-stripe-examples repository, which offers a comprehensive set of examples and full configurations demonstrating how to set up a complete e-commerce store experience.
Usage
First, add installed modules to your configuration in the app.js
root file:
require('apostrophe')({
shortName: 'project-name',
modules: {
// Custom fields
'read-only-field': {},
// Stripe Products
'stripe-products': {},
'stripe-products/product': {}
}
});
Then, set global variables inside the .env
file. It's important to set the STRIPE_TEST_MODE
variable to anything other than false
to enable test mode.
PORT='4000'
APOS_BASE_URL='http://localhost:4000'
APOS_RELEASE_ID='a4-boilerplate'
APOS_MONGODB_URI='mongodb://localhost:27017/a4-boilerplate'
STRIPE_KEY='sk_test_xyz'
STRIPE_TEST_MODE='false'
STRIPE_DASHBOARD_BASE_URL='https://dashboard.stripe.com'
API Routes
The stripe-products
module contains a custom API route ('/api/v1/stripe-products/synchronize'
) triggered by the Synchronize Products
utility operation. It is executed through the '@apostrophecms/job'
module. Once the job is completed, it saves the difference between the existing and received data to the results object in the aposJobs
collection document.
TODOs (Limitations)
- add tests
- archive products when they are not included in the API request payload