unionpay

package module
v0.0.0-...-ce0579b Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

README

unionpay

unionpay 银联支付

#####安装

go get -u github.com/qiwen698/unionpay

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapURLEncode

func MapURLEncode(m map[string]string) string

MapURLEncode Map to string and url encode.

func ParseCertificateFromFile

func ParseCertificateFromFile(path string) (cert *x509.Certificate, err error)

ParseCertificateFromFile 根据文件名解析出证书 openssl pkcs12 -in xxxx.pfx -clcerts -nokeys -out key.cert

func ParserPfxToCert

func ParserPfxToCert(path string, password string) (private *rsa.PrivateKey, cert *x509.Certificate, err error)

ParserPfxToCert 根据银联获取到的PFX文件和密码来解析出里面包含的私钥(rsa)和证书(x509)

func Sign

func Sign(params map[string]string, private *rsa.PrivateKey) (string, error)

Sign sign with privateKey.

func SignVerify

func SignVerify(params map[string]string) (bool, error)

SignVerify verify the signature.

func SortUnionMap

func SortUnionMap(m map[string]string) string

SortUnionMap unionpay requset map sort.

Types

type UnionCert

type UnionCert struct {
	Private *rsa.PrivateKey
	Cert    *x509.Certificate
	CertID  string
}

UnionCert cert info

type UnionPay

type UnionPay struct {
	Mode      string
	MerID     string
	URL       string
	FrontURL  string
	BackURL   string
	PfxPath   string
	PfxPwd    string
	UnionCert UnionCert
	// contains filtered or unexported fields
}

UnionPay unionpay

func NewUnionPay

func NewUnionPay(unionPay UnionPay) *UnionPay

NewUnionPay new unionpay client.

func (*UnionPay) AppConsume

func (c *UnionPay) AppConsume(txnamt int, orderNo, attach string) (map[string]string, error)

AppConsume 消费获取Tn

func (*UnionPay) BackNotifyReceive

func (c *UnionPay) BackNotifyReceive(writer http.ResponseWriter, request *http.Request) (map[string]string, error)

func (*UnionPay) ConsumeUndo

func (c *UnionPay) ConsumeUndo(txnamt int, orderNo, queryID, attach string) (map[string]string, error)

ConsumeUndo 消费撤销交易

func (*UnionPay) ParseNotify

func (c *UnionPay) ParseNotify(data string) (map[string]string, error)

ParseNotify parse and url decode notification.

func (*UnionPay) ParseRespone

func (c *UnionPay) ParseRespone(bytes []byte) map[string]string

ParseRespone parse respone.

func (*UnionPay) Post

func (c *UnionPay) Post(m map[string]string) (map[string]string, error)

Post requset

func (*UnionPay) Query

func (c *UnionPay) Query(orderNo string) (map[string]string, error)

Query 交易状态查询

func (*UnionPay) Refund

func (c *UnionPay) Refund(txnamt int, orderNo, queryID, attach string) (map[string]string, error)

Refund 退货交易

func (*UnionPay) ResultCheck

func (c *UnionPay) ResultCheck(m map[string]string) error

ResultCheck check result is success.

Jump to

Keyboard shortcuts

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