This library provides privat24 marchant information api client.
Note: before using p24
you need to register merchant in privat24 system.
go get -u github.com/dimboknv/p24
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)
}