Demo — sample data, nothing is saved or charged About this product on digitalhorizon.it.comReset demo
Cashpylon
app/Http/Controllers/CheckoutController.phpPHP · merchant site
// 1. Create a payment session on the gateway

public function pay(Order $order)

{

    $res = Http::withToken(config('cashpylon.live_key'))

        ->post('https://api.cashpylon.example/v1/sessions', [

            'amount'     => $order->total,   // fixed here

            'currency'   => 'EUR',

            'reference'  => $order->number,

            'return_url' => route('orders.thanks'),

        ]);

    // 2. Redirect the shopper to the hosted checkout

    return redirect($res->json('checkout_url'));

}

// 3. Confirm by webhook, after checking the signature

public function webhook(Request $r)

{

    abort_unless(Cashpylon::verify($r), 403);

    if ($r->input('event') === 'payment.succeeded') {

        Order::whereNumber($r->input('reference'))->first()

            ->markPaid($r->input('payment_id'));

    }

    return response()->noContent();

}
REST API · quickstart

Three steps from basket to confirmed payment

What the gateway does between the two calls on the left

Session createdAmount and currency set by merchantPOST
Hosted checkoutCard data never reaches the merchantHosted
3-D Secure 2Rate locked at authorizationAuthorized
Signed webhookpayment.succeeded goes to the shop200 OK
Back to the merchant's siteSuccess, pending or failed shownReturn

Payment record

SUCCEEDED
ReferenceFH-48213
Payment IDpay_8KQ2M4T7
Method · amountCard · 3DS 2 · 129.00 EUR

Run this payment in the sandbox See API keys and webhooksPlugins and SDKs

Authentication

Every request carries a secret key as a bearer token. Each merchant has a pair of test keys and a pair of live keys; the key decides which mode the request runs in. Secret keys belong on the server only.

Request headerHTTP
Authorization: Bearer sk_test_your_secret_key
Content-Type: application/json

Sandbox

Test keys talk to the sandbox. No real money moves, and the hosted checkout shows a control for choosing the result, so success, pending and failed can each be rehearsed. This demo runs the same way.

Payment sessions

POST/v1/sessions — create a session and get the address of the hosted checkout. The amount and currency are fixed here and cannot be changed by the shopper.

Create a sessionJSON
{
  "amount": 129.00,
  "currency": "EUR",
  "reference": "FH-48213",
  "return_url": "https://shop.example/orders/thanks"
}
Response · 201JSON
{
  "id": "ses_4T7K2QM8",
  "checkout_url": "https://pay.cashpylon.example/c/ses_4T7K2QM8",
  "status": "open"
}

Payments

GET/v1/payments/{id} — read one payment. GET/v1/payments — list payments with the same filters as the dashboard.

A paymentJSON
{
  "id": "pay_2H7VR5TS",
  "reference": "FH-48177",
  "amount": 75.00,
  "currency": "USD",
  "method": "ach",
  "status": "pending"
}

Refunds

POST/v1/refunds — refund a captured payment in full, or pass an amount for a partial refund.

Partial refundJSON
{
  "payment_id": "pay_8KQ2M4T7",
  "amount": 40.00,
  "reason": "Item returned"
}

POST/v1/payment-links — create a shareable link with a QR code for a fixed amount, one-time or as a subscription. Open a sample link.

Signed webhooks

The gateway posts an event to each of the merchant's endpoints when something changes. Every delivery is signed; check the signature before trusting the body, then answer with a 2xx status.

payment.succeededJSON
{
  "event": "payment.succeeded",
  "payment_id": "pay_8KQ2M4T7",
  "reference": "FH-48213",
  "amount": 129.00,
  "currency": "EUR"
}
Check the signaturePHP
$payload = file_get_contents('php://input');
$expected = hash_hmac('sha256', $payload, $signingSecret);
if (!hash_equals($expected, $signatureFromHeader)) {
    http_response_code(403);
    return;
}

Events: payment.succeeded payment.pending payment.failed refund.created dispute.opened settlement.paid

Errors

Errors come back as JSON with an HTTP status: 401 for a missing or wrong key, 422 when a field fails validation, 404 for an unknown id. The request log in the merchant dashboard keeps each call with its status and timing.

Response · 422JSON
{
  "error": "validation_failed",
  "message": "The currency field is required."
}