forked from pagarme/pagarme-golang-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
createCheckoutCreditCardPaymentRequest.go
55 lines (49 loc) · 1.81 KB
/
createCheckoutCreditCardPaymentRequest.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
52
53
54
55
package models
import (
"encoding/json"
)
// Checkout card payment request
type CreateCheckoutCreditCardPaymentRequest struct {
StatementDescriptor *string `json:"statement_descriptor,omitempty"`
Installments *[]CreateCheckoutCardInstallmentOptionRequest `json:"installments,omitempty"`
Authentication *CreatePaymentAuthenticationRequest `json:"authentication,omitempty"`
Capture *bool `json:"capture,omitempty"`
}
func (c *CreateCheckoutCreditCardPaymentRequest) MarshalJSON() (
[]byte,
error) {
return json.Marshal(c.toMap())
}
func (c *CreateCheckoutCreditCardPaymentRequest) toMap() map[string]any {
structMap := make(map[string]any)
if c.StatementDescriptor != nil {
structMap["statement_descriptor"] = c.StatementDescriptor
}
if c.Installments != nil {
structMap["installments"] = c.Installments
}
if c.Authentication != nil {
structMap["authentication"] = c.Authentication
}
if c.Capture != nil {
structMap["capture"] = c.Capture
}
return structMap
}
func (c *CreateCheckoutCreditCardPaymentRequest) UnmarshalJSON(input []byte) error {
temp := &struct {
StatementDescriptor *string `json:"statement_descriptor,omitempty"`
Installments *[]CreateCheckoutCardInstallmentOptionRequest `json:"installments,omitempty"`
Authentication *CreatePaymentAuthenticationRequest `json:"authentication,omitempty"`
Capture *bool `json:"capture,omitempty"`
}{}
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
c.StatementDescriptor = temp.StatementDescriptor
c.Installments = temp.Installments
c.Authentication = temp.Authentication
c.Capture = temp.Capture
return nil
}