Documentation ¶
Overview ¶
Package zooz contains Go client for Zooz API.
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
Index ¶
- Constants
- type APIError
- type AdditionalDetails
- type Address
- type Authorization
- type AuthorizationClient
- func (c *AuthorizationClient) Get(ctx context.Context, paymentID string, authorizationID string) (*Authorization, error)
- func (c *AuthorizationClient) GetList(ctx context.Context, paymentID string) ([]Authorization, error)
- func (c *AuthorizationClient) New(ctx context.Context, idempotencyKey string, paymentID string, ...) (*Authorization, error)
- type AuthorizationParams
- type Caller
- type Capture
- type CaptureClient
- func (c *CaptureClient) Get(ctx context.Context, paymentID string, captureID string) (*Capture, error)
- func (c *CaptureClient) GetList(ctx context.Context, paymentID string) ([]Capture, error)
- func (c *CaptureClient) New(ctx context.Context, idempotencyKey string, paymentID string, ...) (*Capture, error)
- type CaptureParams
- type Charge
- type ChargeClient
- type ChargeParams
- type Client
- func (c *Client) Authorization() *AuthorizationClient
- func (c *Client) Call(ctx context.Context, method, path string, headers map[string]string, ...) (callErr error)
- func (c *Client) Capture() *CaptureClient
- func (c *Client) Charge() *ChargeClient
- func (c *Client) Customer() *CustomerClient
- func (c *Client) Payment() *PaymentClient
- func (c *Client) PaymentMethod() *PaymentMethodClient
- func (c *Client) Redirection() *RedirectionClient
- func (c *Client) Refund() *RefundClient
- func (c *Client) Void() *VoidClient
- type ClientInfo
- type Customer
- type CustomerClient
- func (c *CustomerClient) Delete(ctx context.Context, id string) error
- func (c *CustomerClient) Get(ctx context.Context, id string) (*Customer, error)
- func (c *CustomerClient) New(ctx context.Context, idempotencyKey string, params *CustomerParams) (*Customer, error)
- func (c *CustomerClient) Update(ctx context.Context, id string, params *CustomerParams) (*Customer, error)
- type CustomerParams
- type Error
- type HTTPClient
- type IdentityDocument
- type Installments
- type Option
- type Payment
- type PaymentAction
- type PaymentClient
- func (c *PaymentClient) Get(ctx context.Context, id string, expands ...PaymentExpand) (*Payment, error)
- func (c *PaymentClient) New(ctx context.Context, idempotencyKey string, params *PaymentParams) (*Payment, error)
- func (c *PaymentClient) Update(ctx context.Context, id string, params *PaymentParams) (*Payment, error)
- type PaymentExpand
- type PaymentMethod
- type PaymentMethodClient
- func (c *PaymentMethodClient) Get(ctx context.Context, customerID string, token string) (*PaymentMethod, error)
- func (c *PaymentMethodClient) GetList(ctx context.Context, customerID string) ([]PaymentMethod, error)
- func (c *PaymentMethodClient) New(ctx context.Context, idempotencyKey string, customerID string, token string) (*PaymentMethod, error)
- type PaymentMethodDetails
- type PaymentMethodHref
- type PaymentNextAction
- type PaymentOrder
- type PaymentOrderLineItem
- type PaymentParams
- type PaymentRelatedResources
- type PaymentStatus
- type ProviderData
- type ProviderDocument
- type Redirection
- type RedirectionClient
- type Refund
- type RefundClient
- type RefundParams
- type Result
- type ThreeDSecureAttributes
- type Void
- type VoidClient
Constants ¶
const ( // EnvTest is a value for test environment header EnvTest env = "test" // EnvLive is a value for live environment header EnvLive env = "live" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct { Category string `json:"category"` Description string `json:"description"` MoreInfo string `json:"more_info"` }
APIError represents API error response. https://developers.paymentsos.com/docs/api#/introduction/responses/errors
type AdditionalDetails ¶
AdditionalDetails is a set of any custom key-value info.
type Address ¶
type Address struct { Country string `json:"country,omitempty"` State string `json:"state,omitempty"` City string `json:"city,omitempty"` Line1 string `json:"line1,omitempty"` Line2 string `json:"line2,omitempty"` ZipCode string `json:"zip_code,omitempty"` Title string `json:"title,omitempty"` FirstName string `json:"first_name,omitempty"` LastName string `json:"last_name,omitempty"` Phone string `json:"phone,omitempty"` Email string `json:"email,omitempty"` }
Address is a set of fields describing customer address.
type Authorization ¶
type Authorization struct { ID string `json:"id"` Result Result `json:"result"` Amount int64 `json:"amount"` Created json.Number `json:"created"` ReconciliationID string `json:"reconciliation_id"` PaymentMethod PaymentMethodHref `json:"payment_method"` ThreeDSecureAttributes *ThreeDSecureAttributes `json:"three_d_secure_attributes"` Installments *Installments `json:"installments"` ProviderData ProviderData `json:"provider_data"` ProviderSpecificData map[string]interface{} `json:"provider_specific_data"` OriginatingPurchaseCountry string `json:"originating_purchase_country"` IPAddress string `json:"ip_address"` Redirection *Redirection `json:"redirection"` }
Authorization is a model of entity.
type AuthorizationClient ¶
type AuthorizationClient struct {
Caller Caller
}
AuthorizationClient is a client for work with Authorization entity. https://developers.paymentsos.com/docs/api#/reference/authorizations
func (*AuthorizationClient) Get ¶
func (c *AuthorizationClient) Get(ctx context.Context, paymentID string, authorizationID string) (*Authorization, error)
Get returns Authorization entity.
func (*AuthorizationClient) GetList ¶
func (c *AuthorizationClient) GetList(ctx context.Context, paymentID string) ([]Authorization, error)
GetList returns list of all Authorizations for given payment ID.
func (*AuthorizationClient) New ¶
func (c *AuthorizationClient) New(ctx context.Context, idempotencyKey string, paymentID string, params *AuthorizationParams, clientInfo *ClientInfo) (*Authorization, error)
New creates new Authorization entity.
type AuthorizationParams ¶
type AuthorizationParams struct { PaymentMethod PaymentMethodDetails `json:"payment_method"` MerchantSiteURL string `json:"merchant_site_url,omitempty"` ReconciliationID string `json:"reconciliation_id,omitempty"` ThreeDSecureAttributes *ThreeDSecureAttributes `json:"three_d_secure_attributes,omitempty"` Installments *Installments `json:"installments,omitempty"` ProviderSpecificData map[string]interface{} `json:"provider_specific_data,omitempty"` }
AuthorizationParams is a set of params for creating entity.
type Caller ¶
type Caller interface {
Call(ctx context.Context, method, path string, headers map[string]string, reqObj interface{}, respObj interface{}) error
}
Caller makes HTTP call with given options and decode response into given struct. Client implements this interface and pass itself to entity clients. You may create entity clients with own caller for test purposes.
type Capture ¶
type Capture struct { CaptureParams ID string `json:"id"` Result Result `json:"result"` Created json.Number `json:"created"` ProviderData ProviderData `json:"provider_data"` }
Capture is a model of entity.
type CaptureClient ¶
type CaptureClient struct {
Caller Caller
}
CaptureClient is a client for work with Capture entity. https://developers.paymentsos.com/docs/api#/reference/captures
func (*CaptureClient) Get ¶
func (c *CaptureClient) Get(ctx context.Context, paymentID string, captureID string) (*Capture, error)
Get returns Capture entity.
func (*CaptureClient) New ¶
func (c *CaptureClient) New(ctx context.Context, idempotencyKey string, paymentID string, params *CaptureParams) (*Capture, error)
New creates new Capture entity.
type CaptureParams ¶
type CaptureParams struct { ReconciliationID string `json:"reconciliation_id,omitempty"` Amount int64 `json:"amount,omitempty"` }
CaptureParams is a set of params for creating entity.
type Charge ¶
type Charge struct { ID string `json:"id"` Result Result `json:"result"` Amount int64 `json:"amount"` Created json.Number `json:"created"` ReconciliationID string `json:"reconciliation_id"` PaymentMethod PaymentMethodHref `json:"payment_method"` ThreeDSecureAttributes *ThreeDSecureAttributes `json:"three_d_secure_attributes"` Installments *Installments `json:"installments"` ProviderData ProviderData `json:"provider_data"` ProviderSpecificData map[string]interface{} `json:"provider_specific_data"` OriginatingPurchaseCountry string `json:"originating_purchase_country"` IPAddress string `json:"ip_address"` Redirection *Redirection `json:"redirection"` }
Charge is a model of entity.
type ChargeClient ¶
type ChargeClient struct {
Caller Caller
}
ChargeClient is a client for work with Charge entity. https://developers.paymentsos.com/docs/api#/reference/charges
func (*ChargeClient) New ¶
func (c *ChargeClient) New(ctx context.Context, idempotencyKey string, paymentID string, params *ChargeParams, clientInfo *ClientInfo) (*Charge, error)
New creates new Charge entity.
type ChargeParams ¶
type ChargeParams struct { PaymentMethod PaymentMethodDetails `json:"payment_method"` MerchantSiteURL string `json:"merchant_site_url,omitempty"` ReconciliationID string `json:"reconciliation_id,omitempty"` ThreeDSecureAttributes *ThreeDSecureAttributes `json:"three_d_secure_attributes,omitempty"` Installments *Installments `json:"installments,omitempty"` ProviderSpecificData map[string]interface{} `json:"provider_specific_data,omitempty"` }
ChargeParams is a set of params for creating entity.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client contains API parameters and provides set of API entity clients.
func (*Client) Authorization ¶
func (c *Client) Authorization() *AuthorizationClient
Authorization creates client for work with corresponding entity.
func (*Client) Call ¶
func (c *Client) Call(ctx context.Context, method, path string, headers map[string]string, reqObj interface{}, respObj interface{}) (callErr error)
Call does HTTP request with given params using set HTTP client. Response will be decoded into respObj. Error may be returned if something went wrong. If API return error as response, then Call returns error of type zooz.Error.
func (*Client) Capture ¶
func (c *Client) Capture() *CaptureClient
Capture creates client for work with corresponding entity.
func (*Client) Charge ¶
func (c *Client) Charge() *ChargeClient
Charge creates client for work with corresponding entity.
func (*Client) Customer ¶
func (c *Client) Customer() *CustomerClient
Customer creates client for work with corresponding entity.
func (*Client) Payment ¶
func (c *Client) Payment() *PaymentClient
Payment creates client for work with corresponding entity.
func (*Client) PaymentMethod ¶
func (c *Client) PaymentMethod() *PaymentMethodClient
PaymentMethod creates client for work with corresponding entity.
func (*Client) Redirection ¶
func (c *Client) Redirection() *RedirectionClient
Redirection creates client for work with corresponding entity.
func (*Client) Refund ¶
func (c *Client) Refund() *RefundClient
Refund creates client for work with corresponding entity.
func (*Client) Void ¶
func (c *Client) Void() *VoidClient
Void creates client for work with corresponding entity.
type ClientInfo ¶
ClientInfo represents optional request params for some methods.
type Customer ¶
type Customer struct { CustomerParams ID string `json:"id"` Created json.Number `json:"created"` Modified json.Number `json:"modified"` PaymentMethods []PaymentMethod `json:"payment_methods"` }
Customer is a model of entity.
type CustomerClient ¶
type CustomerClient struct {
Caller Caller
}
CustomerClient is a client for work with Customer entity. https://developers.paymentsos.com/docs/api#/reference/customers
func (*CustomerClient) Delete ¶
func (c *CustomerClient) Delete(ctx context.Context, id string) error
Delete deletes Customer entity.
func (*CustomerClient) New ¶
func (c *CustomerClient) New(ctx context.Context, idempotencyKey string, params *CustomerParams) (*Customer, error)
New creates new Customer entity.
func (*CustomerClient) Update ¶
func (c *CustomerClient) Update(ctx context.Context, id string, params *CustomerParams) (*Customer, error)
Update updates Customer entity with given params and return updated Customer entity.
type CustomerParams ¶
type CustomerParams struct { CustomerReference string `json:"customer_reference"` FirstName string `json:"first_name,omitempty"` LastName string `json:"last_name,omitempty"` Email string `json:"email,omitempty"` AdditionalDetails AdditionalDetails `json:"additional_details,omitempty"` ShippingAddress *Address `json:"shipping_address,omitempty"` }
CustomerParams is a set of params for creating and updating entity.
type HTTPClient ¶
HTTPClient is interface fot HTTP client. Built-in net/http.Client implements this interface as well.
type IdentityDocument ¶
IdentityDocument represents some identity document.
type Installments ¶
type Installments struct { NumberOfInstallments int64 `json:"number_of_installments"` FirstPaymentAmount int64 `json:"first_payment_amount"` RemainingPaymentsAmount int64 `json:"remaining_payments_amount"` }
Installments is a set of options of installments.
type Option ¶
type Option func(*Client)
Option is a callback for redefine client parameters.
func OptHTTPClient ¶
func OptHTTPClient(httpClient HTTPClient) Option
OptHTTPClient returns option with given HTTP client.
func OptPrivateKey ¶
OptPrivateKey returns option with given private key.
type Payment ¶
type Payment struct { PaymentParams ID string `json:"id"` Created json.Number `json:"created"` Modified json.Number `json:"modified"` Status PaymentStatus `json:"status"` PossibleNextActions []PaymentNextAction `json:"possible_next_actions"` // Expansions PaymentMethod *PaymentMethodHref `json:"payment_method"` Customer *Customer `json:"customer"` RelatedResources *PaymentRelatedResources `json:"related_resources"` }
Payment is a model of entity.
type PaymentAction ¶
type PaymentAction string
PaymentAction is a type of action performed on payment
const ( PaymentActionAuthorize PaymentAction = "Authorize" PaymentActionCharge PaymentAction = "Charge" PaymentActionCapture PaymentAction = "Capture" PaymentActionRefund PaymentAction = "Refund" PaymentActionVoid PaymentAction = "Void" PaymentActionUpdatePayment PaymentAction = "Update Payment" )
List of possible payment action values.
type PaymentClient ¶
type PaymentClient struct {
Caller Caller
}
PaymentClient is a client for work with Payment entity. https://developers.paymentsos.com/docs/api#/reference/payments
func (*PaymentClient) Get ¶
func (c *PaymentClient) Get(ctx context.Context, id string, expands ...PaymentExpand) (*Payment, error)
Get returns Payment entity with optional expansions. You may specify any number of expansion or use zooz.PaymentExpandAll for expand payments with all expansions.
func (*PaymentClient) New ¶
func (c *PaymentClient) New(ctx context.Context, idempotencyKey string, params *PaymentParams) (*Payment, error)
New creates new Payment entity.
func (*PaymentClient) Update ¶
func (c *PaymentClient) Update(ctx context.Context, id string, params *PaymentParams) (*Payment, error)
Update changes Payment entity and returned updated entity. Payment details can only be updated if no other action has been performed on the Payment resource. Note: In addition to the fields that you want to update, you must re-send all the other original argument fields, because this operation replaces the Payment resource.
type PaymentExpand ¶
type PaymentExpand string
PaymentExpand is a type of "expand" param value, used while requesting payment
const ( PaymentExpandAuthorizations PaymentExpand = "authorizations" PaymentExpandRedirections PaymentExpand = "redirections" PaymentExpandCaptures PaymentExpand = "captures" PaymentExpandRefunds PaymentExpand = "refunds" PaymentExpandVoids PaymentExpand = "voids" PaymentExpandCredits PaymentExpand = "credits" PaymentExpandCustomer PaymentExpand = "customer" PaymentExpandPaymentMethod PaymentExpand = "payment_method" PaymentExpandAll PaymentExpand = "all" )
List of possible payment expansion values.
type PaymentMethod ¶
type PaymentMethod struct { Type string `json:"type"` TokenType string `json:"token_type"` PassLuhnValidation bool `json:"pass_luhn_validation"` Token string `json:"token"` Created json.Number `json:"created"` Customer string `json:"customer"` AdditionalDetails AdditionalDetails `json:"additional_details"` BinNumber json.Number `json:"bin_number"` Vendor string `json:"vendor"` Issuer string `json:"issuer"` CardType string `json:"card_type"` Level string `json:"level"` CountryCode string `json:"country_code"` HolderName string `json:"holder_name"` ExpirationDate string `json:"expiration_date"` Last4Digits string `json:"last_4_digits"` IdentityDocument *IdentityDocument `json:"identity_document"` BillingAddress *Address `json:"billing_address"` }
PaymentMethod is a entity model.
type PaymentMethodClient ¶
type PaymentMethodClient struct {
Caller Caller
}
PaymentMethodClient is a client for work with PaymentMethod entity. https://developers.paymentsos.com/docs/api#/reference/payment-methods
func (*PaymentMethodClient) Get ¶
func (c *PaymentMethodClient) Get(ctx context.Context, customerID string, token string) (*PaymentMethod, error)
Get returns PaymentMethod entity by customer ID and token.
func (*PaymentMethodClient) GetList ¶
func (c *PaymentMethodClient) GetList(ctx context.Context, customerID string) ([]PaymentMethod, error)
GetList returns list of PaymentMethods for given customer.
func (*PaymentMethodClient) New ¶
func (c *PaymentMethodClient) New(ctx context.Context, idempotencyKey string, customerID string, token string) (*PaymentMethod, error)
New creates new PaymentMethod entity.
type PaymentMethodDetails ¶
type PaymentMethodDetails struct { Type string `json:"type"` Token string `json:"token,omitempty"` CreditCardCvv string `json:"credit_card_cvv,omitempty"` SourceType string `json:"source_type,omitempty"` Vendor string `json:"vendor,omitempty"` AdditionalDetails AdditionalDetails `json:"additional_details,omitempty"` }
PaymentMethodDetails represents payment method details for POST requests.
type PaymentMethodHref ¶
type PaymentMethodHref struct { Href string `json:"href"` PaymentMethod *PaymentMethod `json:"payment_method"` }
PaymentMethodHref wraps PaymentMethod with associated href.
type PaymentNextAction ¶
type PaymentNextAction struct { Action PaymentAction `json:"action"` Href string `json:"href"` }
PaymentNextAction represents action which may be performed on Payment entity.
type PaymentOrder ¶
type PaymentOrder struct { ID string `json:"id,omitempty"` AdditionalDetails AdditionalDetails `json:"additional_details,omitempty"` TaxAmount int64 `json:"tax_amount,omitempty"` TaxPercentage int64 `json:"tax_percentage,omitempty"` LineItems []PaymentOrderLineItem `json:"line_items,omitempty"` }
PaymentOrder represents order description.
type PaymentOrderLineItem ¶
type PaymentOrderLineItem struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Quantity int64 `json:"quantity,omitempty"` UnitPrice int64 `json:"unit_price,omitempty"` }
PaymentOrderLineItem represents one item of order.
type PaymentParams ¶
type PaymentParams struct { Amount int64 `json:"amount"` Currency string `json:"currency"` CustomerID string `json:"customer_id,omitempty"` AdditionalDetails AdditionalDetails `json:"additional_details,omitempty"` StatementSoftDescriptor string `json:"statement_soft_descriptor,omitempty"` Order *PaymentOrder `json:"order,omitempty"` ShippingAddress *Address `json:"shipping_address,omitempty"` BillingAddress *Address `json:"billing_address,omitempty"` }
PaymentParams is a set of params for creating and updating entity.
type PaymentRelatedResources ¶
type PaymentRelatedResources struct { Authorizations []Authorization `json:"authorizations"` Charges []Charge `json:"charges"` Voids []Void `json:"voids"` Redirections []Redirection `json:"redirections"` Captures []Capture `json:"captures"` Refunds []Refund `json:"refunds"` }
PaymentRelatedResources is a set of resources related to Payment.
type PaymentStatus ¶
type PaymentStatus string
PaymentStatus is a type of payment status
const ( PaymentStatusInitialized PaymentStatus = "Initialized" PaymentStatusPending PaymentStatus = "Pending" PaymentStatusAuthorized PaymentStatus = "Authorized" PaymentStatusCaptured PaymentStatus = "Captured" PaymentStatusRefunded PaymentStatus = "Refunded" PaymentStatusVoided PaymentStatus = "Voided" )
List of possible payment status values.
type ProviderData ¶
type ProviderData struct { ProviderName string `json:"provider_name"` ResponseCode string `json:"response_code"` Description string `json:"description"` RawResponse string `json:"raw_response"` AvsCode string `json:"avs_code"` AuthorizationCode string `json:"authorization_code"` TransactionID string `json:"transaction_id"` ExternalID string `json:"external_id"` Documents []ProviderDocument `json:"documents"` AdditionalInformation map[string]string `json:"additional_information"` }
ProviderData is a set of params describing payment provider.
type ProviderDocument ¶
type ProviderDocument struct { Descriptor string `json:"descriptor"` ContentType string `json:"content_type"` Href string `json:"href"` }
ProviderDocument represents provider document.
type Redirection ¶
type Redirection struct { ID string `json:"id"` Created json.Number `json:"created"` MerchantSiteURL string `json:"merchant_site_url"` URL string `json:"url"` }
Redirection is a entity model.
type RedirectionClient ¶
type RedirectionClient struct {
Caller Caller
}
RedirectionClient is a client for work with Redirection entity. https://developers.paymentsos.com/docs/api#/reference/redirections
func (*RedirectionClient) Get ¶
func (c *RedirectionClient) Get(ctx context.Context, paymentID string, redirectionID string) (*Redirection, error)
Get creates new Redirection entity.
func (*RedirectionClient) GetList ¶
func (c *RedirectionClient) GetList(ctx context.Context, paymentID string) ([]Redirection, error)
GetList returns a list of Redirections for given payment.
type Refund ¶
type Refund struct { RefundParams ID string `json:"id"` Result Result `json:"result"` Created json.Number `json:"created"` ProviderData ProviderData `json:"provider_data"` }
Refund is a entity model.
type RefundClient ¶
type RefundClient struct {
Caller Caller
}
RefundClient is a client for work with Refund entity. https://developers.paymentsos.com/docs/api#/reference/refunds
func (*RefundClient) New ¶
func (c *RefundClient) New(ctx context.Context, idempotencyKey string, paymentID string, params *RefundParams) (*Refund, error)
New creates new Refund entity.
type RefundParams ¶
type RefundParams struct { ReconciliationID string `json:"reconciliation_id,omitempty"` Amount int64 `json:"amount,omitempty"` CaptureID string `json:"capture_id,omitempty"` Reason string `json:"reason,omitempty"` }
RefundParams is a set of params for creating entity.
type Result ¶
type Result struct { Status string `json:"status"` Category string `json:"category"` SubCategory string `json:"sub_category"` Description string `json:"description"` }
Result represents status and category of some methods response.
type ThreeDSecureAttributes ¶
type ThreeDSecureAttributes struct { Encoding string `json:"encoding"` XID string `json:"xid"` CAVV string `json:"cavv"` EciFlag string `json:"eci_flag"` }
ThreeDSecureAttributes is a set of attributes for 3D-Secure.
type Void ¶
type Void struct { ID string `json:"id"` Result Result `json:"result"` Created json.Number `json:"created"` ProviderData ProviderData `json:"provider_data"` }
Void is an entity model.
type VoidClient ¶
type VoidClient struct {
Caller Caller
}
VoidClient is a client for work with Void entity. https://developers.paymentsos.com/docs/api#/reference/voids