Skip to content

indraoct/go-jenius

Repository files navigation

go-jenius

Implementation Jenius Pay using Go (Golang)

GitHub code size in bytes GitHub

1. Installation

To install this library , you can import it into your GOPATH by running this command in your terminal :

go get github.com/indraoct/go-jenius

2. Usage

To use this library , first thing first is you need to initiate the client property data like this :

	
	client := jenius.NewClient()
    	client.UrlDevelopment = "{JENIUS URL DEVELOPMENT}"
    	client.UrlProduction  = "{JENIUS URL PRODUCTION}"
    	client.Environtment = "dev"     // dev for development ; prod for production
    	client.ApiKey       = "{YOUR API KEY}"
    	client.ApiSecret    = "{YOUR API SECRET}"
    	client.ChannelId    = "{YOUR CHANNEL ID}"
    	client.ClientId     = "{YOUR CLIENT ID}"
    	client.CallbackUrl  = "{YOUR CALLBACK URL}"
    	client.ReferenceNo  = "{YOUR TRANSACTION ID}"
    	client.TimeStamp    = helper.GetNowTime().Format(jenius.JENIUS_DATETIME_FORMAT) //timestamp standard for jenius payment
    	

And then you must parse the initiate data into function initiate like this :

   //parse the client data into function
   	function := jenius.Function{
   		Client:client,
   	}

And then you can set the parameter data for main function , for example "PayRequest" for creating payment After that you can call the main function such as Create Transaction and Payment Status.

3. Example

Create Transaction

Create Transaction is a jenius service to send transaction data from client to jenius server.

package main

import (
	"fmt"
	"github.com/indraoct/go-jenius"
	"github.com/indraoct/go-jenius/helper"
)

func main(){
	
	//initiate client
	client := jenius.NewClient()
	client.UrlDevelopment = "{JENIUS URL DEVELOPMENT}"
	client.UrlProduction  = "{JENIUS URL PRODUCTION}"
	client.Environtment = "dev"     // dev for development ; prod for production
	client.ApiKey       = "{YOUR API KEY}"
	client.ApiSecret    = "{YOUR API SECRET}"
	client.ChannelId    = "{YOUR CHANNEL ID}"
	client.ClientId     = "{YOUR CLIENT ID}"
	client.CallbackUrl  = "{YOUR CALLBACK URL}"
	client.ReferenceNo  = "{YOUR TRANSACTION ID}"
	client.TimeStamp    = helper.GetNowTime().Format(jenius.JENIUS_DATETIME_FORMAT) //timestamp standard for jenius payment
	
	//match client into function
	function := jenius.Function{
		Client:client,
	}
	
	//PayRequest Parameter
	req := &jenius.PayRequest{
		Cashtag:"{YOUR CUSTOMER CASHTAG}",
		PromoCode:"",
		PurchaseDesc:"Beli Emas 0.6 gr Indra",
		TxnAmount:"350000",
	}
	
	//main function
	res,err := function.CreateTransaction(req)
	
	if err != nil{
		fmt.Println(err.Error())
	}
	
	fmt.Println(res)
}

Transaction Status

Transaction status is a jenius service to get data transaction status.

package main

import (
	"fmt"
	"github.com/indraoct/go-jenius"
	"github.com/indraoct/go-jenius/helper"
)

func main(){
	
	//initiate client
	client := jenius.NewClient()
	client.UrlDevelopment = "{JENIUS URL DEVELOPMENT}"
	client.UrlProduction  = "{JENIUS URL PRODUCTION}"
	client.Environtment = "dev"     // dev for development ; prod for production
	client.ApiKey       = "{YOUR API KEY}"
	client.ApiSecret    = "{YOUR API SECRET}"
	client.ChannelId    = "{YOUR CHANNEL ID}"
	client.ClientId     = "{YOUR CLIENT ID}"
	client.CallbackUrl  = "{YOUR CALLBACK URL}"
	client.TimeStamp    = helper.GetNowTime().Format(jenius.JENIUS_DATETIME_FORMAT) //timestamp standard for jenius payment
	
	//match client into function
	function := jenius.Function{
		Client:client,
	}
	
	//Status Request Parameter
	req := &jenius.TrxStatusRequest{
		ReferenceNo:"{YOUR TRANSACTION ID}",
		TrxDateTime:"2020-04-08T15:16:45.791+07:00", // transaction date time in jenius format
	}
	
	//main function
	res,err := function.TransactionStatus(req)
	
	if err != nil{
		fmt.Println(err.Error())
	}
	
	fmt.Println(res)
}

License

MIT

Copyright (c) 2020 - Indra Octama

About

Jenius Pay implementation using Go (Golang)

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages