forked from BoltApp/braintree-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
paypal_account_gateway.go
43 lines (38 loc) · 1.14 KB
/
paypal_account_gateway.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
package braintree
import "context"
type PayPalAccountGateway struct {
*Braintree
}
func (g *PayPalAccountGateway) Update(ctx context.Context, paypalAccount *PayPalAccount) (*PayPalAccount, error) {
resp, err := g.executeVersion(ctx, "PUT", "payment_methods/paypal_account/"+paypalAccount.Token, paypalAccount, apiVersion4)
if err != nil {
return nil, err
}
switch resp.StatusCode {
case 200:
return resp.paypalAccount()
}
return nil, &invalidResponseError{resp}
}
func (g *PayPalAccountGateway) Find(ctx context.Context, token string) (*PayPalAccount, error) {
resp, err := g.executeVersion(ctx, "GET", "payment_methods/paypal_account/"+token, nil, apiVersion4)
if err != nil {
return nil, err
}
switch resp.StatusCode {
case 200:
return resp.paypalAccount()
}
return nil, &invalidResponseError{resp}
}
func (g *PayPalAccountGateway) Delete(ctx context.Context, paypalAccount *PayPalAccount) error {
resp, err := g.executeVersion(ctx, "DELETE", "payment_methods/paypal_account/"+paypalAccount.Token, nil, apiVersion4)
if err != nil {
return err
}
switch resp.StatusCode {
case 200:
return nil
}
return &invalidResponseError{resp}
}