Socket
Socket
Sign inDemoInstall

okra-billing

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

okra-billing

This is an Okra billing TypeScript Package with methods for handling billings.


Version published
Maintainers
1
Created
Source

Okra-billing package

This is an Okra billing TypeScript Package with methods for handling billings.

Usage

import {} from 'okra-billing'
// Retrieve income status, products, plan, and company information
  const usedIncome = usedProduct?.income;
  const companySelect =
    'free_calls micro_lending name billing_email sandbox_callback_token';

  const [products, plan, incomeStatus, company] = await Promise.all([
    getManyDocument({ type: { $in: billable_products } }, 'product', {
      select: 'prices type okra_lite_discount',
    }),
    getOneDocument({ owner }, 'plan', {
      populate: [
        {
          path: 'type',
          select: 'default_discount name type',
          model: 'PlanType',
        },
      ],
    }),
    usedIncome && getOneDocument({ record: recordId }, 'income', {}),
    getDocumentById(owner, 'company', { select: companySelect }),
  ]);
// call getCostAndBreadown to get the cost and breakdown of the products
  const { charge, productBreakDown } = getCostAndBreadown({
    plan,
    record,
    amountOfTrans,
    usedIncome: incomeStatus,
    products,
    company,
  });
// update the company and wallet information with the charge
  const walletUpdate = await sendToAPI(
    {
      model: 'wallet',
      query: { currency, owner },
      update: { $inc: { amount: -charge } },
      options: { new: true },
    },
    'db/update-id',
  );
// Create the receipt 
  const receiptData = createReceiptObject(
    charge,
    productBreakDown,
    record,
    plan,
    amountOfTrans,
    walletUpdate,
  );
  return sendToAPI(
    { model: 'receipt', doc: receiptData, from: 'billing-service' },
    'db/save',
  );

Keywords

FAQs

Package last updated on 06 Dec 2022

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc