go-unitpay-sdk

command module
v0.0.0-...-4290a6a Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2020 License: MIT Imports: 4 Imported by: 0

README

UnitPay Go-sdk

Golang sdk for UnitPay.ru

Documentation https://help.unitpay.ru

Installation

import "github.com/11golubin/go-unitpay-sdk/unitpay"

Examples

Example server provided in examples.go. Example requests provided in examples.http

Handler Sample
keys := r.URL.Query()

	valid, _ := unitpay.CheckHandlerRequest(keys, secret)

	if valid {
		w.Write(unitpay.GetSuccessHandlerResponse("Ok Message"))
	} else {
		w.Write(unitpay.GetErrorHandlerResponse("Error Message"))
	}
Payment integration using UnitPay Api
	keys := r.URL.Query()

	method := keys.Get("method")

	keys.Del("method")

	params := make(map[string]string)

	for key, _ := range keys {
		params[key] = keys.Get(key)
	}

	res, errorstring := unitpay.API(method, params, secret, public)
	if errorstring != "" {
		fmt.Println(errorstring)
	}


	if res.Error.Message != "" {
		response, _ := json.Marshal(res.Error)

		w.Write(response)
	} else {
		response, _ := json.Marshal(res.Result)

		w.Write(response)
	}
Form init sample
p := unitpay.Params{
   		Account:          "test",
   		Desc:             "testDesc",
   		Sum:              "100",
   		AdditionalParams: map[string]string{"locale": "en"},
   	}
   
   	url := unitpay.Form(p, secret, public)
   
   	http.Redirect(w, r, url, 301)

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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