Compare commits

..

2 Commits

Author SHA1 Message Date
Bastian de Byl
831ad7c029 added order: prefix to TokenPNGBase64 2023-02-25 16:57:10 -05:00
Bastian de Byl
be7452ddc1 added order TokenPNGBase64 2023-02-25 16:49:56 -05:00
2 changed files with 14 additions and 1 deletions

5
go.mod
View File

@@ -2,4 +2,7 @@ module github.com/debyltech/go-snipcart
go 1.20
require github.com/debyltech/go-helpers v0.0.0-20230224002154-eb55816c71ec
require (
github.com/debyltech/go-helpers v0.0.0-20230224002154-eb55816c71ec
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
)

View File

@@ -7,6 +7,7 @@ import (
"fmt"
helper "github.com/debyltech/go-helpers"
"github.com/skip2/go-qrcode"
)
const (
@@ -93,3 +94,12 @@ func (s *SnipcartProvider) GetOrdersByStatus(status OrderStatus) (*SnipcartOrder
return s.GetOrders(map[string]string{"status": string(status)})
}
func (o *SnipcartOrder) TokenPNGBase64() (string, error) {
img, err := qrcode.Encode("order:"+o.Token, qrcode.Medium, 128)
if err != nil {
return "", err
}
return base64.StdEncoding.EncodeToString(img), nil
}