4.0.3 • Published 7 years ago

payment-template-helpers v4.0.3

Weekly downloads
62
License
-
Repository
github
Last release
7 years ago

Payment Template Helpers

Build Status

Installation

Presents payment information in any JavaScript-based templating language (frontend of backend). See the Methods section below. The code is pretty simple, the main value add is the unit tests.

Usage

var paymentTemplateHelpers = require('payment-template-helpers');

You'd typically add it to the helper methods to your templating system. For example, using ractive.js:

Ractive.defaults.data.paymentTemplateHelpers = paymentTemplateHelpers

Methods

amountToDollarsCents returns a string representation of some amount of money. If the amount ends in 00, it will just show the major units. If the amount is less than or equal to 0, it will return 'FREE'. It has the following options:

  • amount Number, required. Amount of money in minor units (cents, Eurocents, etc)

percentOff returns a discounted amount, never less than 0.

  • percentageDiscount Number, required. A percentage, in whole number.
  • amount Number, required. Amount of money in minor units (cents, Eurocents, etc)

getProRatedPrice returns a discounted amount, based on a yearly rate, for a product with an expiry date

  • yearlyPrice Number, required. A yearly price in minor units (cents, Eurocents, etc)
  • expiry Date, required. Date when the product will expire.

amountOff returns a discounted amount, never less than 0.

  • percentageDiscount Number, required. Discount in minor units (cents, Eurocents, etc)
  • amount Number, required. Amount of money in minor units (cents, Eurocents, etc)

TODO

Support currencies with more than two digits for minor units.

Tests

Run mocha

4.0.3

7 years ago

4.0.2

7 years ago

4.0.1

7 years ago

4.0.0

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.2.0

9 years ago

2.1.0

9 years ago

2.0.0

9 years ago

1.0.0

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago