Download the PHP package core45/laravel-tubapay without Composer
On this page you can find all versions of the php package core45/laravel-tubapay. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-tubapay
Laravel TubaPay
A Laravel integration for TubaPay BNPL (Buy Now, Pay Later) payment solutions.
Sits on top of core45/tubapay-php and gives you:
- A webhook endpoint with idempotency and optional persistence
- Checkout helpers (installment/consents resolution + Blade components)
- A selection store so the customer's choice survives between HTTP requests
- A transaction creation service that writes a local tracking row
- Optional default listeners wired to any order model implementing a small contract
- Blade components for status badges, top bar, popup, installment selector, and consent checkboxes
- Translations in 6 languages (en, pl, de, es, fr, it)
Table of Contents
- Requirements
- Installation
- Configuration
- How TubaPay Works (Flow Overview)
- End-to-End Integration Guide
- Step 1 — Show TubaPay on checkout
- Step 2 — Validate selection before creating the order
- Step 3 — Persist the selection, then create the transaction
- Step 4 — Handle webhooks
- Livewire Integration
- Webhook Events Reference
- Optional Default Listeners
- Blade Components
- Console Commands & Scheduling
- Transaction Tracking Model
- Agreement Statuses
- Configuration Options
- Translations
- Testing
- License
Requirements
- PHP 8.2 or higher (PHP 8.3+ for Laravel 13)
- Laravel 10.x, 11.x, 12.x, or 13.x
core45/tubapay-php^0.2.1- TubaPay merchant account (sandbox credentials for
test, production credentials forproduction)
Installation
The service provider is auto-discovered. Publish the config and migrations:
Migrations create:
| Table | Purpose |
|---|---|
tubapay_transactions |
Local tracking row per transaction — status, amount, customer, installments, consents |
tubapay_checkout_selections |
Short-lived store for the customer's installment/consent choices, keyed by your order reference |
tubapay_webhook_events |
Idempotency log — deduplicates webhook deliveries by commandType:commandRef |
tubapay_payments |
Merchant payout notifications (optional, populated by persistence layer) |
tubapay_recurring_requests |
Recurring order requests from TubaPay (optional) |
Configuration
Minimum .env:
Additional options (see config/tubapay.php for the full list):
How TubaPay Works (Flow Overview)
Two important moments to distinguish:
- Credit accepted (
TransactionStatusChangedwithisAccepted()) — TubaPay has approved the customer's financing application. At this point TubaPay has assumed the credit risk and the merchant can fulfill the order. This is the right moment to mark the order paid. - Merchant payment (
PaymentReceived) — TubaPay has wired the funds to your merchant account. This happens later, on TubaPay's payout schedule. It's informational — your order is already paid from the customer's perspective when the credit was accepted.
End-to-End Integration Guide
This section walks through a typical checkout integration. If you use Livewire, jump to Livewire Integration for adjustments to the Blade components.
Step 1 — Show TubaPay on checkout
Resolve installment and consent options for the current cart total and render the Blade components.
In the Blade view:
Cache the CheckoutOptions response per cart total — the SDK hits the TubaPay API each time you call forAmount().
Step 2 — Validate selection before creating the order
Before persisting the order, reject submissions that chose TubaPay with an incomplete selection:
Step 3 — Persist the selection, then create the transaction
After the order exists in your database, write a CheckoutSelection keyed by a reference you control — typically the order's UUID. Then create the TubaPay transaction, passing the selection explicitly to avoid the SDK silently falling back to defaults with empty consents.
Why pass
selectionexplicitly? If you omit theselectionargument,TubaPayCheckoutServicewill look for a stored selection byexternalRefand — if none is found — fall back to a defaultCheckoutSelectionwith no accepted consents, which will likely be rejected by TubaPay or create an agreement the customer hasn't actually consented to. Always pass the explicit selection you validated in Step 2.
Step 4 — Handle webhooks
The package registers a webhook route at POST /webhooks/tubapay (configurable via TUBAPAY_WEBHOOK_PATH). Signature verification and idempotency happen automatically. You subscribe to the dispatched events in your own listeners.
Register them in AppServiceProvider::boot() (Laravel 11/12 style) or in an EventServiceProvider:
Example "mark order paid on credit acceptance" listener:
Example rejection listener:
Livewire Integration
The shipped Blade components use plain <input> tags bound to a name attribute. If you bind them to a Livewire component with wire:model / wire:model.live, you need to publish and patch the views so the binding lands on the <input> element rather than the wrapping <div>:
Then edit resources/views/vendor/tubapay/components/installment-selector.blade.php:
Apply the same pattern to consent-checkboxes.blade.php. Usage:
Be careful with
--force. Re-publishing views with--forcewill overwrite your Livewire-bound copies. Commit the overrides to your repo and avoid--forceafter that.
Webhook Events Reference
| Event | TubaPay command | When it fires | Typical action |
|---|---|---|---|
TransactionStatusChanged |
TRANSACTION_STATUS_CHANGED |
Credit application transitions through draft → registered → signed → accepted/rejected | Mark order paid on isAccepted(); cancel on isRejected() |
PaymentReceived |
TRANSACTION_MERCHANT_PAYMENT |
TubaPay has paid out funds to the merchant | Log for bookkeeping; do not re-mark the order paid (it already is) |
RecurringOrderRequested |
CUSTOMER_RECURRING_ORDER_REQUEST |
Customer's recurring billing cycle generates a new order | Create the next local order against the saved agreement |
InvoiceRequested |
(legacy alias of above) | Same as RecurringOrderRequested |
Prefer RecurringOrderRequested for new code |
WebhookReceived |
any | Every incoming webhook (raw) | Debugging / custom routing |
Common methods on TransactionStatusChanged:
Webhook idempotency is handled by the tubapay_webhook_events table — duplicate deliveries with the same commandType:commandRef are acknowledged (HTTP 200) but not re-dispatched.
Optional Default Listeners
If you'd rather not write your own listeners and your order model can implement a small contract, the package can auto-register default listeners for accepted/rejected/payment/recurring events.
1. Implement the resolver:
2. Implement TubaPayTransactable on the order model:
3. Bind the resolver and enable auto-listeners:
Blade Components
Fetching the top bar content:
Console Commands & Scheduling
Schedule the prune task daily in routes/console.php:
Transaction Tracking Model
The row is created with currency = 'PLN' (the TubaPay platform's native currency) and status = draft. If your order is denominated in another currency (e.g. EUR), update the tracking row's currency after createTransaction() returns:
Agreement Statuses
| Status | Description | isPending() |
isSuccessful() |
isFailed() |
|---|---|---|---|---|
draft |
Initial state | ✓ | ||
registered |
Application submitted | ✓ | ||
signed |
Documents signed | ✓ | ||
accepted |
Approved — customer is financed, merchant can fulfill | ✓ | ||
rejected |
Application rejected | ✓ | ||
canceled |
Canceled by customer | ✓ | ||
terminated |
Terminated by system | ✓ | ||
withdrew |
Customer withdrew | ✓ | ||
repaid |
Fully repaid | ✓ | ||
closed |
Agreement closed | ✓ |
Configuration Options
See config/tubapay.php for the full list:
- Webhook route path and signature verification
- Webhook idempotency lease and retry settings
- Token cache store and TTL
- Transaction tracking toggle
- Checkout default installments and selection TTL
- Optional UI JSON route registration
- Optional auto-listener registration
- Optional status map (
accepted→paid,rejected→failed, etc.) - Integration metadata sent to TubaPay (source, app version)
- Top bar / popup / content cache TTL
- Debug logging flags
Use the status mapper from your listeners:
Optional UI Helper Routes
Enable JSON endpoints for client-side checkouts (SPA, fetch-based carts):
| Method | Path | Route name | Purpose |
|---|---|---|---|
| GET | /tubapay/installments?amount=1000 |
tubapay.ui.installments |
Installments + consents + UI texts for amount |
| GET | /tubapay/content/top-bar |
tubapay.ui.content.top-bar |
Top bar HTML content |
| GET | /tubapay/content/popup |
tubapay.ui.content.popup |
Popup HTML content |
| GET | /tubapay/texts |
tubapay.ui.texts |
Checkout UI text labels |
Content responses are cached for TUBAPAY_UI_CACHE_TTL seconds.
Translations
Translations ship in en, pl, de, es, fr, it. Publish to customize:
Testing
End-to-end transaction creation is covered manually against the TubaPay sandbox because TubaPayCheckoutService is final and TubaPay client methods are not easily mocked. For unit tests, stub the TubaPay client binding:
License
MIT License. See LICENSE file for details.
All versions of laravel-tubapay with dependencies
core45/tubapay-php Version ^0.2.1
illuminate/cache Version ^10.0|^11.0|^12.0|^13.0
illuminate/console Version ^10.0|^11.0|^12.0|^13.0
illuminate/contracts Version ^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^10.0|^11.0|^12.0|^13.0
illuminate/events Version ^10.0|^11.0|^12.0|^13.0
illuminate/http Version ^10.0|^11.0|^12.0|^13.0
illuminate/routing Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.0