1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- package certificates_test
- import (
- "context"
- "log"
- "git.nanodreamtech.com/sg/wechatpay-go/core"
- "git.nanodreamtech.com/sg/wechatpay-go/core/option"
- "git.nanodreamtech.com/sg/wechatpay-go/services/certificates"
- "git.nanodreamtech.com/sg/wechatpay-go/utils"
- )
- func ExampleCertificatesApiService_DownloadCertificates() {
- var (
- mchID string = "190000****"
- mchCertificateSerialNumber string = "3775************************************"
- mchAPIv3Key string = "2ab9****************************"
- )
-
- mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
- if err != nil {
- log.Print("load merchant private key error")
- }
- ctx := context.Background()
-
- opts := []core.ClientOption{
- option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
- }
- client, err := core.NewClient(ctx, opts...)
- if err != nil {
- log.Printf("new wechat pay client err:%s", err)
- }
- svc := certificates.CertificatesApiService{Client: client}
- resp, result, err := svc.DownloadCertificates(ctx)
- if err != nil {
-
- log.Printf("call DownloadCertificates err:%s", err)
- } else {
-
- log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
- }
- }
|