Giter Club home page Giter Club logo

qiwip2p's Introduction

Golang QIWI P2P library

This library can be used to access QIWI P2P Payments API (https://p2p.qiwi.com)

To get library run

go get -u github.com/vekotov/qiwiP2P

Usage

Importing library

import "github.com/vekotov/qiwiP2P"

Creating API Client

c := qiwiP2P.CreateClient(token)

Creating new payment bill

b := qiwiP2P.CreateBill()

// setup bill parameters
b.SetValue(10.57)
b.SetCurrency("RUB")
b.SetExpirationDuration(time.Minute * 5)

// put bill
result, err := c.PutBill(b)
if err != nil {
	println(err.Description)
	return
}
// print bill url
println(result.PayUrl)

Getting bill info

result, err := c.GetBill(billId)
if err != nil {
    println(err.Description)
    return
}

// print bill status
println(result.Status.Value)

Rejecting bill

result, err := c.RejectBill(result.BillId)
if err != nil {
    println(err.Description)
    return
}

Using webhook

For using webhook you need go to https://qiwi.com/p2p-admin/transfers/api and create new private key with webhook turned on.

Also don't forget that you need to add your backend URL in key settings.

// start webhook (you need to setup address on qiwi p2p page first)
ch := c.StartWebhook("/qiwi", 80)
for upd := range ch {
    // print bill id when bill is paid
    println(upd.Bill.BillId)
}

Authors

vekotov (tg: @vekotov), 2021

Library licensed under MIT License

qiwip2p's People

Contributors

vekotov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

qiwip2p's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.