-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathexample_test.go
More file actions
43 lines (37 loc) · 871 Bytes
/
Copy pathexample_test.go
File metadata and controls
43 lines (37 loc) · 871 Bytes
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 gocardless
import (
"fmt"
"os"
)
func ExampleCustomer() {
// Create a Client instance, providing your access token and the environment you want to use
token := os.Getenv("GOCARDLESS_ACCESS_TOKEN")
client := NewClient(token, SandboxEnvironment)
// create customer
cm := NewCustomer("user@example.com", "Frank", "Osborne", "27 Acer Road", "Apt 2", "London", "E8 3GX", "GB")
cm.AddMetadata("salesforce_id", "ABCD1234")
err := client.CreateCustomer(cm)
if err != nil {
panic(err)
}
fmt.Println(cm)
// retrieve customer
cm, err = client.GetCustomer(cm.ID)
if err != nil {
panic(err)
}
fmt.Println(cm)
// get customers
res, err := client.GetCustomers()
if err != nil {
panic(err)
}
fmt.Println(res)
// update customer
cm.CompanyName = "Google.com"
err = client.UpdateCustomer(cm)
if err != nil {
panic(err)
}
fmt.Println(cm)
}