forked from braintree-go/braintree-go
-
Notifications
You must be signed in to change notification settings - Fork 12
/
apple_pay_card.go
75 lines (66 loc) · 2.34 KB
/
apple_pay_card.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package braintree
import (
"encoding/xml"
"time"
)
type ApplePayCard struct {
XMLName xml.Name `xml:"apple-pay-card"`
Token string `xml:"token,omitempty"`
ImageURL string `xml:"image-url,omitempty"`
CardType string `xml:"card-type,omitempty"`
PaymentInstrumentName string `xml:"payment-instrument-name,omitempty"`
SourceDescription string `xml:"source-description,omitempty"`
BIN string `xml:"bin,omitempty"`
Last4 string `xml:"last-4,omitempty"`
ExpirationMonth string `xml:"expiration-month,omitempty"`
ExpirationYear string `xml:"expiration-year,omitempty"`
ECI string `xml:"eci-indicator,omitempty"`
Cryptogram string `xml:"cryptogram,omitempty"`
Number string `xml:"number,omitempty"`
CardholderName string `xml:"cardholder-name,omitempty"`
Expired bool `xml:"expired,omitempty"`
Default bool `xml:"default,omitempty"`
CustomerId string `xml:"customer-id,omitempty"`
CreatedAt *time.Time `xml:"created-at,omitempty"`
UpdatedAt *time.Time `xml:"updated-at,omitempty"`
Subscriptions *Subscriptions `xml:"subscriptions,omitempty"`
}
type ApplePayCards struct {
ApplePayCard []*ApplePayCard `xml:"apple-pay-card"`
}
func (a *ApplePayCards) PaymentMethods() []PaymentMethod {
if a == nil {
return nil
}
var paymentMethods []PaymentMethod
for _, a := range a.ApplePayCard {
paymentMethods = append(paymentMethods, a)
}
return paymentMethods
}
func (a *ApplePayCard) GetCustomerId() string {
return a.CustomerId
}
func (a *ApplePayCard) GetToken() string {
return a.Token
}
func (a *ApplePayCard) IsDefault() bool {
return a.Default
}
func (a *ApplePayCard) GetImageURL() string {
return a.ImageURL
}
// AllSubscriptions returns all subscriptions for this paypal account, or nil if none present.
func (a *ApplePayCard) AllSubscriptions() []*Subscription {
if a.Subscriptions != nil {
subs := a.Subscriptions.Subscription
if len(subs) > 0 {
a := make([]*Subscription, 0, len(subs))
for _, s := range subs {
a = append(a, s)
}
return a
}
}
return nil
}