Download the PHP package zenopay/zenopay-php without Composer
On this page you can find all versions of the php package zenopay/zenopay-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zenopay/zenopay-php
More information about zenopay/zenopay-php
Files in zenopay/zenopay-php
Package zenopay-php
Short Description A PHP package for ZenoPay payment processing.
License MIT
Informations about the package zenopay-php
ZenoPay Order Creation and Status Check Scripts
This repository contains PHP scripts for interacting with the ZenoPay API. The scripts demonstrate how to create an order and check the status of an order.
Table of Contents
- Order Creation Script
- Overview
- Script Components
- API Endpoint
- Order Data
- cURL Configuration
- Error Logging Function
- Error Handling
- Example Usage
- Notes
- Order Status Check Script
- Overview
- Script Components
- API Endpoint
- Post Data
- cURL Configuration
- Error Handling
- Example Usage
- Notes
Order Creation Script
Overview
This script sends a POST request to the ZenoPay API to create an order. It includes a basic error logging function to capture any issues during the request.
Script Components
API Endpoint
-
URL:
https://api.zeno.africa
This is the endpoint for creating an order.
Order Data
The following data is sent in the POST request:
create_order
(integer): Set to1
to initiate order creation.buyer_email
(string): Customer's email address.buyer_name
(string): Customer's full name.buyer_phone
(string): Customer's phone number.amount
(integer): The amount to be paid (in smallest currency unit, e.g., cents).account_id
(string): Your unique account ID for authentication.api_key
(string): Your API key for authentication.secret_key
(string): Your secret key for authentication.
cURL Configuration
Request Format
To initiate a payment transaction, send a POST request to the API with a JSON payload that includes the following parameters:
Parameter | Type | Description | Example |
---|---|---|---|
buyer_name |
string | Full name of the buyer | "John Doe" |
buyer_phone |
string | Phone number of the buyer | "255712345678" |
buyer_email |
string | Email address of the buyer | "[email protected]" |
amount |
float | Amount to be paid by the buyer in the transaction | 1500.00 |
account_id |
string | Unique account identifier for the transaction | "acc_12345xyz" |
api_key |
string | Your API key for authentication. | "api_key" |
secret_key |
string | Your secret key for authentication. | "secret_key" |
The script uses cURL to make the POST request:
Error Logging Function
Logs errors to a file:
Error Handling
To enhance error handling:
-
Check cURL Errors:
- Check HTTP Status Code:
Example Usage
- Update Order Data: Replace placeholder values with actual information.
- Save the Script: Save the file as
create_order.php
or another preferred filename. - Run the Script: Execute it via command line or web server.
Notes
- Ensure that
error_log.txt
is writable by the script. - Handle sensitive information such as API keys and secret keys securely.
Order Status Check Script
Overview
This script checks the status of an order by sending a POST request to the ZenoPay API endpoint for order status.
Script Components
API Endpoint
-
URL:
https://api.zeno.africa/order-status
This is the endpoint for checking the status of an order.
Post Data
The following data is sent in the POST request:
check_status
(integer): Set to1
to request the status.order_id
(string): The ID of the order whose status you want to check.api_key
(string): Your API key for authentication.secret_key
(string): Your secret key for authentication.
cURL Configuration
The script uses cURL to perform the POST request:
Error Handling
-
Check cURL Errors:
-
Handle Response: Decode and format the JSON response based on the status:
Webhook Handling
After a payment is processed, ZenoPay may send a webhook to notify you about the status of the transaction. You can use the following PHP code to handle the webhook and log the incoming data for further processing or debugging.
Webhook PHP Example
How the Webhook Works:
- Receiving Webhook Data: This script listens for incoming POST requests (which ZenoPay sends for webhooks
) and reads the raw data from the request body using file_get_contents('php://input')
.
- Logging Webhook Data: The webhook data is logged to a file (
weblogs.txt
) along with a timestamp for reference. This log will help you debug and track transaction statuses or other data sent via the webhook.
Example Usage
- Update Post Data: Replace placeholder values with actual data.
- Save the Script: Save the file as
check_order_status.php
or another preferred filename. - Run the Script: Execute it via command line or web server.
Notes
- Ensure that
error_log.txt
is writable if you are using error logging. - Secure sensitive information such as API keys and secret keys.
Feel free to modify or expand this README as needed for your specific requirements.