zenopay

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2025 License: MIT Imports: 9 Imported by: 0

README

# ZenoPay-Go

ZenoPay-Go is a Go package for integrating with the ZenoPay payment API. It provides methods to initiate payments and check payment statuses.

## Installation

To install the package, run:

```bash
go get github.com/hekimapro/zenopay-go
```

## Features

- Initiate a payment
- Check payment status

## Requirements

- Go 1.18 or later
- ZenoPay API credentials (`APIKey`, `SecretKey`, `AccountID`)

## Usage

### 1. Import the package

```go
import "github.com/hekimapro/zenopay-go"
```

### 2. Initialize ZenoPay

```go
package main

import (
	"fmt"
	"log"

	"github.com/hekimapro/zenopay-go"
)

func main() {
	// Initialize ZenoPay with API credentials
	zeno := zenopay.NewZenoPay(zenopay.ZenoPayOptionsType{
		APIKey:    "your_api_key",
		SecretKey: "your_secret_key",
		AccountID: "your_account_id",
	})

	// Example usage of Pay function
	orderID, err := zeno.Pay(zenopay.PaymentOptionsType{
		CustomerName:       "John Doe",
		CustomerEmail:      "johndoe@example.com",
		CustomerPhoneNumber: "1234567890",
		AmountToCharge:     100.50,
		CallbackURL:        "https://your-callback-url.com",
	})

	if err != nil {
		log.Fatalf("Error initiating payment: %s", err.Error())
	}
	fmt.Printf("Payment initiated successfully. Order ID: %s\n", orderID)

	// Example usage of CheckPaymentStatus function
	status, err := zeno.CheckPaymentStatus(orderID)
	if err != nil {
		log.Fatalf("Error checking payment status: %s", err.Error())
	}
	fmt.Printf("Payment status: %s\n", status)
}
```

## API Reference

### ZenoPay Options

| Field       | Type   | Description                |
|-------------|--------|----------------------------|
| `APIKey`    | string | Your ZenoPay API key       |
| `SecretKey` | string | Your ZenoPay secret key    |
| `AccountID` | string | Your ZenoPay account ID    |

### Payment Options

| Field                 | Type    | Description                            |
|-----------------------|---------|----------------------------------------|
| `CustomerName`        | string  | Name of the customer                   |
| `CustomerEmail`       | string  | Email address of the customer          |
| `CustomerPhoneNumber` | string  | Phone number of the customer           |
| `AmountToCharge`      | float64 | Payment amount                         |
| `CallbackURL`         | string  | URL to receive payment status updates  |

### Functions

#### `Pay`

- **Description:** Initiates a payment.
- **Parameters:**
  - `PaymentOptionsType`
- **Returns:**
  - `string` - Order ID
  - `error` - Error message, if any

#### `CheckPaymentStatus`

- **Description:** Checks the payment status for a given order ID.
- **Parameters:**
  - `string` - Order ID
- **Returns:**
  - `string` - Payment status
  - `error` - Error message, if any

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

---

Replace `"your_api_key"`, `"your_secret_key"`, and `"your_account_id"` with your actual ZenoPay API credentials to get started.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ZenoPay

type ZenoPay struct {
	APIKey    string
	SecretKey string
	AccountID string
	BaseURL   string
}

ZenoPay handles API interactions.

func NewZenoPay

func NewZenoPay(apiKey, secretKey, accountID string) *ZenoPay

NewZenoPay initializes a new ZenoPay instance.

func (*ZenoPay) CheckPaymentStatus

func (z *ZenoPay) CheckPaymentStatus(orderID string) (string, error)

CheckPaymentStatus checks payment status and returns the status or an error.

func (*ZenoPay) Pay

func (z *ZenoPay) Pay(options models.PaymentOptionsType) (string, error)

Pay initiates a payment and returns the order ID or an error.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL