Documentation ¶
Overview ¶
Package notify 微信支付 API v3 Go SDK 商户通知处理库
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EncryptedResource ¶
type EncryptedResource struct { Algorithm string `json:"algorithm"` Ciphertext string `json:"ciphertext"` AssociatedData string `json:"associated_data"` Nonce string `json:"nonce"` OriginalType string `json:"original_type"` Plaintext string // Ciphertext 解密后内容 }
EncryptedResource 微信支付通知请求中的内容
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler 微信支付通知 Handler
func NewNotifyHandler ¶
NewNotifyHandler 创建通知处理器
func (*Handler) ParseNotifyRequest ¶
func (h *Handler) ParseNotifyRequest(ctx context.Context, request *http.Request, content interface{}) ( *Request, error, )
ParseNotifyRequest 从 HTTP 请求(http.Request) 中解析 微信支付通知(notify.Request)
Example (No_model) ¶
package main import ( "context" "fmt" "net/http" "gitee.com/eden-w2w/wechatpay-go/core/notify" ) func main() { var handler notify.Handler var request *http.Request content := make(map[string]interface{}) notifyReq, err := handler.ParseNotifyRequest(context.Background(), request, content) if err != nil { fmt.Println(err) return } // 处理通知内容 fmt.Println(notifyReq.Summary) fmt.Println(content) }
Output:
Example (Transaction) ¶
package main import ( "context" "fmt" "net/http" "gitee.com/eden-w2w/wechatpay-go/core/notify" "gitee.com/eden-w2w/wechatpay-go/services/payments" ) func main() { var handler notify.Handler var request *http.Request content := new(payments.Transaction) notifyReq, err := handler.ParseNotifyRequest(context.Background(), request, content) if err != nil { fmt.Println(err) return } // 处理通知内容 fmt.Println(notifyReq.Summary) fmt.Println(content) }
Output:
type Request ¶
type Request struct { ID string `json:"id"` CreateTime *time.Time `json:"create_time"` EventType string `json:"event_type"` ResourceType string `json:"resource_type"` Resource *EncryptedResource `json:"resource"` Summary string `json:"summary"` // 原始通知请求 RawRequest *http.Request }
Request 微信支付通知请求结构
Click to show internal directories.
Click to hide internal directories.