Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be7452ddc1 | ||
|
|
3627712c9b |
5
go.mod
5
go.mod
@@ -2,4 +2,7 @@ module github.com/debyltech/go-snipcart
|
|||||||
|
|
||||||
go 1.20
|
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
|
||||||
|
)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
helper "github.com/debyltech/go-helpers"
|
helper "github.com/debyltech/go-helpers"
|
||||||
|
"github.com/skip2/go-qrcode"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -36,20 +37,22 @@ type SnipcartItem struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SnipcartOrder struct {
|
type SnipcartOrder struct {
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
Invoice string `json:"invoiceNumber"`
|
Invoice string `json:"invoiceNumber"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
TotalWeight float64 `json:"totalWeight"`
|
TotalWeight float64 `json:"totalWeight"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Name string `json:"shippingAddressName"`
|
Name string `json:"shippingAddressName"`
|
||||||
Address1 string `json:"shippingAddressAddress1"`
|
Address1 string `json:"shippingAddressAddress1"`
|
||||||
Address2 string `json:"shippingAddressAddress2"`
|
Address2 string `json:"shippingAddressAddress2"`
|
||||||
City string `json:"shippingAddressCity"`
|
City string `json:"shippingAddressCity"`
|
||||||
Province string `json:"shippingAddressProvince"`
|
Province string `json:"shippingAddressProvince"`
|
||||||
Country string `json:"shippingAddressCountry"`
|
Country string `json:"shippingAddressCountry"`
|
||||||
PostalCode string `json:"shippingAddressPostalCode"`
|
PostalCode string `json:"shippingAddressPostalCode"`
|
||||||
Phone string `json:"shippingAddressPhone"`
|
Phone string `json:"shippingAddressPhone"`
|
||||||
Items []SnipcartItem `json:"items"`
|
TrackingNumber string `json:"trackingNumber"`
|
||||||
|
TrackingUrl string `json:"trackingUrl"`
|
||||||
|
Items []SnipcartItem `json:"items"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SnipcartOrders struct {
|
type SnipcartOrders struct {
|
||||||
@@ -91,3 +94,12 @@ func (s *SnipcartProvider) GetOrdersByStatus(status OrderStatus) (*SnipcartOrder
|
|||||||
|
|
||||||
return s.GetOrders(map[string]string{"status": string(status)})
|
return s.GetOrders(map[string]string{"status": string(status)})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *SnipcartOrder) TokenPNGBase64() (string, error) {
|
||||||
|
img, err := qrcode.Encode(o.Token, qrcode.Medium, 128)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return base64.StdEncoding.EncodeToString(img), nil
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user