example_test.go 956 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2021 Tencent Inc. All rights reserved.
  2. package notify_test
  3. import (
  4. "context"
  5. "fmt"
  6. "net/http"
  7. "git.nanodreamtech.com/sg/wechatpay-go/core/notify"
  8. "git.nanodreamtech.com/sg/wechatpay-go/services/payments"
  9. )
  10. func ExampleHandler_ParseNotifyRequest_transaction() {
  11. var handler notify.Handler
  12. var request *http.Request
  13. content := new(payments.Transaction)
  14. notifyReq, err := handler.ParseNotifyRequest(context.Background(), request, content)
  15. if err != nil {
  16. fmt.Println(err)
  17. return
  18. }
  19. // 处理通知内容
  20. fmt.Println(notifyReq.Summary)
  21. fmt.Println(content)
  22. }
  23. func ExampleHandler_ParseNotifyRequest_no_model() {
  24. var handler notify.Handler
  25. var request *http.Request
  26. content := make(map[string]interface{})
  27. notifyReq, err := handler.ParseNotifyRequest(context.Background(), request, content)
  28. if err != nil {
  29. fmt.Println(err)
  30. return
  31. }
  32. // 处理通知内容
  33. fmt.Println(notifyReq.Summary)
  34. fmt.Println(content)
  35. }