micropay

package
v1.0.0-beta.4 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package micropay 付款码支付

Package micropay 付款码支付

Package micropay 付款码支付

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthCodeToOpenId

func AuthCodeToOpenId(ctx *wxpay.WXPay, params map[string]string) (result map[string]string, err error)

付款码查询openid

通过付款码查询公众号Openid,调用查询后,该付款码只能由此商户号发起扣款,直至付款码更新。

See: https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_13&index=9

POST https://api.mch.weixin.qq.com/tools/authcodetoopenid

Example
package main

import (
	"fmt"

	"github.com/fastwego/wxpay"
	"github.com/fastwego/wxpay/apis/micropay"
)

func main() {
	var ctx *wxpay.WXPay

	params := map[string]string{
		"appid": "APPID",
		// ...
	}
	resp, err := micropay.AuthCodeToOpenId(ctx, params)

	fmt.Println(resp, err)
}
Output:

func MicroPay

func MicroPay(ctx *wxpay.WXPay, params map[string]string) (result map[string]string, err error)

付款码支付

收银员使用扫码设备读取微信用户付款码以后,二维码或条码信息会传送至商户收银台,由商户收银台或者商户后台调用该接口发起支付。

提醒1:提交支付请求后微信会同步返回支付结果。当返回结果为“系统错误”时,商户系统等待5秒后调用【查询订单API】,查询支付实际交易结果;当返回结果为“USERPAYING”时,商户系统可设置间隔时间(建议10秒)重新查询支付结果,直到支付成功或超时(建议30秒);

提醒2:在调用查询接口返回后,如果交易状况不明晰,请调用【撤销订单API】,此时如果交易失败则关闭订单,该单不能再支付成功;如果交易成功,则将扣款退回到用户账户。当撤销无返回或错误时,请再次调用。注意:请勿扣款后立即调用【撤销订单API】,建议至少15秒后再调用。撤销订单API需要双向证书。

See: https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_10&index=1#

POST https://api.mch.weixin.qq.com/pay/micropay

Example
package main

import (
	"fmt"

	"github.com/fastwego/wxpay"
	"github.com/fastwego/wxpay/apis/micropay"
)

func main() {
	var ctx *wxpay.WXPay

	params := map[string]string{
		"appid": "APPID",
		// ...
	}
	resp, err := micropay.MicroPay(ctx, params)

	fmt.Println(resp, err)
}
Output:

func Reverse

func Reverse(ctx *wxpay.WXPay, params map[string]string) (result map[string]string, err error)

撤销订单

支付交易返回失败或支付系统超时,调用该接口撤销交易。如果此订单用户支付失败,微信支付系统会将此订单关闭;如果用户支付成功,微信支付系统会将此订单资金退还给用户。

注意:7天以内的交易单可调用撤销,其他正常支付的单如需实现相同功能请调用申请退款API。提交支付交易后调用【查询订单API】,没有明确的支付结果再调用【撤销订单API】。

See: https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_11&index=3

POST https://api.mch.weixin.qq.com/secapi/pay/reverse

Example
package main

import (
	"fmt"

	"github.com/fastwego/wxpay"
	"github.com/fastwego/wxpay/apis/micropay"
)

func main() {
	var ctx *wxpay.WXPay

	params := map[string]string{
		"appid": "APPID",
		// ...
	}
	resp, err := micropay.Reverse(ctx, params)

	fmt.Println(resp, err)
}
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

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