Categorygithub.com/gtforge/go-zooz
modulepackage
1.9.0
Repository: https://github.com/gtforge/go-zooz.git
Documentation: pkg.go.dev

# README

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

# Packages

No description provided by the author

# Functions

CalculateWebhookSignature calculates signature for webhook request (without "sig1=" prefix).
DecodeWebhookRequest decodes PaymentsOS webhook http request into callback entity.
New creates new client with given options.
OptApiURL returns option with given API URL.
OptAppID returns option with given App ID.
OptEnv returns option with given environment value.
OptHTTPClient returns option with given HTTP client.
OptPrivateKey returns option with given private key.
OptPublicKey returns option with given public key.
No description provided by the author

# Constants

ApiURL is default base url to send requests.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
EnvLive is a value for live environment header.
EnvTest is a value for test environment header.
List of possible payment action values.
List of possible payment action values.
List of possible payment action values.
List of possible payment action values.
List of possible payment action values.
List of possible payment action values.
List of possible payment expansion values.
List of possible payment expansion values.
List of possible payment expansion values.
List of possible payment expansion values.
List of possible payment expansion values.
List of possible payment expansion values.
List of possible payment expansion values.
List of possible payment expansion values.
List of possible payment expansion values.
List of possible payment status values.
List of possible payment status values.
List of possible payment status values.
List of possible payment status values.
List of possible payment status values.
List of possible payment status values.
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

Address is a set of fields describing customer address.
APIError represents API error response.
Authorization is a model of entity.
No description provided by the author
AuthorizationClient is a client for work with Authorization entity.
AuthorizationParams is a set of params for creating entity.
No description provided by the author
Capture is a model of entity.
No description provided by the author
CaptureClient is a client for work with Capture entity.
CaptureParams is a set of params for creating entity.
Charge is a model of entity.
ChargeClient is a client for work with Charge entity.
ChargeParams is a set of params for creating entity.
Client contains API parameters and provides set of API entity clients.
ClientInfo represents optional request params for some methods.
No description provided by the author
No description provided by the author
CreditCardToken is a model of entity.
CreditCardTokenClient is a client for work with Token entity (type = credit_card).
CreditCardTokenParams is a set of params for creating entity.
Customer is a model of entity.
CustomerClient is a client for work with Customer entity.
CustomerParams is a set of params for creating and updating entity.
Contains information about the decision flow executed by the Decision Engine and the rules that were evaluated as payments pass through the flow.
No description provided by the author
Error represents possible client error.
IdentityDocument represents some identity document.
Installments is a set of options of installments.
Level 2 and Level 3 card data provides more information for business, commercial, corporate, purchasing, and government cardholders.
The line items of the order.
Payment is a model of entity.
No description provided by the author
PaymentClient is a client for work with Payment entity.
PaymentMethod is a entity model.
PaymentMethodClient is a client for work with PaymentMethod entity.
PaymentMethodDetails represents payment method details for POST requests.
PaymentNextAction represents action which may be performed on Payment entity.
PaymentOrder represents order description.
PaymentOrderLineItem represents one item of order.
PaymentParams is a set of params for creating and updating entity.
PaymentRelatedResources is a set of resources related to Payment.
Describes the results of the policy rules executed in the flow.
This object represents the configuration of the provider that handled the transaction, as defined in your PaymentsOS Control Center account.
ProviderData is a set of params describing payment provider.
ProviderDocument represents provider document.
Redirection is a entity model.
RedirectionClient is a client for work with Redirection entity.
Refund is a entity model.
No description provided by the author
RefundClient is a client for work with Refund entity.
RefundParams is a set of params for creating entity.
Result represents status and category of some methods response.
ThreeDSecureAttributes is a set of attributes for 3D-Secure.
No description provided by the author
nolint:maligned // third-party api struct.
No description provided by the author
No description provided by the author
Void is an entity model.
No description provided by the author
VoidClient is a client for work with Void entity.

# Interfaces

No description provided by the author
Caller makes HTTP call with given options and decode response into given struct.
HTTPClient is interface fot HTTP client.

# Type aliases

AdditionalDetails is a set of any custom key-value info.
No description provided by the author
No description provided by the author
No description provided by the author
ExpirationDate is credit card expiration date.
No description provided by the author
Option is a callback for redefine client parameters.
PaymentAction is a type of action performed on payment.
PaymentExpand is a type of "expand" param value, used while requesting payment.
PaymentStatus is a type of payment status.
No description provided by the author
No description provided by the author