forked from stripe/stripe-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
39 lines (30 loc) · 903 Bytes
/
client.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
// package threedsecure provides the /3d_secure APIs
package threedsecure
import (
"strconv"
"github.com/stripe/stripe-go"
)
type Client struct {
B stripe.Backend
Key string
}
func New(params *stripe.ThreeDSecureParams) (*stripe.ThreeDSecure, error) {
return getC().New(params)
}
func (c Client) New(params *stripe.ThreeDSecureParams) (*stripe.ThreeDSecure, error) {
body := &stripe.RequestValues{}
body.Add("amount", strconv.FormatUint(params.Amount, 10))
body.Add("card", params.Card)
body.Add("currency", string(params.Currency))
body.Add("return_url", params.ReturnURL)
if len(params.Customer) > 0 {
body.Add("customer", params.Customer)
}
params.AppendTo(body)
tds := &stripe.ThreeDSecure{}
err := c.B.Call("POST", "/3d_secure", c.Key, body, ¶ms.Params, tds)
return tds, err
}
func getC() Client {
return Client{stripe.GetBackend(stripe.APIBackend), stripe.Key}
}