| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | package main |
||
| 2 | |||
| 3 | import ( |
||
| 4 | "fmt" |
||
| 5 | |||
| 6 | "github.com/VictorAvelar/mollie-api-go/mollie" |
||
| 7 | ) |
||
| 8 | |||
| 9 | const ( |
||
| 10 | APIKey string = "your api key here" |
||
| 11 | OrgKey string = "your org key here" |
||
| 12 | ) |
||
| 13 | |||
| 14 | func main() { |
||
| 15 | /* |
||
| 16 | To build our config, we need to tell our client if its |
||
| 17 | purpose is to be used for testing or live requests, and |
||
| 18 | then if using static tokens we will pass our key as |
||
| 19 | second parameter, this will attach our token to every |
||
| 20 | outgoing requests as a Bearer token. |
||
| 21 | */ |
||
| 22 | config := mollie.NewConfig(true, APIKey) |
||
| 23 | |||
| 24 | /* |
||
| 25 | Then we build our Mollie API client, in this case we will |
||
| 26 | pass nil as we are not using a prebuilt http client and our |
||
| 27 | recently created configuration. |
||
| 28 | |||
| 29 | Now after checking for errors we are ready to make a test call |
||
| 30 | to Mollie's API. |
||
| 31 | */ |
||
| 32 | m, err := mollie.NewClient(nil, config) |
||
| 33 | if err != nil { |
||
| 34 | return |
||
| 35 | } |
||
| 36 | |||
| 37 | output, err := m.Methods.List(nil) |
||
| 38 | if err != nil { |
||
| 39 | return |
||
| 40 | } |
||
| 41 | |||
| 42 | /* |
||
| 43 | Now you should see a list of the enabled payment methods for your |
||
| 44 | account. |
||
| 45 | */ |
||
| 46 | for _, o := range output.Embedded.Methods { |
||
| 47 | fmt.Printf("Id: %s | Name: %s", o.ID, o.Description) |
||
| 48 | } |
||
| 50 |