forked from pagarme/pagarme-golang-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
createGooglePayRequest.go
51 lines (45 loc) · 1.5 KB
/
createGooglePayRequest.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package models
import (
"encoding/json"
)
// The GooglePay Token Payment Request
type CreateGooglePayRequest struct {
Version string `json:"version"`
Data string `json:"data"`
Header CreateGooglePayHeaderRequest `json:"header"`
Signature string `json:"signature"`
MerchantIdentifier string `json:"merchant_identifier"`
}
func (c *CreateGooglePayRequest) MarshalJSON() (
[]byte,
error) {
return json.Marshal(c.toMap())
}
func (c *CreateGooglePayRequest) toMap() map[string]any {
structMap := make(map[string]any)
structMap["version"] = c.Version
structMap["data"] = c.Data
structMap["header"] = c.Header
structMap["signature"] = c.Signature
structMap["merchant_identifier"] = c.MerchantIdentifier
return structMap
}
func (c *CreateGooglePayRequest) UnmarshalJSON(input []byte) error {
temp := &struct {
Version string `json:"version"`
Data string `json:"data"`
Header CreateGooglePayHeaderRequest `json:"header"`
Signature string `json:"signature"`
MerchantIdentifier string `json:"merchant_identifier"`
}{}
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
c.Version = temp.Version
c.Data = temp.Data
c.Header = temp.Header
c.Signature = temp.Signature
c.MerchantIdentifier = temp.MerchantIdentifier
return nil
}