Total Lines | 55 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package examples |
||
2 | |||
3 | import ( |
||
4 | "fmt" |
||
5 | "log" |
||
6 | "os" |
||
7 | |||
8 | "github.com/VictorAvelar/mollie-api-go/mollie" |
||
9 | ) |
||
10 | |||
11 | |||
12 | func init() { |
||
13 | _ = os.Setenv(mollie.APITokenEnv, "YOUR_API_TOKEN") |
||
14 | |||
15 | config := mollie.NewConfig(true, mollie.APITokenEnv) |
||
16 | client, _ = mollie.NewClient(nil, config) |
||
17 | } |
||
18 | |||
19 | // ListPaymentMethods code sample for getting a list of enabled payment methods on the website |
||
20 | func ListPaymentMethods() { |
||
21 | |||
22 | options := &mollie.MethodsOptions{Resource: "orders"} |
||
23 | list, err := client.Methods.List(options) |
||
24 | |||
25 | if err != nil { |
||
26 | log.Fatal(err) |
||
27 | } |
||
28 | |||
29 | fmt.Println(list) |
||
30 | } |
||
31 | |||
32 | // ListAllPaymentMethods code sample for getting a list all payment methods offered by Mollie |
||
33 | func ListAllPaymentMethods() { |
||
34 | |||
35 | options := &mollie.MethodsOptions{Locale: "en_US"} |
||
36 | list, err := client.Methods.All(options) |
||
37 | |||
38 | if err != nil { |
||
39 | log.Fatal(err) |
||
40 | } |
||
41 | |||
42 | fmt.Println(list) |
||
43 | } |
||
44 | |||
45 | // GetPaymentMethod code sample for getting an enabled payment method on the website |
||
46 | func GetPaymentMethod() { |
||
47 | |||
48 | options := &mollie.MethodsOptions{Include: "issuers"} |
||
49 | paymentMethod, err := client.Methods.Get("ideal", options) |
||
50 | |||
51 | if err != nil { |
||
52 | log.Fatal(err) |
||
53 | } |
||
54 | |||
55 | fmt.Println(paymentMethod) |
||
56 | } |
||
57 |