lazerpay

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2022 License: MIT Imports: 7 Imported by: 0

README

Lazerpay Golang SDK ⚡

Installation ✔️

To install the package, use the command below.

go get github.com/milinches/lazerpay-go-sdk

Import the package.

import "github.com/milinches/lazerpay-go-sdk"

Optional, import the godotenv package in your code. It'll help in loading the .env files.

import "github.com/joho/godotenv"

You can also get your Test API keys, from the Lazerpay Dashboard here.

INITIALIZE TRANSACTIONS

Initiate a payment.

package main

import (
    "log"
    "os"

    "github.com/joho/godotenv"
    "github.com/milinches/lazerpay-go-sdk"
)

func main() {
    // Load the env file
    if err := godotenv.Load(".Sample.env); err != nil {
        log.Fatal("Error loading .env file")
    }

    secretKey := os.GetEnv("SECRET_KEY")
    publicKey := os.GetEnv("PUBLIC_KEY")

    // You can also handle error by adding a second parameter
    initialize, _ := lazerpay.LazerpayClient(publicKey, secretKey)

    // Initialize payment
    payment, _ := lazerpay.InitTransaction(initialize, "xxxxxxxx", "100", 
    "Njoku Emmanuel", "kalunjoku123@gmail.com", "USD", "USDC", true
    )

    log.Println(payment)
}

VERIFY TRANSACTION

Helps confirm a transaction after payment has been made.

package main

import (
    "log"
    "os"

    "github.com/joho/godotenv"
    "github.com/milinches/lazerpay-go-sdk"
)

func main() {
    // Load the env file
    if err := godotenv.Load(".Sample.env); err != nil {
        log.Fatal("Error loading .env file")
    }

    secretKey := os.GetEnv("SECRET_KEY")
    publicKey := os.GetEnv("PUBLIC_KEY")

    // You can also handle error by adding a second parameter
    initialize, _ := lazerpay.LazerpayClient(publicKey, secretKey)

    // Verify Transaction
    verify, _ := lazerpay.VerifyTransaction(initialize, "referenceNumberxxxxx")

    log.Println(verify)
}

Get Accepted Coins

Returns the list of accepted coins at Lazerpay.

package main

import (
    "log"
    "os"

    "github.com/joho/godotenv"
    "github.com/milinches/lazerpay-go-sdk"
)

func main() {
    // Load the env file
    if err := godotenv.Load(".Sample.env); err != nil {
        log.Fatal("Error loading .env file")
    }

    secretKey := os.GetEnv("SECRET_KEY")
    publicKey := os.GetEnv("PUBLIC_KEY")

    // You can also handle error by adding a second parameter
    initialize, _ := lazerpay.LazerpayClient(publicKey, secretKey)

    // Get the list of all accepted coins
    coins, _ := lazerpay.GetAcceptedCoins(initialize)

    log.Println(coins)
}

Transfer Funds

Helps send funds to another recipient address.

package main

import (
    "log"
    "os"

    "github.com/joho/godotenv"
    "github.com/milinches/lazerpay-go-sdk"
)

func main() {
    // Load the env file
    if err := godotenv.Load(".Sample.env); err != nil {
        log.Fatal("Error loading .env file")
    }

    secretKey := os.GetEnv("SECRET_KEY")
    publicKey := os.GetEnv("PUBLIC_KEY")

    // You can also handle error by adding a second parameter
    initialize, _ := lazerpay.LazerpayClient(publicKey, secretKey)

    // Send funds to another recipient address
    transfer, _ := lazerpay.Transfer(initialize, 10, "recipientxxxxxx", "USDC", "Binance Smart Chain")

    log.Println(transfer)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAcceptedCoins

func GetAcceptedCoins(clientHeader http.Header) (string, error)

GetAcceptedCoins helps retrive all accepted coins.

The “clientHeader“ is gotten from the LazerpayClient

lazerpay.GetAcceptedCoins(clientHeader)

func InitTransaction

func InitTransaction(clientHeader http.Header, reference, amount, customerName, customerEmail, currencyType, coin string, acceptPartialPayment bool) (string, error)

InitTransaction function helps initialize new transactions.

The “clientHeader“ is gotten from the LazerpayClient

lazerpay.InitTransaction(clientHeader ,"4tytytreytrey65756u5u66", "1000", "Abdulfatai Suleiman", "staticdev20046@gmail.com", "USD", "DAI", true)

func LazerpayClient

func LazerpayClient(publicKey, secretKey string) (http.Header, error)

LazerpayClient adds the necessary “http.header“

lazerpay.LazerpayClient(publicKey, secretKey)

func Transfer

func Transfer(clientHeader http.Header, amount uint, recipient, coin, blockchain string) (string, error)

Transfer helps send funds to another recipient.

amount must not be less than 1 and also it should not be empty.
recipient should not be empty, and also the recipient must be an Ethereum address.
coin must be a string, coin should not be empty.
blockchain must be a string, and blockchain must not be empty.

The “clientHeader“ is gotten from the LazerpayClient

lazerpay.Transfer(clientHeader,1, "0xF378c952d5266eF8e1783521a1395Fe40cDCe55B", "USDT", "Binance Smart Chain")

func VerifyTransaction

func VerifyTransaction(clientHeader http.Header, reference string) (string, error)

VerifyTransactions helps verify a payment.

The “clientHeader“ is gotten from the LazerpayClient

lazerpay.VerifyTransaction(clientHeader, "0xf2345527195C3bdc6C5f07576a3C860281926841")

Types

type InitializeTransaction

type InitializeTransaction struct {
	Reference            string `json:"reference"`
	Amount               string `json:"amount"`
	CustomerName         string `json:"customer_name"`
	CustomerEmail        string `json:"customer_Eemail"`
	Currency             string `json:"currency"`
	Coin                 string `json:"coin"`
	AcceptPartialPayment bool   `json:"accept_partial_payment"`
}

type TransferFunds

type TransferFunds struct {
	Amount     uint   `json:"amount"`
	Recipient  string `json:"recipient"`
	Coin       string `json:"coin"`
	BlockChain string `json:"blockchain"`
}

Jump to

Keyboard shortcuts

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