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
- func CalculateWebhookSignature(ctx context.Context, reqBody []byte, reqHeader http.Header, ...) (string, error)
- func ParseCardExpirationDate(expirationDate string) (m, y int, err error)
- type APIError
- type AdditionalDetails
- type Address
- type AuthType
- type AuthenticationDataCollectionValue
- type Authorization
- type AuthorizationCallback
- type AuthorizationClient
- func (c *AuthorizationClient) ContinueAuthentication(ctx context.Context, idempotencyKey string, ...) (*Authorization, error)
- 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 COFTransactionIndicators
- type Callback
- type CallbackCommon
- type Caller
- type Capture
- type CaptureCallback
- 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) CreditCardToken() *CreditCardTokenClient
- 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 ContinueAuthenticationParams
- type CreditCardToken
- type CreditCardTokenClient
- type CreditCardTokenParams
- 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) GetByReference(ctx context.Context, reference 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 DecisionEngineExecution
- type DecodedJSON
- type ErrBadRequest
- type Error
- type ExpirationDate
- type FixedPrivateKeyProvider
- type HTTPClient
- type IdentityDocument
- type Installments
- type Level23
- type LevelLineItem
- type Option
- type Payment
- type PaymentAction
- type PaymentCallback
- 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) Delete(ctx context.Context, customerID string, token string) error
- 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 PaymentNextAction
- type PaymentOrder
- type PaymentOrderLineItem
- type PaymentParams
- type PaymentRelatedResources
- type PaymentStatus
- type PolicyResult
- type PrivateKeyProviderFunc
- type ProviderConfiguration
- type ProviderData
- type ProviderDocument
- type Redirection
- type RedirectionClient
- type Refund
- type RefundCallback
- type RefundClient
- type RefundParams
- type Result
- type ThreeDSecureAttributes
- type ThreeDSecureAttributesExternal
- type ThreeDSecureAttributesInternal
- type ThreeDSecureResult
- type ThreeDSecureScaExemptions
- type TokenType
- type Void
- type VoidCallback
- type VoidClient
Examples ¶
Constants ¶
const ( // ApiURL is default base url to send requests. It May be changed with OptApiURL ApiURL = "https://api.paymentsos.com" // 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 ¶
func CalculateWebhookSignature ¶ added in v1.3.0
func CalculateWebhookSignature(ctx context.Context, reqBody []byte, reqHeader http.Header, keyProvider privateKeyProvider) (string, error)
CalculateWebhookSignature calculates signature for webhook request (without "sig1=" prefix). Generally, you would compare it to "signature" request header sent by PaymentsOS:
signature, _ := CalculateWebhookSignature(...) if "sig1=" + signature == r.Header.Get("signature") { // webhook request is valid }
reqBody should be a raw webhook http request body. reqHeader should be webhook http request headers (currently only 'event-type' header matters). Will return ErrBadRequest{} if error is permanent and should not be retried (malformed json body, unknown app_id) Also used by DecodeWebhookRequest.
Example ¶
keyProvider := zooz.FixedPrivateKeyProvider{"app-id": []byte("my-private-key")} _ = http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { body, _ := ioutil.ReadAll(r.Body) signature, _ := zooz.CalculateWebhookSignature(r.Context(), body, r.Header, keyProvider) if "sig1="+signature == r.Header.Get("signature") { fmt.Print("Request signature is valid") } else { fmt.Print("Request signature is invalid") } })
func ParseCardExpirationDate ¶ added in v1.8.4
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 AuthenticationDataCollectionValue ¶ added in v1.7.0
type AuthenticationDataCollectionValue string
const ( AuthenticationDataCollectionCompleted AuthenticationDataCollectionValue = "Y" AuthenticationDataCollectionNotCompleted AuthenticationDataCollectionValue = "N" )
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 PaymentMethod `json:"payment_method"` ThreeDSecureAttributes *ThreeDSecureAttributes `json:"three_d_secure_attributes"` Installments *Installments `json:"installments"` ProviderData ProviderData `json:"provider_data"` ProviderSpecificData DecodedJSON `json:"provider_specific_data"` ProviderConfiguration ProviderConfiguration `json:"provider_configuration"` OriginatingPurchaseCountry string `json:"originating_purchase_country"` IPAddress string `json:"ip_address"` Redirection *Redirection `json:"redirection"` AdditionalDetails AdditionalDetails `json:"additional_details"` DecisionEngineExecution DecisionEngineExecution `json:"decision_engine_execution"` }
Authorization is a model of entity.
type AuthorizationCallback ¶ added in v1.3.0
type AuthorizationCallback struct { CallbackCommon Data Authorization `json:"data"` }
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) ContinueAuthentication ¶ added in v1.7.0
func (c *AuthorizationClient) ContinueAuthentication(ctx context.Context, idempotencyKey string, params ContinueAuthenticationParams, clientInfo *ClientInfo) (*Authorization, error)
ContinueAuthentication continues the authentication flow for the specified payment ID and authorization ID. Returns auth struct if everything is ok, and error when continue flow failed
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"` AdditionalDetails map[string]string `json:"additional_details,omitempty"` COFTransactionIndicators *COFTransactionIndicators `json:"cof_transaction_indicators,omitempty"` AuthType AuthType `json:"authorization_type,omitempty"` }
AuthorizationParams is a set of params for creating entity.
type COFTransactionIndicators ¶ added in v1.2.2
type Callback ¶ added in v1.3.0
type Callback interface {
// contains filtered or unexported methods
}
func DecodeWebhookRequest ¶ added in v1.3.0
func DecodeWebhookRequest(ctx context.Context, body []byte, header http.Header, keyProvider privateKeyProvider) (Callback, error)
DecodeWebhookRequest decodes PaymentsOS webhook http request into callback entity. Supports webhook version >= 1.2.0 reqBody should be a raw webhook http request body. reqHeader should be webhook http request headers.
Use type switch to determine concrete callback entity. Returned callback entity is a value, never a pointer (i.e. AuthorizationCallback, not *AuthorizationCallback).
cb, _ := DecodeWebhookRequest(...) switch cb := cb.(type) { case zooz.AuthorizationCallback: case zooz.CaptureCallback: ... }
Will return ErrBadRequest if the error is permanent and request should not be retried. Bear in mind that your webhook handler should respond with 2xx status code anyway, otherwise PaymentsOS will continue resending this request. ErrBadRequest errors include:
- wrong body format (broken/invalid json, ...)
- validation error (missing required fields or headers, unexpected values)
- unknown business unit (app_id)
- incorrect request signature
Example ¶
keyProvider := zooz.FixedPrivateKeyProvider{"app-id": []byte("my-private-key")} _ = http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { body, _ := ioutil.ReadAll(r.Body) cb, err := zooz.DecodeWebhookRequest(r.Context(), body, r.Header, keyProvider) if err != nil { if errors.As(err, &zooz.ErrBadRequest{}) { // Invalid request. We don't want PaymentsOS to resend it, so respond with 2xx code. rw.WriteHeader(200) } else { // Temporary problem. rw.WriteHeader(500) } return } switch cb := cb.(type) { case zooz.AuthorizationCallback: fmt.Printf("authorization: %+v", cb.Data) case zooz.CaptureCallback: fmt.Printf("capture: %+v", cb.Data) } rw.WriteHeader(200) })
type CallbackCommon ¶ added in v1.3.0
type CallbackCommon struct { EventType string `json:"-"` // The type of resource that triggered the event. For example, "payment.authorization.create". Returned in "event-type" header. XPaymentsOSEnv string `json:"-"` // PaymentsOS environment, 'live' or 'test'. Returned in "x-payments-os-env" header. XZoozRequestID string `json:"-"` // The ID of the original request that triggered the webhook event. Returned in "x-zooz-request-id" header. ID string `json:"id"` // The Webhook id. This id is unique per Webhook and can be used to validate that the request is unique. Created time.Time `json:"created"` // The date and time the event was created. "2018-10-03T04:58:35.385Z". AccountID string `json:"account_id"` AppID string `json:"app_id"` PaymentID string `json:"payment_id"` }
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"` ProviderSpecificData DecodedJSON `json:"provider_specific_data"` Level23 Level23 `json:"level_2_3"` ProviderConfiguration ProviderConfiguration `json:"provider_configuration"` AdditionalDetails AdditionalDetails `json:"additional_details"` }
Capture is a model of entity.
type CaptureCallback ¶ added in v1.3.0
type CaptureCallback struct { CallbackCommon Data Capture `json:"data"` }
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 PaymentMethod `json:"payment_method"` ThreeDSecureAttributes *ThreeDSecureAttributes `json:"three_d_secure_attributes"` Installments *Installments `json:"installments"` ProviderData ProviderData `json:"provider_data"` ProviderSpecificData DecodedJSON `json:"provider_specific_data"` OriginatingPurchaseCountry string `json:"originating_purchase_country"` IPAddress string `json:"ip_address"` Redirection *Redirection `json:"redirection"` ProviderConfiguration ProviderConfiguration `json:"provider_configuration"` AdditionalDetails AdditionalDetails `json:"additional_details"` DecisionEngineExecution DecisionEngineExecution `json:"decision_engine_execution"` }
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) CreditCardToken ¶ added in v1.6.0
func (c *Client) CreditCardToken() *CreditCardTokenClient
CreditCardToken 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 ContinueAuthenticationParams ¶ added in v1.7.0
type ContinueAuthenticationParams struct { PaymentID string AuthorizationID string ReconciliationID string DataCollectionCompletedInd AuthenticationDataCollectionValue }
type CreditCardToken ¶ added in v1.6.0
type CreditCardToken struct { TokenType TokenType `json:"token_type"` // State - Enum: "valid" "created" "used" "assigned". // Reflects the token's usage. The state can be one of the following: // * valid: token has been successfully created and can be used. Only applies to tokens created in API version 1.1.0 or below. // * created: token has been successfully created but has not yet been used or assigned to a customer. // * used: token has been used in a successful authorize or charge request. // * assigned: the token is assigned to a customer. The token will remain in this state also if it is used in a new authorize or charge request. State string `json:"state"` // PassLuhnValidation - When token_type is credit_card, then this indicates if the credit card number passed the Luhn validation. PassLuhnValidation bool `json:"pass_luhn_validation"` // BinNumber - The initial four to six numbers that appear on the card. BinNumber string `json:"bin_number"` // Vendor - The name of the credit card corporation. Vendor string `json:"vendor"` // Issuer - The name of the bank that issued the card. Issuer string `json:"issuer"` // TODO: WTF? in the API docs it is issuer_name, but actually it is issuer // CardType - The type of card. CardType string `json:"card_type"` // Level - The level of benefits or services available with the card. Level string `json:"level"` // CountryCode - The 3-letter country code defined in ISO 3166-1 alpha-3 format, identifying the country in which the card was issued. CountryCode string `json:"country_code"` // HolderName - Name of the credit card holder. HolderName string `json:"holder_name"` // Credit card expiration date. ExpirationDate ExpirationDate `json:"expiration_date"` // Masked credit card number (last four digits) of the card associated with the PaymentsOS token. Last4Digits string `json:"last_4_digits"` // Token - Depending on the `token_type`, the token represents one of the following: // a customer's credit card number, the card cvv code or a billing agreement. Token string `json:"token"` // Created - <timestamp> The date and time that the token was created. Created string `json:"created"` // Type - Value: "tokenized". Depending on the `token_type`, this field represents either // the card's or billing agreement's representation as it will be used in an authorization or charge request. Type string `json:"type"` // EncryptedCVV - <missing in API docs> // Returned only for new token creation. And only if `credit_card_cvv` was sent. // Expires after three hours. EncryptedCVV string `json:"encrypted_cvv"` }
CreditCardToken is a model of entity.
type CreditCardTokenClient ¶ added in v1.6.0
type CreditCardTokenClient struct {
Caller Caller
}
CreditCardTokenClient is a client for work with Token entity (type = credit_card). https://developers.paymentsos.com/docs/api#/reference/tokens
func (*CreditCardTokenClient) Get ¶ added in v1.6.0
func (c *CreditCardTokenClient) Get(ctx context.Context, token string) (*CreditCardToken, error)
Get returns Token entity.
func (*CreditCardTokenClient) New ¶ added in v1.6.0
func (c *CreditCardTokenClient) New(ctx context.Context, idempotencyKey string, params *CreditCardTokenParams) (*CreditCardToken, error)
New creates new Token entity (type = credit_card).
type CreditCardTokenParams ¶ added in v1.6.0
type CreditCardTokenParams struct { // HolderName - Name of the credit card holder. HolderName string `json:"holder_name"` // ExpirationDate - ^(0[1-9]|1[0-2])(\/|\-|\.| )\d{2,4} Credit card expiration date. // Possible formats: mm-yyyy, mm-yy, mm.yyyy, mm.yy, mm/yy, mm/yyyy, mm yyyy, or mm yy. ExpirationDate string `json:"expiration_date,omitempty"` // IdentityDocument - National identity document of the card holder. IdentityDocument *IdentityDocument `json:"identity_document,omitempty"` // CardNumber - \d{8}|\d{12,19} Credit card number. CardNumber string `json:"card_number"` ShippingAddress *Address `json:"shipping_address,omitempty"` BillingAddress *Address `json:"billing_address,omitempty"` AdditionalDetails AdditionalDetails `json:"additional_details,omitempty"` // CreditCardCVV - The CVV number on the card (3 or 4 digits) to be encrypted. // Sending this field returns an encrypted_cvv field, which expires after three hours. CreditCardCVV string `json:"credit_card_cvv,omitempty"` }
CreditCardTokenParams is a set of params for creating entity.
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"` Href string `json:"href"` }
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) GetByReference ¶ added in v1.4.0
GetByReference returns Customer entity by reference.
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 DecisionEngineExecution ¶ added in v1.3.1
type DecisionEngineExecution struct { ID string `json:"id"` Created string `json:"created"` FlowID string `json:"flow_id"` Status string `json:"status"` PolicyResults []PolicyResult `json:"policy_results"` }
Contains information about the decision flow executed by the Decision Engine and the rules that were evaluated as payments pass through the flow. Read more about the Decision Engine in the PaymentsOS developer guide.
type DecodedJSON ¶ added in v1.3.1
type DecodedJSON map[string]interface{}
func (*DecodedJSON) UnmarshalJSON ¶ added in v1.3.1
func (d *DecodedJSON) UnmarshalJSON(data []byte) error
UnmarshalJSON is called when the function json.Unmarshal is called.
type ErrBadRequest ¶ added in v1.3.0
type ErrBadRequest struct {
Err error
}
func (ErrBadRequest) Error ¶ added in v1.3.0
func (e ErrBadRequest) Error() string
func (ErrBadRequest) Unwrap ¶ added in v1.3.0
func (e ErrBadRequest) Unwrap() error
type ExpirationDate ¶ added in v1.8.4
type ExpirationDate string
ExpirationDate is credit card expiration date. Possible formats: mm-yyyy, mm-yy, mm.yyyy, mm.yy, mm/yy, mm/yyyy, mm yyyy, or mm yy.
Ivan: seems that PaymentsOS always normalizes it to mm/yyyy format when returning.
func (ExpirationDate) Parse ¶ added in v1.8.4
func (e ExpirationDate) Parse() (month, year int, err error)
type FixedPrivateKeyProvider ¶ added in v1.3.0
func (FixedPrivateKeyProvider) PrivateKey ¶ added in v1.3.0
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 Level23 ¶ added in v1.3.1
type Level23 struct { OrderID json.RawMessage `json:"id"` TaxMode string `json:"tax_mode"` TaxAmount int64 `json:"tax_amount"` ShippingAmount int64 `json:"shipping_amount"` FromShippingZipCode string `json:"from_shipping_zip_code"` DutyAmount int64 `json:"duty_amount"` DiscountAmount int64 `json:"discount_amount"` LineItems []LevelLineItem `json:"line_items"` ShippingAddress *Address `json:"shipping_address"` }
Level 2 and Level 3 card data provides more information for business, commercial, corporate, purchasing, and government cardholders. Credit card transactions submitted with Level 2 and Level 3 card data can obtain lower interchange rates and thus provide you with a lower processing cost.
type LevelLineItem ¶ added in v1.3.1
type LevelLineItem struct { Name string `json:"name"` ID string `json:"id"` Quantity int `json:"quantity"` UnitPrice int64 `json:"unit_price"` CommodityCode string `json:"commodity_code"` UnitOfMeasure string `json:"unit_of_measure"` TaxMode string `json:"tax_mode"` TaxAmount int64 `json:"tax_amount"` TaxPercentage decimal.Decimal `json:"tax_percentage"` DiscountAmount int64 `json:"discount_amount"` DiscountPercentage decimal.Decimal `json:"discount_percentage"` SubTotal int64 `json:"sub_total"` }
The line items of the order.
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.
func OptPublicKey ¶ added in v1.6.0
OptPublicKey returns option with given public 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 *PaymentMethod `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 PaymentCallback ¶ added in v1.3.0
type PaymentCallback struct { CallbackCommon Data Payment `json:"data"` }
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 { Href string `json:"href"` 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 string `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 ExpirationDate `json:"expiration_date"` Last4Digits string `json:"last_4_digits"` ShippingAddress *Address `json:"shipping_address"` BillingAddress *Address `json:"billing_address"` FingerPrint string `json:"fingerprint"` State string `json:"state"` }
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 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. Note that order fields required for level 2 and 3 data, must be passed separately in a Create Capture request within a level_2_3 object (fields passed in the order object only are not recognized as level 2 and 3 data fields).
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"` }
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 PolicyResult ¶ added in v1.3.1
type PolicyResult struct { Type string `json:"type"` ProviderName string `json:"provider_name"` ProviderConfiguration string `json:"provider_configuration"` Name string `json:"name"` ExecutionTime string `json:"execution_time"` Transaction string `json:"transaction"` Result string `json:"result"` }
Describes the results of the policy rules executed in the flow.
type PrivateKeyProviderFunc ¶ added in v1.3.0
func (PrivateKeyProviderFunc) PrivateKey ¶ added in v1.3.0
type ProviderConfiguration ¶ added in v1.3.1
type ProviderConfiguration struct { ID string `json:"id"` Name string `json:"name"` Description string `json:"description"` Created string `json:"created"` Modified string `json:"modified"` ProviderID string `json:"provider_id"` Type string `json:"type"` AccountID string `json:"account_id"` Href string `json:"href"` }
This object represents the configuration of the provider that handled the transaction, as defined in your PaymentsOS Control Center account. Note that the object does not include your provider authentication credentials.
type ProviderData ¶
type ProviderData struct { ProviderName string `json:"provider_name"` ResponseCode string `json:"response_code"` Description string `json:"description"` RawResponse DecodedJSON `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"` NetworkTransactionID string `json:"network_transaction_id"` ThreeDSecureResult ThreeDSecureResult `json:"three_d_secure_result"` }
ProviderData is a set of params describing payment provider.
type ProviderDocument ¶
type ProviderDocument struct { Descriptor string `json:"descriptor"` ContentType string `json:"content_type"` Content string `json:"content"` 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"` OperationType string `json:"operation_type"` }
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"` AdditionalDetails AdditionalDetails `json:"additional_details"` ProviderConfiguration ProviderConfiguration `json:"provider_configuration"` }
Refund is a entity model.
type RefundCallback ¶ added in v1.3.0
type RefundCallback struct { CallbackCommon Data Refund `json:"data"` }
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 { External *ThreeDSecureAttributesExternal `json:"external,omitempty"` Internal *ThreeDSecureAttributesInternal `json:"internal,omitempty"` ScaExemptions *ThreeDSecureScaExemptions `json:"sca_exemptions,omitempty"` }
ThreeDSecureAttributes is a set of attributes for 3D-Secure.
type ThreeDSecureAttributesExternal ¶ added in v1.7.0
type ThreeDSecureAttributesExternal struct { ThreeDSecureVersion string `json:"three_d_secure_version,omitempty"` ThreeDSecureAuthenticationStatus string `json:"three_d_secure_authentication_status,omitempty"` XID string `json:"xid,omitempty"` DsXID string `json:"ds_xid,omitempty"` Encoding string `json:"encoding,omitempty"` CAVV string `json:"cavv,omitempty"` ECIFlag string `json:"eci_flag,omitempty"` AuthenticationID string `json:"authentication_id,omitempty"` }
type ThreeDSecureAttributesInternal ¶ added in v1.7.0
type ThreeDSecureAttributesInternal struct { ThreeDSecureServerTransactionID string `json:"three_d_secure_server_transaction_id,omitempty"` DataCollectionCompletedInd string `json:"data_collection_completed_ind,omitempty"` DeviceChannel string `json:"device_channel,omitempty"` WorkPhone string `json:"work_phone,omitempty"` MobilePhone string `json:"mobile_phone,omitempty"` HomePhone string `json:"home_phone,omitempty"` MobilePhoneCountry string `json:"mobile_phone_country,omitempty"` HomePhoneCountry string `json:"home_phone_country,omitempty"` WorkPhoneCountry string `json:"work_phone_country,omitempty"` AddressMatch *bool `json:"address_match,omitempty"` ProductCode string `json:"product_code,omitempty"` ShippingMethodIndicator string `json:"shipping_method_indicator,omitempty"` DeliveryTimeFrame string `json:"delivery_time_frame,omitempty"` ReorderIndicator string `json:"reorder_indicator,omitempty"` PreOrderIndicator string `json:"pre_order_indicator,omitempty"` PreOrderDate string `json:"pre_order_date,omitempty"` AccountAgeIndicator string `json:"account_age_indicator,omitempty"` AccountCreateDate string `json:"account_create_date,omitempty"` AccountChangeIndicator string `json:"account_change_indicator,omitempty"` AccountChangeDate string `json:"account_change_date,omitempty"` AccountPwdChangeIndicator string `json:"account_pwd_change_indicator,omitempty"` AccountPwdChangeDate string `json:"account_pwd_change_date,omitempty"` AccountAdditionalInformation string `json:"account_additional_information,omitempty"` ShippingAddressUsageIndicator string `json:"shipping_address_usage_indicator,omitempty"` ShippingAddressUsageDate string `json:"shipping_address_usage_date,omitempty"` TransactionCountDay string `json:"transaction_count_day,omitempty"` TransactionCountYear string `json:"transaction_count_year,omitempty"` AddCardAttemptsDay string `json:"add_card_attempts_day,omitempty"` AccountPurchasesSixMonths string `json:"account_purchases_six_months,omitempty"` FraudActivity string `json:"fraud_activity,omitempty"` ShippingNameIndicator string `json:"shipping_name_indicator,omitempty"` PaymentAccountIndicator string `json:"payment_account_indicator,omitempty"` PaymentAccountAge string `json:"payment_account_age,omitempty"` RequestorAuthenticationMethod string `json:"requestor_authentication_method,omitempty"` RequestorAuthenticationTimestamp string `json:"requestor_authentication_timestamp,omitempty"` PriorAuthenticationData string `json:"prior_authentication_data,omitempty"` PriorAuthenticationMethod string `json:"prior_authentication_method,omitempty"` PriorAuthenticationTimestamp string `json:"prior_authentication_timestamp,omitempty"` PriorAuthenticationRef string `json:"prior_authentication_ref,omitempty"` PurchaseDateTime string `json:"purchase_date_time,omitempty"` RecurringEndDate string `json:"recurring_end_date,omitempty"` RecurringFrequency string `json:"recurring_frequency,omitempty"` BrowserHeader string `json:"browser_header,omitempty"` BrowserJavaEnabled *bool `json:"browser_java_enabled,omitempty"` BrowserLanguage string `json:"browser_language,omitempty"` BrowserColorDepth string `json:"browser_color_depth,omitempty"` BrowserScreenHeight string `json:"browser_screen_height,omitempty"` BrowserScreenWidth string `json:"browser_screen_width,omitempty"` BrowserTimeZone string `json:"browser_time_zone,omitempty"` ChallengeIndicator string `json:"challenge_indicator,omitempty"` ChallengeWindowSize string `json:"challenge_window_size,omitempty"` RequestorAuthenticationData string `json:"requestor_authentication_data,omitempty"` SdkAppID string `json:"sdk_app_id,omitempty"` SdkEncryptedData string `json:"sdk_encrypted_data,omitempty"` SdkMaxTimeout string `json:"sdk_max_timeout,omitempty"` SdkReferenceNumber string `json:"sdk_reference_number,omitempty"` SdkTransactionID string `json:"sdk_transaction_id,omitempty"` SdkInterface string `json:"sdk_interface,omitempty"` SdkUIType string `json:"sdk_ui_type,omitempty"` SdkEphemeralPublicKey string `json:"sdk_ephemeral_public_key,omitempty"` }
type ThreeDSecureResult ¶ added in v1.7.0
type ThreeDSecureResult struct { Internal struct { ServerTransactionID string `json:"three_d_secure_server_transaction_id"` XID string `json:"xid"` AuthenticationStatus string `json:"three_d_secure_authentication_status"` Version string `json:"three_d_secure_version"` DsXID string `json:"ds_xid"` ECIFlag string `json:"eci_flag"` CAVV string `json:"cavv"` } `json:"internal"` ScaExemptions struct { WhitelistStatus string `json:"whitelist_status"` } `json:"sca_exemptions"` }
type ThreeDSecureScaExemptions ¶ added in v1.7.0
type Void ¶
type Void struct { ID string `json:"id"` Result Result `json:"result"` Created json.Number `json:"created"` ProviderData ProviderData `json:"provider_data"` AdditionalDetails AdditionalDetails `json:"additional_details"` ProviderConfiguration ProviderConfiguration `json:"provider_configuration"` }
Void is an entity model.
type VoidCallback ¶ added in v1.3.0
type VoidCallback struct { CallbackCommon Data Void `json:"data"` }
type VoidClient ¶
type VoidClient struct {
Caller Caller
}
VoidClient is a client for work with Void entity. https://developers.paymentsos.com/docs/api#/reference/voids