API Documentation

Welcome to the Crown Pay API documentation. Build powerful payment solutions with our simple and secure API.

Base URL: https://multi.crownbites.net/api/v1

Authentication

All API requests require authentication using your API keys. You have two types of keys:

Important: Never expose your secret key in client-side code or version control.

Using Your API Key

Include your secret key in the Authorization header as a Bearer token:

curl https://multi.crownbites.net/api/v1/payments/initialize \
  -H "Authorization: Bearer sk_test_your_secret_key" \
  -H "Content-Type: application/json"

Error Handling

The API uses standard HTTP status codes to indicate success or failure:

Status Code Description
200Success
201Resource created
400Bad request - Invalid parameters
401Unauthorized - Invalid API key
403Forbidden - Insufficient permissions
404Not found
500Server error

Error Response Format

{
  "status": false,
  "message": "Invalid API key",
  "errors": {
    "email": ["The email field is required."]
  }
}

Sandbox Mode

Test your integration without processing real payments using sandbox mode:

Tip: Complete KYC verification to unlock live payment processing.

Initialize Payment

Create a new payment transaction and get a checkout URL.

POST /api/v1/payments/initialize

Request Parameters

Parameter Type Required Description
amount number Required Amount to charge (minimum: 1)
currency string Required Currency code (GHS, NGN, USD, EUR, GBP)
email string Required Customer email address
name string Optional Customer name
phone string Optional Customer phone number
description string Optional Payment description
callback_url string Optional URL to redirect after payment
metadata object Optional Custom data (key-value pairs)

Example Request

curl -X POST https://multi.crownbites.net/api/v1/payments/initialize \
  -H "Authorization: Bearer sk_test_your_secret_key" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 100.00,
    "currency": "GHS",
    "email": "customer@example.com",
    "name": "John Doe",
    "description": "Payment for Order #1234",
    "metadata": {
      "order_id": "1234",
      "customer_id": "5678"
    }
  }'

Example Response

{
  "status": true,
  "message": "Payment initialized successfully",
  "data": {
    "reference": "CP_ABC123XYZ",
    "amount": 100.00,
    "currency": "GHS",
    "fee": 1.50,
    "authorization_url": "https://multi.crownbites.net/checkout/CP_ABC123XYZ",
    "access_code": "abc123xyz789"
  }
}

PHP Example

Error: [2] Trying to access array offset on value of type null in /home3/crownbi0/multi.crownbites.net/docs/index.php on line 314

JavaScript Example

fetch('https://multi.crownbites.net/api/v1/payments/initialize', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer sk_test_your_secret_key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    amount: 100.00,
    currency: 'GHS',
    email: 'customer@example.com',
    name: 'John Doe'
  })
})
.then(response => response.json())
.then(data => {
  if (data.status) {
    window.location.href = data.data.authorization_url;
  }
});

Verify Payment

Verify the status of a payment transaction.

GET /api/v1/verify/{reference}

Example Request

curl https://multi.crownbites.net/api/v1/verify/CP_ABC123XYZ \
  -H "Authorization: Bearer sk_test_your_secret_key"

Example Response

{
  "status": true,
  "message": "Transaction retrieved successfully",
  "data": {
    "reference": "CP_ABC123XYZ",
    "amount": 100.00,
    "currency": "GHS",
    "status": "success",
    "paid_at": "2024-01-03 12:34:56",
    "created_at": "2024-01-03 12:30:00",
    "customer": {
      "email": "customer@example.com",
      "name": "John Doe",
      "phone": "+233XXXXXXXXX"
    },
    "metadata": {
      "order_id": "1234"
    }
  }
}

Webhook Events

Receive real-time notifications about events in your account.

Available Events

Event Description
payment.successPayment completed successfully
payment.failedPayment failed
refund.completedRefund processed
transfer.completedTransfer completed
subscription.createdNew subscription created
subscription.cancelledSubscription cancelled

Webhook Payload Example

{
  "event": "payment.success",
  "data": {
    "reference": "CP_ABC123XYZ",
    "amount": 100.00,
    "currency": "GHS",
    "customer_email": "customer@example.com"
  },
  "timestamp": 1704283496
}

Webhook Security

Verify webhook authenticity using HMAC signatures.

PHP Verification Example

Invalid signature