/themap

Go client library for TheMAP

Primary LanguageGoMIT LicenseMIT

TheMAP

GitHub Actions GoDoc codecov Go Report Card Sourcegraph sendtips

A Go library to work with TheMAP.

Install

Install by import github.com/sendtips/themap or via go get github.com/sendtips/themap

The library itself can be compiled on go1.13, but to run tests you need go1.14 due to strconv.NumError received Unwrap() method only in v1.14

Tests

Run tests using THEMAPTERMID=TestTerminal THEMAPTERMPW=123 THEMAPMERCHID=TestMerchant THEMAPMERCHPW=123 THEMAPAPIHOST=https://api-stage.mapcard.pro go test -v .

Note: Use your credentials. The provided above will not work. There also THEMAPSIGNKEY variable exists, but currently, no one test uses it properly.

Example

To obtain a payment session you need to call Init() method.

package main

import (
	"fmt"
	"context"
	"github.com/sendtips/themap"
)

func main() {
	pay := themap.New("TestTerminal", "TestOrder123")
	pay.SetTerm("123") // Set Terminal password

	err := pay.Init(context.TODO(), 300) // Create a session for 3.00RUB
	if err != nil {
		fmt.Printf("Error occurred: %v", err)
	}

	fmt.Printf("%s", pay.SessionGUID) // TheMAP payment session identifier
}