bind(Client::class, fn() => new Client(config('opensalestax.url')))).OpenSalesTax::calculate()) for cleaner syntax.Client into controllers/services via constructor injection.TaxCalculated) after calculations for downstream processing (e.g., tax reporting).^0.1 + engine v0.20+). Mismatches risk breaking changes.Money packages like league/money). Example:
$amount = (string) ($cents / 100); // "100.00" from 10000 cents
round() or bcmath may be needed to avoid precision loss.OpenSalesTaxException subclasses (e.g., OpenSalesTaxApiException).OpenSalesTaxNetworkException) may need retries (e.g., Laravel’s retry helper or a queue job).v0.59.0+. Must check $client->capabilities()->features->shippingFirstClass at runtime.calculate() calls remain unchanged, but new code must handle null shipping responses.Money class be needed to bridge the gap?OpenSalesTaxNetworkException.)v0.59.0+ is deployed.CalculateResponse in a database.)Client as a singleton or context-bound instance.config/opensalestax.php:
'engine' => [
'url' => env('OPENSALESTAX_URL', 'http://localhost:8080'),
'api_key' => env('OPENSALESTAX_API_KEY'),
'timeout' => 10.0,
],
TaxCalculated events after calculations for analytics/reporting.league/money or moneyphp/money to handle decimal strings. Example:
use Money\Money;
$money = Money::USD(10000); // 100.00 USD
$amount = (string) $money->getAmount() / 100;
Client::calculate():
$shipping = new OpenSalesTax\Shipping(
amount: '12.50',
method: 'standard',
separatelyStated: true
);
$result = $client->calculate($address, $lineItems, $shipping);
/api/tax-calculate).Client in Laravel’s service container.OpenSalesTaxException.guzzlehttp/psr7 if not using Laravel’s client).calculate() for line items.OpenSalesTaxException.v0.59.0+ is used.composer.json and deployment manifests.0.1.x → 0.2.x) are backward-compatible. Major updates may require testing.composer require ejosterberg/opensalestax:^0.1 to auto-update patch/minor versions.docker logs opensalestax-engine) for failures.OpenSalesTaxValidationException for bad inputs (e.g., invalid ZIPs).How can I help you explore Laravel packages today?