forked from braintree-go/braintree-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apple_pay_card.go
71 lines (62 loc) · 1.93 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
package braintree
import (
"encoding/xml"
"time"
)
type ApplePayCard struct {
XMLName xml.Name `xml:"apple-pay-card"`
Token string `xml:"token"`
ImageURL string `xml:"image-url"`
CardType string `xml:"card-type"`
PaymentInstrumentName string `xml:"payment-instrument-name"`
SourceDescription string `xml:"source-description"`
BIN string `xml:"bin"`
Last4 string `xml:"last-4"`
ExpirationMonth string `xml:"expiration-month"`
ExpirationYear string `xml:"expiration-year"`
Expired bool `xml:"expired"`
Default bool `xml:"default"`
CustomerId string `xml:"customer-id"`
CreatedAt *time.Time `xml:"created-at"`
UpdatedAt *time.Time `xml:"updated-at"`
Subscriptions *Subscriptions `xml:"subscriptions"`
}
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
}