Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.
/ p24 Public archive

Privat24 merchant API library for golang

License

Notifications You must be signed in to change notification settings

dimboknv/p24

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

p24 Build Status Go Report Card Coverage Status

This library provides privat24 marchant information api client.

Note: before using p24 you need to register merchant in privat24 system.

Install

go get -u github.com/dimboknv/p24

Usage

Also, you can visit p24-cli for an example with retryable, rate limited, logged client.

package main

import (
	"fmt"
	"log"
	"context"
	"net/http"
	"time"
	"github.com/dimboknv/p24"
)

func main() {
	client := p24.NewClient(p24.ClientOpts{
		HTTP: &http.Client{},
		Merchant: p24.Merchant{
			ID:   "merchant id",
			Pass: "merchant pass",
		},
	})

	// get merchant statements list for 2021-12-25 - 2021-12-27 date range
	// and "1234567891234567" card number
	ctx := context.Background()
	statements, err := client.GetStatements(ctx, p24.StatementsOpts{
		StartDate:  time.Date(2021, 12, 25, 0, 0, 0, 0, time.Local),
		EndDate:    time.Date(2021, 12, 27, 0, 0, 0, 0, time.Local),
		CardNumber: "1234567891234567",
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(statements)

	// get merchant card balance for "1234567891234567" card number
	cardBalance, err := client.GetCardBalance(ctx, p24.BalanceOpts{
		CardNumber: "1234567891234567",
		Country:    "UA",
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(cardBalance)
}