forked from braintree-go/braintree-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
44 lines (28 loc) · 1.02 KB
/
doc.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
/*
Package braintree is a client library for Braintree.
Initializing
Initialize it with API Keys:
braintree.New(Sandbox, merchantId, publicKey, privateKey)
Initialize it with an Access Token:
braintree.NewWithAccessToken(accessToken)
Loggers and HTTP Clients
Optionally configure a logger and HTTP client:
bt := braintree.New(...)
bt.Logger = log.New(...)
bt.HttpClient = ...
Creating Transactions
Create transactions:
ctx := context.Background()
t, err := bt.Transaction().Create(ctx, &braintree.TransactionRequest{
Type: "sale",
Amount: braintree.NewDecimal(100, 2), // $1.00
PaymentMethodNonce: braintree.FakeNonceTransactable,
})
API Errors
API errors are intended to be consumed in two ways. One, they can be dealt with as a single unit:
t, err := bt.Transaction().Create(...)
err.Error() => "A top level error message"
Second, you can drill down to see specific error messages on a field-by-field basis:
err.For("Transaction").On("Base")[0].Message => "A more specific error message"
*/
package braintree