Search by

velyopay / velyopay-laravel

appfolder

Accept cards, Apple Pay, Google Pay and crypto in Laravel with VelyoPay, and get paid in USDC on Polygon.

v1.0.0 2026-12-05 23:03 UTC

This package is auto-updated.

Last update: 2026-12-06 00:34:08 UTC


README

Accept cards, Apple Pay, Google Pay and crypto in your Laravel app with VelyoPay, and get paid in USDC on Polygon, straight to your own wallet.

  • No KYC: your merchant account is active as soon as you sign up.
  • Hosted checkout in 7 languages: card data never touches your server.
  • Signed webhooks turned into Laravel events (PaymentPaid, PaymentFailed, PaymentExpired).
  • Every webhook is checked (HMAC-SHA256) and the payment is re-read from the API before your code runs.
  • Test mode with simulated payments.

Requires PHP 8.2+ and Laravel 11, 12 or 13.

Installation

composer require velyopay/velyopay-laravel

Add your keys to .env (dashboard → API keys, and Settings → Webhook for the secret):

VELYOPAY_API_KEY=vp_test_xxxxxxxxxxxxxxxxxxxxxxxx
VELYOPAY_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxxxxxxxxxxxxx

Start with a vp_test_ key: the checkout then offers Simulate a successful payment and Simulate a failed payment, and no real money moves. Switch to your vp_live_ key when you are ready.

Optionally publish the config file:

php artisan vendor:publish --tag=velyopay-config

Accept a payment

use VelyoPay\Laravel\Facades\VelyoPay;

$payment = VelyoPay::createPayment([
    'amount' => 49.90,
    'currency' => 'EUR',                 // USD, EUR, GBP, CAD, AUD, CHF or MAD
    'reference' => 'ORDER-1042',
    'customer_email' => 'buyer@example.com',
    'return_url' => route('orders.thanks', $order),
    'cancel_url' => route('cart'),
    'metadata' => ['order_id' => (string) $order->id],
]);

return redirect()->away($payment->checkoutUrl);

The customer pays on checkout.velyopay.com by card, Apple Pay, Google Pay, PayPal, Revolut or crypto, then comes back to your return_url.

Fulfil the order: listen to PaymentPaid

The package registers POST /velyopay/webhook. Set it as your webhook URL in the dashboard, or pass webhook_url when you create a payment:

'webhook_url' => route('velyopay.webhook'),

Then write a listener. Laravel discovers it automatically:

namespace App\Listeners;

use App\Models\Order;
use VelyoPay\Laravel\Events\PaymentPaid;

class MarkOrderAsPaid
{
    public function handle(PaymentPaid $event): void
    {
        $payment = $event->payment;
        $order = Order::find($payment->metadata['order_id'] ?? null);

        if (! $order || $order->isPaid()) {
            return; // webhooks can be delivered more than once
        }

        if ($payment->matches($order->total, $order->currency)) {
            $order->markAsPaid($payment->id);
        }
    }
}

Before PaymentPaid is dispatched, the package:

  1. checks the VelyoPay-Signature header with your webhook secret (and rejects events older than 5 minutes);
  2. reads the payment again from the API with your key, so a forged or replayed request can never mark an order as paid;
  3. dispatches the event only if the verified status matches (paid for PaymentPaid).

The redirect to your return_url is not proof of payment. Only trust the webhook, or VelyoPay::payment($id)->isPaid().

The route has no session or CSRF middleware, so nothing else is needed. To use your own route instead, set VELYOPAY_WEBHOOK_PATH=null and add the VerifyWebhookSignature middleware to it.

A complete example (controller, listener, routes) is in examples/.

Other calls

$payment = VelyoPay::payment('pay_8f3k2m9x1q7w4e6r5t0y2u8i');

$payment->isPaid();        // also isPending(), isFailed(), isExpired()
$payment->amount;          // "49.90"
$payment->currency;        // "EUR"
$payment->livemode;        // false for test payments
$payment->txidOut;         // payout transaction hash
$payment->valueCoin;       // USDC sent to your wallet
$payment->paidAt;          // CarbonImmutable

$latest = VelyoPay::payments(limit: 20); // Collection of Payment

// Platforms: one key per merchant
VelyoPay::withKey($merchant->velyopay_key)->createPayment([...]);

API errors throw VelyoPay\Laravel\Exceptions\VelyoPayException with status, type and errors:

try {
    VelyoPay::createPayment(['amount' => 0.5, 'currency' => 'EUR']);
} catch (VelyoPayException $e) {
    $e->getMessage(); // "The amount field must be at least 1."
    $e->status;       // 422
}

Verify a webhook yourself

use VelyoPay\Laravel\Webhook;

$event = Webhook::constructEvent(
    $request->getContent(),
    $request->header('VelyoPay-Signature'),
    config('velyopay.webhook_secret'),
); // throws InvalidSignatureException

Testing your app

The client uses Laravel's HTTP client, so Http::fake() works:

Http::fake(['api.velyopay.com/*' => Http::response(['id' => 'pay_123456789012345678901234', 'status' => 'pending', 'amount' => '10.00', 'currency' => 'EUR', 'checkout_url' => 'https://checkout.velyopay.com/pay/pay_123456789012345678901234'], 201)]);

To send a signed webhook in a test, sign the body with Webhook::sign($body, $secret).

Fees

One fee per successful payment, no monthly or setup fee. See velyopay.com/faq.

Links

License

MIT