Simple PHP endpoints for integrating Selcom payment gateway with Zoho
URL: /api/create_order.php
Description: Creates a new payment order in Selcom
Request Body (JSON):
{
"order_id": "INV-12345",
"amount": 50000,
"currency": "TZS",
"buyer_email": "customer@example.com",
"buyer_name": "John Doe",
"buyer_phone": "+255712345678",
"buyer_remarks": "Payment for invoice",
"redirect_url": "https://yoursite.com/success",
"cancel_url": "https://yoursite.com/cancel",
"webhook": "https://yoursite.com/webhook"
}
Response (Success):
{
"success": true,
"message": "Order created successfully",
"data": {
"order_id": "INV-12345",
"payment_url": "https://...",
"reference": "..."
}
}
URL: /api/order_status.php?order_id=INV-12345
Description: Checks the status of a payment order
Parameters:
order_id - The order ID to checkResponse (Success):
{
"success": true,
"message": "Order status retrieved successfully",
"data": {
"order_id": "INV-12345",
"status": "COMPLETED",
"amount": 50000,
"transaction_id": "..."
}
}
config.php:
// Create payment order
orderData = {
"order_id": invoice.get("Invoice_Number"),
"amount": invoice.get("Grand_Total") * 100,
"currency": "TZS",
"buyer_email": invoice.get("Email"),
"buyer_name": invoice.get("Customer_Name"),
"buyer_phone": invoice.get("Phone")
};
response = invokeurl [
url: "https://yourdomain.com/api/create_order.php"
type: POST
parameters: orderData.toString()
headers: {"Content-Type": "application/json"}
];
info response;
// Check order status
orderId = "INV-12345";
response = invokeurl [
url: "https://yourdomain.com/api/order_status.php?order_id=" + orderId
type: GET
];
info response;
You can test these endpoints using:
curl -X POST http://localhost/zoho-backend/public/api/create_order.php \
-H "Content-Type: application/json" \
-d '{
"order_id": "TEST-001",
"amount": 1000,
"currency": "TZS",
"buyer_email": "test@example.com"
}'