Skip to main content

Payment Orders

Create and manage payment orders - the core transaction record in Paysera Checkout.

Payment orders represent the core transaction record in Paysera Checkout. This guide covers creating and managing orders via the API.

Overview​

A payment order contains:

  • Transaction amount and currency (in minor units)
  • Redirect URLs for success/failure/callback
  • Merchant reference (your order ID)
  • Optional metadata and merchant data
Amount Format

All amounts in the API use minor currency units (e.g., cents for EUR, pennies for GBP):

  • Request: String format (e.g., "2500" for €25.00)
  • Response: Long/integer format (e.g., 2500 for €25.00)

Endpoints​

For complete request/response schemas and examples, see the Endpoint Reference:

MethodEndpointReference
POST/merchant-order/integration/v1/ordersCreate Order
GET/merchant-order/integration/v1/orders/{id}—

Order Statuses​

StatusCodeDescription
Pending Paymentpending_paymentOrder created, awaiting payment
PaidpaidOrder fully paid
CanceledcanceledOrder was canceled*
ClosedclosedOrder closed, no further operations*

*canceled and closed statuses are defined but not yet fully implemented.

See Payment Statuses Reference for complete status documentation.

Code Examples​

<?php

function createPaymentOrder(string $accessToken, array $orderData): array
{
$ch = curl_init('https://api.paysera.com/merchant-order/integration/v1/orders');

curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $accessToken,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'project_id' => $orderData['project_id'],
'redirect_urls' => [
'success_url' => $orderData['success_url'],
'failure_url' => $orderData['failure_url'],
'callback_url' => $orderData['callback_url'],
],
'purchase' => [
'reference' => $orderData['reference'],
'amount' => (string) $orderData['amount'], // Already in minor units
'currency' => $orderData['currency'],
],
]),
]);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($httpCode !== 201) {
throw new Exception('Failed to create order: ' . $response);
}

return json_decode($response, true);
}

// Usage - amount is in minor units (cents)
$order = createPaymentOrder($accessToken, [
'project_id' => 'your-project-id',
'success_url' => 'https://your-site.paysera.net/success',
'failure_url' => 'https://your-site.paysera.net/failure',
'callback_url' => 'https://your-site.paysera.net/webhook',
'reference' => 'ORDER-12345',
'amount' => 2500, // €25.00 in cents
'currency' => 'EUR',
]);

echo "Order ID: " . $order['order_id'];
// Note: To get a payment URL, create a payment link using this order_id

Checking Order Status​

After creating an order and payment link, monitor the order status:

<?php

function checkOrderStatus(string $accessToken, string $orderId): string
{
$ch = curl_init("https://api.paysera.com/merchant-order/integration/v1/orders/{$orderId}");

curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $accessToken,
],
]);

$response = curl_exec($ch);
curl_close($ch);

$order = json_decode($response, true);

return $order['status']; // 'pending_payment', 'paid', 'canceled', or 'closed'
}

// Check if order is paid
$status = checkOrderStatus($accessToken, $orderId);
if ($status === 'paid') {
// Fulfill the order
fulfillOrder($orderId);
}

Error Responses​

Validation Error​

{
"error": "validation_error",
"message": "Invalid request parameters",
"details": [
{
"field": "purchase.amount",
"message": "Amount must be a positive whole number"
}
]
}

Invalid Project​

{
"error": "not_found",
"message": "Project not found or access denied"
}

Duplicate Reference​

{
"error": "conflict",
"message": "Order with this reference already exists"
}