fix(purchase): streamline error handling and improve JSON marshaling for temporary orders

This commit is contained in:
Chang lue Tsen
2025-09-06 11:03:14 -04:00
parent d477ba4772
commit d5ed82955e
5 changed files with 33 additions and 25 deletions
+14 -6
View File
@@ -1,8 +1,6 @@
package constant
import (
"encoding/json"
)
import "encoding/json"
// Used for type cloning conversion
const (
@@ -46,7 +44,17 @@ type TemporaryOrderInfo struct {
InviteCode string `json:"invite_code,omitempty"`
}
func (t TemporaryOrderInfo) Marshal() string {
value, _ := json.Marshal(t)
return string(value)
func (t *TemporaryOrderInfo) Unmarshal(data []byte) error {
type Alias TemporaryOrderInfo
aux := (*Alias)(t)
return json.Unmarshal(data, aux)
}
func (t *TemporaryOrderInfo) Marshal() ([]byte, error) {
type Alias TemporaryOrderInfo
return json.Marshal(&struct {
*Alias
}{
Alias: (*Alias)(t),
})
}