Skip to main content

Verify Payment

Verify the status and details of a payment transaction using its unique reference. This endpoint should be called after payment completion to confirm the transaction status.
Always verify payments! Never rely solely on frontend callbacks or webhook notifications. Always verify transaction status on your backend for security.

Endpoint

GET /transaction/verify/{reference}

Path Parameters

reference
string
required
The unique transaction reference returned when the payment was initialized

Headers

NameTypeRequiredDescription
AuthorizationstringRequiredBearer token with your secret API key
Content-TypestringRequiredMust be application/json

Example Request

curl -X GET https://api.payvessel.com/transaction/verify/TXN_2024_001 \
  -H "Authorization: Bearer sk_test_abc123..." \
  -H "Content-Type: application/json"

Response

status
string
Request status indicator - "success" or "error"
message
string
Human-readable message describing the result
data
object
Transaction verification data

Example Response

{
  "status": "success",
  "message": "Transaction verification successful",
  "data": {
    "id": 123456789,
    "reference": "TXN_2024_001",
    "amount": 50000,
    "currency": "NGN",
    "status": "success",
    "gateway_response": "Successful",
    "paid_at": "2024-01-15T14:35:22Z",
    "created_at": "2024-01-15T14:30:00Z",
    "channel": "card",
    "fees": 750,
    "customer": {
      "id": 12345,
      "email": "[email protected]",
      "first_name": "John",
      "last_name": "Doe",
      "phone": "+2348012345678"
    },
    "authorization": {
      "authorization_code": "AUTH_xyz789abc",
      "bin": "408408",
      "last4": "4081",
      "exp_month": "12",
      "exp_year": "2027",
      "channel": "card",
      "card_type": "visa",
      "bank": "TEST BANK",
      "country_code": "NG",
      "brand": "visa",
      "reusable": true
    },
    "metadata": {
      "custom_fields": [
        {
          "display_name": "Order ID",
          "variable_name": "order_id",
          "value": "ORD_001"
        }
      ]
    },
    "log": {
      "start_time": 1705329000,
      "time_spent": 322,
      "attempts": 1,
      "errors": 0,
      "success": true,
      "mobile": false,
      "input": [],
      "history": [
        {
          "type": "action",
          "message": "Attempted to pay with card",
          "time": 15
        },
        {
          "type": "success",
          "message": "Successfully paid with card",
          "time": 322
        }
      ]
    }
  }
}

Transaction Status Guide

Understanding transaction statuses is crucial for proper payment handling:
Payment Completed SuccessfullyThe payment has been processed and funds have been collected. You can proceed with order fulfillment.
  • paid_at timestamp will be populated
  • authorization object will contain card details (for card payments)
  • Funds will be settled to your account based on your settlement schedule
Payment FailedThe payment attempt was unsuccessful. Common reasons include:
  • Insufficient funds
  • Invalid card details
  • Bank decline
  • Network timeout
  • paid_at will be null
  • authorization will be null
  • Check gateway_response for specific failure reason
Payment ProcessingThe payment is still being processed. This is common with:
  • Bank transfers
  • USSD payments
  • Some mobile money transactions
  • Keep checking status periodically
  • You’ll receive a webhook when status changes
Payment Started but Not CompletedCustomer initiated payment but didn’t complete it:
  • Closed browser before entering details
  • Session timeout
  • Customer changed mind
  • No funds were collected
  • Payment can potentially still be completed if session is still valid
Payment CancelledPayment was explicitly cancelled by customer or system:
  • Customer clicked cancel
  • Multiple failed attempts triggered cancellation
  • System timeout
  • Payment cannot be completed
  • Customer needs to initiate a new payment

Best Practices

Always Verify

Verify every transaction on your backend before order fulfillment, even after webhook notifications

Handle All Status

Implement logic for all possible transaction statuses in your application

Store Authorization

Save authorization codes for successful card payments to enable future recurring charges

Monitor Logs

Use transaction logs to debug payment issues and improve user experience

Common Integration Patterns

// After customer returns from payment
app.get('/payment/callback', async (req, res) => {
  const reference = req.query.reference;
  
  try {
    const verification = await payvessel.transaction.verify(reference);
    
    if (verification.data.status === 'success') {
      // Payment successful - fulfill order
      await fulfillOrder(verification.data);
      res.redirect('/order/success');
    } else {
      // Payment failed - show error
      res.redirect('/order/failed');
    }
  } catch (error) {
    // Handle verification error
    res.redirect('/order/error');
  }
});