https://github.com/glef1x/go-qiwi-sdk
Training project, especially to educate basic features of golang
https://github.com/glef1x/go-qiwi-sdk
Last synced: over 1 year ago
JSON representation
Training project, especially to educate basic features of golang
- Host: GitHub
- URL: https://github.com/glef1x/go-qiwi-sdk
- Owner: GLEF1X
- Created: 2021-10-27T09:53:05.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-06T23:34:13.000Z (over 3 years ago)
- Last Synced: 2025-05-07T17:14:59.635Z (over 1 year ago)
- Language: Go
- Homepage:
- Size: 74.2 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SDK for QIWI API, written with golang
### Quick example:
```go
package main
import (
"context"
"fmt"
"github.com/GLEF1X/qiwi-golang-sdk/p2p"
"github.com/GLEF1X/qiwi-golang-sdk/types"
)
func main() {
config, err := p2p.NewConfig("some token")
if err != nil {
// handle it gracefully
panic(err)
}
httpClient := p2p.NewAPIClient(config)
bill, err := httpClient.CreateBill(
context.Background(),
&p2p.BillCreationOptions{
Amount: types.RequestAmount{
Value: 5.0, Currency: "RUB",
},
},
)
if err != nil {
panic(err)
}
fmt.Println(bill.PayUrl)
}
```
### Polling:
```go
package main
import (
"log"
"github.com/GLEF1X/go-qiwi-sdk/qiwi"
"github.com/GLEF1X/go-qiwi-sdk/qiwi/polling"
"github.com/GLEF1X/go-qiwi-sdk/types"
)
func main() {
config, err := qiwi.NewConfig("token", "+phone_number")
if err != nil {
panic(err)
}
apiClient := qiwi.NewAPIClient(config)
dp := polling.NewDispatcher(&polling.Config{MaxConcurrent: 10})
dp.HandleTransaction(func(transaction *types.Transaction) {
log.Println(transaction.ID)
})
dp.HandleError(func(err error) {
log.Println("Handle error in error handler")
})
dp.StartPolling(apiClient)
}
```