wxgamevp

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2020 License: MIT Imports: 5 Imported by: 0

README

wxgamevp-微信小游戏虚拟支付

Build Status Go Report Card codecov

开发者中心

引入方式

go get github.com/birjemin/wxgamevp

接口列表

使用方式

  • 示例
httpClient := &utils.HTTPClient{
    Client: &http.Client{
        Timeout: 5 * time.Second,
    },
}
pay := Pay{
		OpenID:       "odkx20ENSNa2w5y3g_qOkOvBNM1g",
		AppID:        "wx1234567",
		OfferID:      "12345678",
		Ts:           1507530737,
		ZoneID:       "1",
		Amt:          123,
		BillNo:       "BillNo_123",
		Pf:           "android",
		AccessToken:  "ACCESSTOKEN",
		Secret:       "zNLgAGgqsEWJOg1nFVaO5r7fAlIQxr1u",
		SessionToken: "V7Q38/i2KXaqrQyl2Yx9Hg==",
		HTTPRequest:  httpClient,
	}

	if ret, err := pay.Pay(); err != nil {
		t.Error(err)
	} else {
		if ret.ErrCode != 0 {
			t.Error(errors.New("msg: " + ret.ErrMsg))
		}
	}

测试

  • 测试
    go test
    
  • 格式化代码
    golint
    
  • 覆盖率
    go test -cover
    go test -coverprofile=coverage.out 
    go tool cover -html=coverage.out
    

备注

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSign

func GenerateSign(uri, method, secretName, secret string, params map[string]string) string

GenerateSign generate sign

Types

type Balance

type Balance struct {
	OpenID      string
	AppID       string
	OfferID     string
	Ts          int
	ZoneID      string
	Pf          string
	UserIP      string
	AccessToken string
	Secret      string
	HTTPRequest *utils.HTTPClient
	Debug       bool
}

Balance model

func (*Balance) GetBalance

func (b *Balance) GetBalance() (*RespBalance, error)

GetBalance get balance

type CancelPay

type CancelPay struct {
	OpenID      string
	AppID       string
	OfferID     string
	Ts          int
	ZoneID      string
	Pf          string
	UserIP      string
	BillNo      string
	PayItem     string
	AccessToken string
	Secret      string
	HTTPRequest *utils.HTTPClient
	Debug       bool
}

CancelPay model

func (*CancelPay) CancelPay

func (p *CancelPay) CancelPay() (*RespPay, error)

CancelPay pay

type CommonError

type CommonError struct {
	ErrCode int    `json:"errcode"`
	ErrMsg  string `json:"errmsg"`
}

CommonError model

type Order

type Order struct {
	AppID       string
	OrderNo     string
	OutTradeNo  string
	AccessToken string
	HTTPRequest *utils.HTTPClient
	Debug       bool
}

Order model

func (*Order) GetOrder

func (b *Order) GetOrder() (*RespOrder, error)

GetOrder get order

type OrderDetail

type OrderDetail struct {
	OutTradeNo string `json:"out_trade_no"`
	OrderNo    string `json:"order_no"`
	OpenID     string `json:"openid"`
	CreateTime int    `json:"create_time"`
	Amount     int    `json:"amount"`
	Status     int    `json:"status"`
	ZoneID     string `json:"zone_id"`
	Env        int    `json:"env"`
	PayTime    int    `json:"pay_time"`
}

OrderDetail struct

type Pay

type Pay struct {
	OpenID      string
	AppID       string
	OfferID     string
	Ts          int
	ZoneID      string
	Pf          string
	UserIP      string
	Amt         int
	BillNo      string
	PayItem     string
	AppRemark   string
	AccessToken string
	Secret      string
	HTTPRequest *utils.HTTPClient
	Debug       bool
}

Pay model

func (*Pay) Pay

func (p *Pay) Pay() (*RespPay, error)

Pay pay

type Present

type Present struct {
	OpenID        string
	AppID         string
	OfferID       string
	Ts            int
	ZoneID        string
	Pf            string
	UserIP        string
	BillNo        string
	PresentCounts int
	AccessToken   string
	Secret        string
	HTTPRequest   *utils.HTTPClient
	Debug         bool
}

Present model

func (*Present) Present

func (p *Present) Present() (*RespPay, error)

Present pay

type RespBalance

type RespBalance struct {
	CommonError
	Balance    int `json:"balance"`
	GenBalance int `json:"gen_balance"`
	FirstSave  int `json:"first_save"`
	SaveAmt    int `json:"save_amt"`
	SaveSum    int `json:"save_sum"`
	CostSum    int `json:"cost_sum"`
	PresentSum int `json:"present_sum"`
}

RespBalance response

type RespCancelPay

type RespCancelPay struct {
	CommonError
	BillNo string `json:"bill_no"`
}

RespCancelPay response

type RespOrder

type RespOrder struct {
	CommonError
	PayForOrder OrderDetail `json:"payfororder"`
}

RespOrder response

type RespPay

type RespPay struct {
	CommonError
	BillNo     string `json:"bill_no"`
	Balance    int    `json:"balance"`
	UsedGenAmt int    `json:"used_gen_amt"`
}

RespPay response

type RespPresent

type RespPresent struct {
	CommonError
	Balance string `json:"balance"`
	BillNo  string `json:"bill_no"`
}

RespPresent response

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL