Giter VIP home page Giter VIP logo

wxpayv3's Introduction

WxPayV3

微信支付的v3版本,GO语言实现

The v3 version of WeChat Pay, implemented in GO language

Install

go get -v github.com/chrislzg/wxpayv3

Initialize

package main

import (
"wxpay.v3/core"
"wxpay.v3/dto"
"wxpay.v3/ecommerce"
)

func Test() (core.Client,error) {
    client, err := ecommerce.NewClient(&core.ClientConf{
    AppId:    map[dto.TradeType]string{dto.TradeTypeApp: "${AppId}", dto.TradeTypeJsApi: "${AppId}", dto.TradeTypeXCX: "${AppId}", dto.TradeTypeH5: "${AppId}"},
    MchId:    "${MchId}",
    ApiV3Key: "${APIKEY}",
    ApiCert: &core.ApiCert{
        ApiSerialNo:      "${APISerialNo}",
        ApiPrivateKeyStr: "${apiPrivateKey}",
        ApiCertKey:       "${apiPublickCert}",
    },
    // 该项是可选项,获取平台证书前可不填
    PlatCert: &core.PlatformCert{
        PlatformSerialNo: "${PlatformSerialNo}",
        PlatformCertKey:  "${platformPublicCert}",
    },
    HttpClient: nil,
    })
    if err != nil {
        return nil, err
    }
    return client, nil
}

Usage

/// 获取签名Authorization,由认证类型和签名信息组成
Authorization(httpMethod string, urlString string, body []byte) (string, error)
// 获取签名信息
Token(httpMethod string, rawUrl string, body []byte) (string, error)
// 更新平台证书,获取到证书后调用该方法更新平台证书
UpdatePlatformCert(cert *PlatformCert) error
// 合单支付
CombineTransactions(req *dto.CombineTransactionsReq) (*dto.CombineTransactionsResp, error)
// 提现
WithdrawFund(req *dto.WithdrawFundReq) (*dto.WithdrawFundResp, error)
// 提现状态查询
QueryWithdrawalStatus(req *dto.QueryWithdrawalStatusReq) (*dto.QueryWithdrawalStatusResp, error)
// 查询账户余额
QueryFundBalance(req *dto.QueryFundBalanceReq) (*dto.QueryFundBalanceResp, error)
// 分账
ProfitSharing(req *dto.ProfitSharingReq) (*dto.ProfitSharingResp, error)
// 分账退回
ReturnProfitSharing(req *dto.ReturnProfitSharingReq) (*dto.ReturnProfitSharingResp, error)
// 退款
Refund(req *dto.RefundReq) (*dto.RefundResp, error)
// 验证Response
VerifyResponse(httpStatus int, header *http.Header, body []byte) error
// 验证回调
VerifyNotify(header *http.Header, body []byte) error
// 证书和报文解密
Decrypt(algorithm string, cipherText string, associatedData string, nonce string) ([]byte, error)
// 下载平台证书
Certificate() (*dto.CertificateResp, error)
// 利用api证书私钥对签名串进行签名得到签名值
Sign(message []byte) (string, error)
// 对支付成功通知进行验签和解密
HandlePaymentNotify(headerSerial string, headerSignature string, headerTimestamp string, headerNonce string, body []byte) (*dto.PaymentNotifyResp, error)
// 对分账对账通知验签和解密
HandleProfitSharingNotify(headerSerial string, headerSignature string, headerTimestamp string, headerNonce string, body []byte) (*dto.ProfitSharingNotifyResp, error)
// 对退款通知验签和解密
HandleRefundNotify(headerSerial string, headerSignature string, headerTimestamp string, headerNonce string, body []byte) (*dto.RefundNotifyResp, error)
// 获取客户端调起支付时请求参数
BuildTurnUpPaymentArgumentBody(tradeType dto.TradeType, prepayId string) (string, error)
// 查询分账状态
QueryProfitSharingStatus(req *dto.QueryProfitSharingStatusReq) (*dto.QueryProfitSharingStatusResp, error)

Platform Certification

在获取平台证书前,初始化client可先不传PlatCert配置,调用Certificate()获取平台证书后,调用UpdatePlatformCert方法更新client的证书

Contact

email: [email protected]

Licence

MIT License

Copyright (c) 2020 chrislzg

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

wxpayv3's People

Contributors

chrislzg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

wxpayv3'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.