laravel maintained by tropayment
Description
Official tropayment.com Merchant API package for Laravel
Author
Last update
2026/08/08 10:12
(dev-main)
License
Downloads
1
tropayment/laravel
Official Laravel package for tropayment.com Merchant API (v1.1).
For Laravel 10 / 11 / 12 · PHP 8.1+
Install
composer require tropayment/laravel
php artisan vendor:publish --tag=tropayment-config
Create payment (Stripe-style)
use Tropayment\Laravel\Facades\Tropayment;
$payment = Tropayment::payments()->create([
'amount' => 150.00,
'currency' => 'USDT',
'network' => 'TRON',
'order_id' => 'ORD-' . $order->id,
'title' => 'Order #' . $order->id,
'callback_url' => route('tropayment.webhook'),
'return_url' => route('checkout.return', $order), // UX only — NOT trusted
'metadata' => [
'order_id' => $order->id,
'store_currency' => 'USD',
'store_amount' => 150.00,
],
]);
return redirect($payment['payment_page_url']);
Webhook (middleware)
Route::post('/webhooks/tropayment', TropaymentWebhookController::class)
->middleware('tropayment.webhook')
->name('tropayment.webhook');
class TropaymentWebhookController extends WebhookController
{
protected function handlePaid(array $payload, Request $request): void
{
$orderId = $payload['metadata']['order_id'] ?? null;
Order::where('id', $orderId)->update(['status' => 'paid']);
}
}
return_url guard
use Tropayment\Laravel\Support\ReturnUrlGuard;
// Return controller — UX only
public function return(Request $request)
{
ReturnUrlGuard::guardQueryParams($request->query());
$ctx = ReturnUrlGuard::returnPageContext($request->query('order_id'));
return view('checkout.return', $ctx);
}
Auth (automatic)
-
Headers:
X-API-KEY,X-TIMESTAMP,X-NONCE,X-SIGNATURE,X-APP-ID -
HMAC:
timestamp + nonce + METHOD + path + body
Webhook validation
Middleware enforces: POST, Content-Type: application/json, max body 64KB, X-Signature, timestamp freshness.
API methods
| Resource | Method |
|----------|--------|
| payments()->create() | Create payment |
| payments()->retrieve() | Get payment |
| payments()->retrieveStatus() | Poll status |
| payments()->cancel() | Cancel |
| payments()->list() | List |
| balance()->retrieve() | Balance |
| networks()->list() | Networks |
Legacy facade methods (createPayment, getPayment, …) still work.
Related
-
@tropayment/core (JS shared lib — PHP mirrors same rules)