Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gojuno/go-zooz
Zooz API client for Go
https://github.com/gojuno/go-zooz
zooz-api-client-golang
Last synced: about 2 months ago
JSON representation
Zooz API client for Go
- Host: GitHub
- URL: https://github.com/gojuno/go-zooz
- Owner: gojuno
- License: bsd-3-clause
- Created: 2017-07-04T09:28:23.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-03-06T13:17:10.000Z (10 months ago)
- Last Synced: 2024-10-25T05:25:28.633Z (about 2 months ago)
- Topics: zooz-api-client-golang
- Language: Go
- Homepage:
- Size: 33.2 KB
- Stars: 7
- Watchers: 13
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - zooz - Go client for the Zooz API. (Third-party APIs / Utility/Miscellaneous)
- awesome-go - go-zooz - Zooz API client for Go - ★ 4 (Third-party APIs)
- awesome-go-extra - go-zooz - 07-04T09:28:23Z|2022-06-09T11:27:39Z| (Third-party APIs / Fail injection)
README
# Zooz API client [![GoDoc](https://godoc.org/github.com/gojuno/go-zooz?status.svg)](http://godoc.org/github.com/gojuno/go-zooz) [![Build Status](https://travis-ci.org/gojuno/go-zooz.svg?branch=master)](https://travis-ci.org/gojuno/go-zooz) [![Go Report Card](https://goreportcard.com/badge/github.com/gojuno/go-zooz)](https://goreportcard.com/report/github.com/gojuno/go-zooz)
This repo contains Zooz API client written in Go.
Zooz API documentation: https://developers.paymentsos.com/docs/api
Before using this client you need to register and configure Zooz account: https://developers.paymentsos.com/docs/quick-start.html
## How to install
Download package:
```
go get github.com/gojuno/go-zooz
```Client uses `github.com/pkg/errors`, so you may need to download this package as well:
```
go get github.com/pkg/errors
```## How to use
To init client you will need `private_key` and `app_id` which you can get from your Zooz account profile.
```
import "github.com/gojuno/go-zooz"
...
// Init client
client := zooz.New(
zooz.OptAppID("com.yourhost.go_client"),
zooz.OptPrivateKey("a630518c-22da-4eaa-bb39-502ad7832030"),
)// Create new customer
customer, customerErr := client.Customer().New(
context.Background(),
"customer_idempotency_key",
&zooz.CustomerParams{
CustomerReference: "1234",
FirstName: "John",
LastName: "Doe",
},
)// Create new payment method
paymentMethod, paymentMethodErr := client.PaymentMethod().New(
context.Background(),
"payment_method_idempotency_key",
customer.ID,
"918a917e-4cf9-4303-949c-d0cd7ff7f619",
)// Delete customer
deleteCustomerErr := client.Customer().Delete(context.Background(), customer.ID)
```## Custom HTTP client
By default Zooz client uses `http.DefaultClient`. You can set custom HTTP client using `zooz.OptHTTPClient` option:
```
httpClient := &http.Client{
Timeout: time.Minute,
}client := zooz.New(
zooz.OptAppID("com.yourhost.go_client"),
zooz.OptPrivateKey("a630518c-22da-4eaa-bb39-502ad7832030"),
zooz.OptHTTPClient(httpClient),
)
```
You can use any HTTP client, implementing `zooz.HTTPClient` interface with method `Do(r *http.Request) (*http.Response, error)`. Built-in `net/http` client implements it, of course.## Test/live environment
Zooz supports test and live environment. Environment is defined by `x-payments-os-env` request header.
By default, client sends `test` value. You can redefine this value to `live` using `zooz.OptEnv(zooz.EnvLive)` option.
```
client := zooz.New(
zooz.OptAppID("com.yourhost.go_client"),
zooz.OptPrivateKey("a630518c-22da-4eaa-bb39-502ad7832030"),
zooz.OptEnv(zooz.EnvLive),
)
```## Tokens
API methods for Tokens are not implemented in this client, because they are supposed to be used on client-side, not server-side. See example here: https://developers.paymentsos.com/docs/collecting-payment-details.html