Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Latest commit

 

History

History
48 lines (35 loc) · 1.85 KB

README.md

File metadata and controls

48 lines (35 loc) · 1.85 KB

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
}