• Stars
    star
    7
  • Rank 2,294,772 (Top 46 %)
  • Language
    Go
  • License
    BSD 3-Clause "New...
  • Created over 7 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Zooz API client for Go

Zooz API client GoDoc Build Status Go Report Card

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

More Repositories

1

minimock

Powerful mock generation tool for Go programming language
Go
626
star
2

composer

Reactive Android Instrumentation Test Runner. Archived. Marathon is recommended as an alternative (https://github.com/Malinskiy/marathon).
Kotlin
547
star
3

koptional

Minimalistic Optional type for Kotlin that tries to fit its null-safe type system as smooth as possible.
Kotlin
285
star
4

swarmer

Reactive tool to create and start multiple Android Emulators in parallel.
Kotlin
201
star
5

test_tasks

Juno Inc., Test Tasks
42
star
6

engineering

Juno Engineering Blog
33
star
7

jrg

Juno Reverse Geocoder
Gherkin
28
star
8

genval

Generates Validate() methods for structs by tags
Go
28
star
9

lostgis

PLpgSQL
25
star
10

commander

Set of reactive functions for cli tools like Swarmer and Composer.
Kotlin
20
star
11

geo-py

Set of algorithms and structures related to geodesy
Python
17
star
12

osrm-py

Python client for OSRM API
Python
16
star
13

tracegen

Simple tool to generate opentracing decorators
Go
15
star
14

hexgrid-py

Configurable hex grid on abstract surface
Python
14
star
15

make-profiler

Makefile profiling toolset
Python
10
star
16

metricsgen

Tool to generate metrics decorators for interfaces
Go
8
star
17

hexgridgeo-py

GEO wrapper for HexGrid
Python
7
star
18

generator

Package that simplifies development of go source code generators
Go
6
star
19

junocfg

Template based config generator
Go
6
star
20

morton-py

Morton Pack/Unpack Library
Python
4
star
21

go.morton

Morton Pack/Unpack Library
Go
4
star
22

hexgrid-pgsql

Configurable hexgrid
PLpgSQL
4
star
23

hexgrid-java

HexGrid
Java
4
star
24

goose

Fork of the https://bitbucket.org/liamstask/goose.git without SQLite support
Go
3
star
25

FraktalBand

Swift
3
star
26

TestingPresentableComponents

Swift
3
star
27

FraktalSimplified

Swift
2
star
28

RetryIt

Swift
1
star
29

morton-java

Morton Pack/Unpack Library
Java
1
star
30

frontend-config

JavaScript
1
star
31

morton-js

Morton Pack/Unpack Library
JavaScript
1
star
32

svgen

Scanners and valuers generator for basic types aliases
Go
1
star
33

go-checkout

Checkout.com API client
Go
1
star
34

go.hexgrid

HexGrid
Go
1
star
35

MortonSwift

Swift
1
star