bubb/installments
Composer 安装命令:
composer require bubb/installments
包简介
Installments helper
关键字:
README 文档
README
installment is an official library created by developers of the BUBB.STORE platform that handles the calculation of installments.
System Requirements
It requires the following components to work correctly.
- PHP >= 5.4
- Composer
Composer Setup
In your composer.json, include the following:
{ "require": { "bubb/installments": "master" } } Usage
Example #1
To calculate possible installments for an order, in this case:
Order total price: 200 BRL, Order max. installments: 3
$installment = new Installment; // Required. $installment->setAmount(200); // Required. $installment->setTaxes([ // installment 1: no tax, no discount. ['installment' => 1, 'percent_discount' => 0, 'tax' => 0], // installment 2: no tax, no discount. ['installment' => 2, 'percent_discount' => 0, 'tax' => 0], // installment 3: no tax, no discount. ['installment' => 3, 'percent_discount' => 0, 'tax' => 0], ]); exit(var_dump($installment->get()));
Its output would be:
{ "max_installment":3, "max_installment_value":66.67, "amount":200, "text":"3x de R$ 66,67 sem juros", "text_with_tax":"3x de R$ 66,67", "text_discount_percent":null, "text_discount":null, "installments":[ { "amount":200, "amount_formated":"R$ 200,00", "base_value":200, "tax":0, "tax_value":0, "discount_percent":0, "discount_value":0, "discount_value_formated":"R$ 0,00", "installment":1, "installment_value":200, "installment_value_formated":"R$ 200,00", "text":"1x de R$ 200,00 sem juros", "text_with_tax":"1x de R$ 200,00", "text_discount_percent":null, "text_discount":null }, { "amount":200, "amount_formated":"R$ 200,00", "base_value":200, "tax":0, "tax_value":0, "discount_percent":0, "discount_value":0, "discount_value_formated":"R$ 0,00", "installment":2, "installment_value":100, "installment_value_formated":"R$ 100,00", "text":"2x de R$ 100,00 sem juros", "text_with_tax":"2x de R$ 100,00", "text_discount_percent":null, "text_discount":null }, { "amount":200, "amount_formated":"R$ 200,00", "base_value":200, "tax":0, "tax_value":0, "discount_percent":0, "discount_value":0, "discount_value_formated":"R$ 0,00", "installment":3, "installment_value":66.67, "installment_value_formated":"R$ 66,67", "text":"3x de R$ 66,67 sem juros", "text_with_tax":"3x de R$ 66,67", "text_discount_percent":null, "text_discount":null } ] } Example #2
To calculate possible installments for an order, in this case:
Order total price: 677 BRL, Order max. installments: 12 (up to 6, without taxes) Order min. installment value: 20 BRL
$installment = new Installment; // Required. $installment->setAmount(200); // Required. $installment->setTaxes([ // installment 1: no tax, 10% discount. ['installment' => 1, 'percent_discount' => 10, 'tax' => 0], // Installment 2: no tax, no discount. ['installment' => 2, 'percent_discount' => 0, 'tax' => 0], // Installment 3: no tax, no discount. ['installment' => 3, 'percent_discount' => 0, 'tax' => 0], // Installment 4: no tax, no discount. ['installment' => 4, 'percent_discount' => 0, 'tax' => 0], // Installment 5: no tax, no discount. ['installment' => 5, 'percent_discount' => 0, 'tax' => 0], // Installment 6: no tax, no discount. ['installment' => 6, 'percent_discount' => 0, 'tax' => 0], // Installment 7: tax 1.99% month, no discount. ['installment' => 7, 'percent_discount' => 0, 'tax' => 1.99], // Installment 8: tax 1.99% month, no discount. ['installment' => 8, 'percent_discount' => 0, 'tax' => 1.99], // Installment 9: tax 1.99% month, no discount. ['installment' => 9, 'percent_discount' => 0, 'tax' => 1.99], // Installment 10: tax 1.99% month, no discount. ['installment' => 10, 'percent_discount' => 0, 'tax' => 1.99], // Installment 11: no tax, no discount. ['installment' => 11, 'percent_discount' => 0, 'tax' => 1.99], // Installment 12: tax 1.99% month, no discount. ['installment' => 12, 'percent_discount' => 0, 'tax' => 1.99] ]); $installment->setMinInstallmentValue(20); $installment->setMaxInstallmentsWithoutTax(6); exit(var_dump($installment->get()));
Its output would be:
{ // Max installments is 11 because the library popped the last installment for it had a value lower than the min. installment value (20 BRL). "max_installment":11, "max_installment_value":20.06, "amount":220.71, "text":"11x de R$ 20,06 com juros", "text_with_tax":"11x de R$ 20,06", "text_discount_percent":"10% de desconto \u00e0 vista no cart\u00e3o", "text_discount":"R$ 180,00 \u00e0 vista no cart\u00e3o", "installments":[ { // Discounted amount for the first installment. "amount":180, "amount_formated":"R$ 180,00", "base_value":200, "tax":0, "tax_value":-20, "discount_percent":10, "discount_value":20, "discount_value_formated":"R$ 20,00", "installment":1, "installment_value":180, "installment_value_formated":"R$ 180,00", "text":"1x de R$ 180,00 sem juros", "text_with_tax":"1x de R$ 180,00", "text_discount_percent":"10% de desconto \u00e0 vista no cart\u00e3o", "text_discount":"R$ 180,00 \u00e0 vista no cart\u00e3o" }, { "amount":200, "amount_formated":"R$ 200,00", "base_value":200, "tax":0, "tax_value":0, "discount_percent":0, "discount_value":0, "discount_value_formated":"R$ 0,00", "installment":2, "installment_value":100, "installment_value_formated":"R$ 100,00", "text":"2x de R$ 100,00 sem juros", "text_with_tax":"2x de R$ 100,00", "text_discount_percent":null, "text_discount":null }, { "amount":200, "amount_formated":"R$ 200,00", "base_value":200, "tax":0, "tax_value":0, "discount_percent":0, "discount_value":0, "discount_value_formated":"R$ 0,00", "installment":3, "installment_value":66.67, "installment_value_formated":"R$ 66,67", "text":"3x de R$ 66,67 sem juros", "text_with_tax":"3x de R$ 66,67", "text_discount_percent":null, "text_discount":null }, { "amount":200, "amount_formated":"R$ 200,00", "base_value":200, "tax":0, "tax_value":0, "discount_percent":0, "discount_value":0, "discount_value_formated":"R$ 0,00", "installment":4, "installment_value":50, "installment_value_formated":"R$ 50,00", "text":"4x de R$ 50,00 sem juros", "text_with_tax":"4x de R$ 50,00", "text_discount_percent":null, "text_discount":null }, { "amount":200, "amount_formated":"R$ 200,00", "base_value":200, "tax":0, "tax_value":0, "discount_percent":0, "discount_value":0, "discount_value_formated":"R$ 0,00", "installment":5, "installment_value":40, "installment_value_formated":"R$ 40,00", "text":"5x de R$ 40,00 sem juros", "text_with_tax":"5x de R$ 40,00", "text_discount_percent":null, "text_discount":null }, { "amount":200, "amount_formated":"R$ 200,00", "base_value":200, "tax":0, "tax_value":0, "discount_percent":0, "discount_value":0, "discount_value_formated":"R$ 0,00", "installment":6, "installment_value":33.33, "installment_value_formated":"R$ 33,33", "text":"6x de R$ 33,33 sem juros", "text_with_tax":"6x de R$ 33,33", "text_discount_percent":null, "text_discount":null }, { // Amount with taxes. "amount":203.98, "amount_formated":"R$ 203,98", "base_value":200, "tax":1.99, "tax_value":3.98, "discount_percent":0, "discount_value":-3.98, "discount_value_formated":"R$ -3,98", "installment":7, "installment_value":29.14, "installment_value_formated":"R$ 29,14", "text":"7x de R$ 29,14 com juros", "text_with_tax":"7x de R$ 29,14", "text_discount_percent":null, "text_discount":null }, { // Amount with taxes. "amount":208.04, "amount_formated":"R$ 208,04", "base_value":200, "tax":1.99, "tax_value":8.039202, "discount_percent":0, "discount_value":-8.04, "discount_value_formated":"R$ -8,04", "installment":8, "installment_value":26, "installment_value_formated":"R$ 26,00", "text":"8x de R$ 26,00 com juros", "text_with_tax":"8x de R$ 26,00", "text_discount_percent":null, "text_discount":null }, { // Amount with taxes. "amount":212.18, "amount_formated":"R$ 212,18", "base_value":200, "tax":1.99, "tax_value":12.1791821198, "discount_percent":0, "discount_value":-12.18, "discount_value_formated":"R$ -12,18", "installment":9, "installment_value":23.58, "installment_value_formated":"R$ 23,58", "text":"9x de R$ 23,58 com juros", "text_with_tax":"9x de R$ 23,58", "text_discount_percent":null, "text_discount":null }, { // Amount with taxes. "amount":216.4, "amount_formated":"R$ 216,40", "base_value":200, "tax":1.99, "tax_value":16.401547844, "discount_percent":0, "discount_value":-16.4, "discount_value_formated":"R$ -16,40", "installment":10, "installment_value":21.64, "installment_value_formated":"R$ 21,64", "text":"10x de R$ 21,64 com juros", "text_with_tax":"10x de R$ 21,64", "text_discount_percent":null, "text_discount":null }, { // Amount with taxes. "amount":220.71, "amount_formated":"R$ 220,71", "base_value":200, "tax":1.99, "tax_value":20.7079386461, "discount_percent":0, "discount_value":-20.71, "discount_value_formated":"R$ -20,71", "installment":11, "installment_value":20.06, "installment_value_formated":"R$ 20,06", "text":"11x de R$ 20,06 com juros", "text_with_tax":"11x de R$ 20,06", "text_discount_percent":null, "text_discount":null } ] } bubb/installments 适用场景与选型建议
bubb/installments 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 98.87k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「pricing」 「installments」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bubb/installments 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bubb/installments 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bubb/installments 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Payment plugin to integrate Alma installments and pay later payments with your Sylius shop
Manage acquisition, selling & renting prices for products and services in your Laravel Application
A package provide pricing plans for Laravel.
Estimate AI API costs before making expensive calls
Framework-agnostic PHP SDK for TubaPay payment gateway (BNPL - Buy Now, Pay Later)
This extension allows to set if a product is minimalPrice and can show its price by scope and customer group.
统计信息
- 总下载量: 98.87k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 30
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04