@stepanjakl/apostrophe-stripe-products

0.0.5 • Public • Published

Stripe Products For ApostropheCMS


License

Unit Tests


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.


Admin UI 1
Admin UI 2 Admin UI 3 Admin UI 4

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.


Unit Tests

To run tests locally, you'll need to set up the stripe/stripe-mock package:

brew install stripe/stripe-mock/stripe-mock

brew services start stripe-mock

Once set up, run tests using npm run tests to validate any changes before deploying them.


TODOs (Limitations)

  • fix disappering stripeProductObject and stripePriceObject data when moved between draft and published modes and vice versa

Package Sidebar

Install

npm i @stepanjakl/apostrophe-stripe-products

Weekly Downloads

104

Version

0.0.5

License

MIT

Unpacked Size

168 kB

Total Files

17

Last publish

Collaborators

  • stepanjakl