Download the PHP package derrickob/pricer without Composer

On this page you can find all versions of the php package derrickob/pricer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package pricer

Pricer

A PHP pricing calculator that does one thing perfectly: calculate prices with taxes, discounts, fees, and credits in the correct order.

Code Quality PHP Version Latest Version on Packagist


The Problem

You're building a store, SaaS, subscription service, or any app that charges money. You need to:

Pricer solves all this. It's a calculation engine that handles money correctly, applies components in the right order, and gives you a detailed breakdown of every step.


Installation

Requirements: PHP 8.1+, ext-bcmath, ext-intl

Laravel users: Run php artisan pricer:install after installation to publish the configuration.


Quick Start

That's it. Now let's see what Pricer can do for your business.


Table of Contents


Real-World Use Cases

1. E-commerce Checkout

Your Scenario: Customer buys a $150 item, applies a 10% discount code, adds shipping, pays sales tax, and you pass Stripe fees to them.

Why the order matters: Discount is applied first (reduces taxable amount), then shipping is added (shipping is taxable in most states), then tax is calculated on the new subtotal, and finally fees are added.

Get a detailed breakdown:

Output:


2. Restaurant Bills with Tips

Your Scenario: Dinner costs $85.50, customer pays 8% sales tax, and wants to tip 20% on the pre-tax amount (not the tax).

Alternative: Tip on post-tax amount (some customers prefer this):

Use Case: Point-of-sale systems, restaurant billing, delivery apps.


3. SaaS Subscription Billing

Your Scenario: Customer signs up for a $30/month plan on January 15th. You only charge them for the remaining 17 days until February 1st (fair billing).

First month prorated + next month regular:

Use Case: SaaS platforms, membership sites, recurring billing services.

Supported Billing Cycles:


4. Payment Processing Fees

Your Scenario: You use Stripe (2.9% + $0.30 per transaction) and want to pass fees to customers.

Use Case: E-commerce platforms, marketplaces, donation platforms.


5. Gift Cards & Store Credit

Your Scenario: $150 order, customer has a $50 gift card. Should it apply before or after tax?

Option A: Credit AFTER tax (most common)

Option B: Credit BEFORE tax (less common)

Why this matters: Tax laws vary by jurisdiction. Some require tax on the full amount before credits, others allow credits to reduce the taxable amount. Pricer gives you control.

Use Case: Retail stores, e-commerce platforms, loyalty programs.


6. Bulk/Wholesale Pricing

Your Scenario: The more units a customer buys, the cheaper each unit becomes.

Fixed-amount tiers (e.g., $5 off per unit):

Use Case: Wholesale distributors, B2B platforms, quantity-based pricing.


7. Multiple Tax Jurisdictions

Your Scenario: Customer is in a location with state + city + county taxes (all stack).

Use Case: US sales tax, Canadian GST/PST, VAT in multiple countries.


8. Tax Calculation Modes: Non-Compounding vs Compounding

Your Scenario: Different jurisdictions calculate taxes differently. Some taxes are non-compounding (all calculate on the subtotal), while others are compounding (each tax includes previous taxes in its base).

Non-Compounding Taxes (Default)

Most jurisdictions use this: all taxes calculate on the same subtotal.

Compounding Taxes (Quebec, Some Jurisdictions)

Some jurisdictions apply tax on top of previous taxes.

Mixing Tax Modes

You can mix both modes in a single calculation:

Use Case: Multi-jurisdiction tax compliance, Canadian provinces, luxury/environmental taxes.


Core Concepts

1. Amount Types

Every component (discount, tax, fee, etc.) can be percentage-based or fixed amount:

Examples:


2. Component Priorities (Order of Calculation)

Components are applied in priority order (lower number = applied first):

Component Default Priority Why This Order
Subscription 1 Adds base recurring amount first
Discount 10 Early (reduces taxable amount)
TieredPricing 12 Bulk discounts after regular discounts
Credit (BEFORE_TAX) 15 If credits reduce taxable amount
Shipping 20 Added before tax (shipping is often taxable)
Tax 30 Calculated on subtotal after discounts
Fee 40 Added after tax (e.g., credit card fees)
Credit (AFTER_TAX) 50 Most common - credits applied to final amount
Tip 60 Gratuity added last

Why this matters: Order affects the final price.

Example:

Custom Priorities:

You can override priorities if needed:


3. Precision & Rounding

Pricer uses BCMath for all calculations (no floating-point errors):

Configuration:

Why this matters: Floating-point math in PHP gives you $100.00000000001. BCMath gives you exact $100.00.


4. Money Object

Pricer includes an immutable Money value object for safe calculations:


Complete API Reference

Starting a Calculation


PriceBuilder Methods

All methods return $this for chaining (except calculate()).

Discounts

Taxes

Fees

Shipping

Subscriptions

Credits & Gift Cards

Tips

Bulk/Tiered Pricing

Conditional Logic

Calculate & Retrieve Results


Laravel Integration

1. Installation

This publishes the configuration file to config/pricer.php.


2. Configuration


3. Facade


4. Helper Functions


5. Blade Directives


Advanced Features

1. Conditional Pricing Patterns

Free shipping over threshold:

VIP customer logic:


2. Multi-Currency Support


3. Validation

Pricer includes comprehensive validation:


4. Common Patterns

Invoice Generation

Subscription Billing


Error Handling

Pricer validates inputs and throws descriptive exceptions:


Testing Your Code


Roadmap & Feature Status

Out of Scope

These features are intentionally excluded to keep Pricer focused:

Why? Pricer is a pricing calculator, not a billing platform. It calculates what to charge, your app handles when, how, and to whom.


License

MIT License. See LICENSE for details.


Support


Stop worrying about pricing logic. Use Pricer.


All versions of pricer with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-intl Version *
ext-bcmath Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package derrickob/pricer contains the following files

Loading the files please wait ...