Socket
Book a DemoInstallSign in
Socket

create-order

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-order

Basic checkout page & checkout process & order creation for single-product stores.

Source
npmnpm
Version
1.1.6
Version published
Weekly downloads
16
Maintainers
1
Weekly downloads
 
Created
Source

Create Order

Basic checkout page & checkout process & order creation for single-product stores.

Installation

Using npm:

$ npm install create-order --save

Using yarn:

$ yarn add create-order

Usage

In ExpressJS:

// Load the module.
const createOrder = require('create-order')

// The Express app.
const app = express()

// Setup the router.
app.use(createOrder.router({
  // The name of the application.
  app: 'Foo Bar',

  // Stripe configuration options.
  stripe: {
    // Stripe API key.
    key: 'STRIPE_API_KEY',

    // Specify if charges should be captured.
    // Note: When value is `false` charges will be authorized only.
    capture: true
  },

  // Send confirmation emails after payment.
  // Note: requires `pug-mailer` module to be initialized.
  //       More details: https://www.npmjs.com/package/pug-mailer
  mail: {
    // Confirmation emails will be sent from this email.
    from: 'foo@bar.com'
  },

  // Delivery information.
  delivery: {

    // How long it usually takes to deliver the product.
    days: 0
  },

  // Provide product details.
  product: (req, res, quantity) => {
    return {
      // Product ID.
      id: '1234567',

      // Name of the product.
      name: 'Foo Bar Product',

      // Image of the product (Should be 150x150 pixels).
      image: 'https://lorempixel.com/150/150',

      // Specify meta information.
      // Note: Meta information is not required.
      meta: [
        {
          name: 'color',
          label: 'Color',
          value: 'red'
        },
        {
          name: 'size',
          label: 'Size',
          value: 'XXL'
        }
        // ...
      ],

      // Quantity.
      quantity: quantity,

      // Currency to show.
      currency: 'USD',

      // Unit price to show.
      unit: 19.99,

      // Gross price to show.
      gross: 19.99 * quantity,

      // Shipping price to show.
      shipping: 10,

      // Total to pay to show.
      total: 19.99 * quantity + 10,

      // In this currency client will be charged.
      // Note: Defaults to `currency`.
      baseCurrency: 'USD',

      // Unit price which will be saved to the databse.
      // Note: Defaults to `unit`.
      baseUnit: 19.99,

      // Gross price which will be saved to the databse.
      // Note: Defaults to `gross`.
      baseGross: 19.99 * quantity,

      // Shipping price which will be saved to the databse.
      // Note: Defaults to `shipping`.
      baseShipping: 10,

      // Total price which will be saved to the databse.
      // Note: Defaults to `total`.
      // Important: Client will be charged for this amount.
      baseTotal: 19.99 * quantity + 10
    }
  }
}))

Routes

After setup the following routes become available:

  • http://localhost:3000/checkout - The checkout page.
  • http://localhost:3000/thank-you/:id - Client is redirected here after a successfuly payment.
  • http://localhost:3000/order/:id - Clients can view their orders on this page.

Database

Currently all orders are saved in a mongodb collection using the mongoose module based on the order-model model.

Supported Payment Gateways

Currently we support only the following payment gateways:

We may add more payment gateways in future versions.

Supported Languages

Currently we support only the following languages:

  • English (en)

We may add more languages in future versions.

Payment Confirmation Emails

Payment confirmation emails are sent using pug-mailer module.

License

The MIT License (MIT)

Copyright (c) 2017 Ion Suman sumanion122@gmail.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

FAQs

Package last updated on 07 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts