Documentation ¶
Overview ¶
Package twikey provides the bindings for Twikey REST APIs.
Index ¶
- Variables
- type AmdmntRsn
- type Client
- func (c *Client) CustomerUpdate(ctx context.Context, request *Customer) error
- func (c *Client) DocumentCancel(ctx context.Context, mandate string, reason string) error
- func (c *Client) DocumentDetail(ctx context.Context, mndtId string) (*Mndt, error)
- func (c *Client) DocumentFeed(ctx context.Context, newDocument func(mandate *Mndt, eventTime string), ...) error
- func (c *Client) DocumentInvite(ctx context.Context, request *InviteRequest) (*Invite, error)
- func (c *Client) DocumentSign(ctx context.Context, request *InviteRequest) (*Invite, error)
- func (c *Client) DocumentUpdate(ctx context.Context, request *UpdateRequest) error
- func (c *Client) DownloadPdf(ctx context.Context, mndtId string, downloadFile string) error
- func (c *Client) InvoiceAction(ctx context.Context, invoiceIdOrNumber string, action InvoiceAction) error
- func (c *Client) InvoiceAdd(ctx context.Context, invoiceRequest *NewInvoiceRequest) (*Invoice, error)
- func (c *Client) InvoiceDetail(ctx context.Context, invoiceIdOrNumber string, sideloads ...string) (*Invoice, error)
- func (c *Client) InvoiceFeed(ctx context.Context, callback func(invoice *Invoice), sideloads ...string) error
- func (c *Client) PaylinkFeed(ctx context.Context, callback func(paylink *Paylink), sideloads ...string) error
- func (c *Client) PaylinkNew(ctx context.Context, paylinkRequest *PaylinkRequest) (*Paylink, error)
- func (c *Client) Ping() error
- func (c *Client) ReservationNew(ctx context.Context, reservationRequest *ReservationRequest) (*Reservation, error)
- func (c *Client) TransactionCollect(ctx context.Context, template string, prenotify bool) (string, error)
- func (c *Client) TransactionFeed(ctx context.Context, callback func(transaction *Transaction), ...) error
- func (c *Client) TransactionNew(ctx context.Context, transaction *TransactionRequest) (*Transaction, error)
- func (c *Client) VerifyWebhook(signatureHeader string, payload string) error
- type CollectResponse
- type CtctDtls
- type Customer
- type CxlRsn
- type DbtrAgt
- type DefaultTimeProvider
- type FinInstnId
- type HTTPClient
- type Invite
- type InviteRequest
- type Invoice
- type InvoiceAction
- type InvoiceFeed
- type InvoiceFeedMeta
- type KeyValue
- type Lastpayment
- type MandateUpdate
- type MandateUpdates
- type Mndt
- type MndtDetail
- type NewInvoiceRequest
- type Paylink
- type PaylinkList
- type PaylinkRequest
- type Prty
- type PstlAdr
- type Reservation
- type ReservationRequest
- type TimeProvider
- type Transaction
- type TransactionList
- type TransactionRequest
- type TwikeyError
- type UpdateRequest
Constants ¶
This section is empty.
Variables ¶
var SystemError error = &TwikeyError{
Status: 500,
Code: "system_error",
}
Functions ¶
This section is empty.
Types ¶
type AmdmntRsn ¶
type AmdmntRsn struct {
Rsn string
}
AmdmntRsn contains the reason why something was updated
type Client ¶
type Client struct { BaseURL string APIKey string PrivateKey string Salt string UserAgent string HTTPClient HTTPClient Debug *log.Logger // contains filtered or unexported fields }
Client is the base class, please use a dedicated UserAgent so we can notify the emergency contact if weird behaviour is perceived.
func NewClient ¶
NewClient is a convenience method to hit the ground running with the Twikey Rest API
func (*Client) CustomerUpdate ¶ added in v0.1.6
func (*Client) DocumentCancel ¶
DocumentCancel allows to cancel (or delete if unsigned) a previously added document
func (*Client) DocumentDetail ¶ added in v0.1.2
DocumentDetail allows a snapshot of a particular mandate, note that this is rate limited
func (*Client) DocumentFeed ¶
func (c *Client) DocumentFeed( ctx context.Context, newDocument func(mandate *Mndt, eventTime string), updateDocument func(originalMandateNumber string, mandate *Mndt, reason *AmdmntRsn, eventTime string), cancelledDocument func(mandateNumber string, reason *CxlRsn, eventTime string)) error
DocumentFeed retrieves all documents since the last call with callbacks since there may be many
func (*Client) DocumentInvite ¶
DocumentInvite allows to invite a customer to sign a specific document
func (*Client) DocumentSign ¶ added in v0.1.4
DocumentSign allows a customer to sign directly a specific document
func (*Client) DocumentUpdate ¶
func (c *Client) DocumentUpdate(ctx context.Context, request *UpdateRequest) error
DocumentUpdate allows to update a previously added document
func (*Client) DownloadPdf ¶
DownloadPdf allows the download of a specific (signed) pdf
func (*Client) InvoiceAction ¶ added in v0.1.18
func (c *Client) InvoiceAction(ctx context.Context, invoiceIdOrNumber string, action InvoiceAction) error
InvoiceAction allows certain actions to be done on an existing invoice
func (*Client) InvoiceAdd ¶ added in v0.1.2
func (c *Client) InvoiceAdd(ctx context.Context, invoiceRequest *NewInvoiceRequest) (*Invoice, error)
InvoiceFromUbl sends an invoice to Twikey in UBL format
func (*Client) InvoiceDetail ¶ added in v0.1.14
func (c *Client) InvoiceDetail(ctx context.Context, invoiceIdOrNumber string, sideloads ...string) (*Invoice, error)
InvoiceDetail allows a snapshot of a particular invoice, note that this is rate limited
func (*Client) InvoiceFeed ¶
func (c *Client) InvoiceFeed(ctx context.Context, callback func(invoice *Invoice), sideloads ...string) error
InvoiceFeed Get invoice Feed twikey
func (*Client) PaylinkFeed ¶
func (c *Client) PaylinkFeed(ctx context.Context, callback func(paylink *Paylink), sideloads ...string) error
PaylinkFeed retrieves the feed of updated paylinks since last call
func (*Client) PaylinkNew ¶
PaylinkNew sends the new paylink to Twikey for creation
func (*Client) ReservationNew ¶ added in v0.1.4
func (c *Client) ReservationNew(ctx context.Context, reservationRequest *ReservationRequest) (*Reservation, error)
ReservationNew sends a new reservation to Twikey
func (*Client) TransactionCollect ¶ added in v0.1.11
func (c *Client) TransactionCollect(ctx context.Context, template string, prenotify bool) (string, error)
TransactionCollect collects all open transaction
func (*Client) TransactionFeed ¶
func (c *Client) TransactionFeed(ctx context.Context, callback func(transaction *Transaction), sideloads ...string) error
TransactionFeed retrieves all transaction updates since the last call with a callback since there may be many
func (*Client) TransactionNew ¶
func (c *Client) TransactionNew(ctx context.Context, transaction *TransactionRequest) (*Transaction, error)
TransactionNew sends a new transaction to Twikey
type CollectResponse ¶ added in v0.1.11
type CollectResponse struct {
ID string `json:"rcurMsgId"`
}
CollectResponse is a struct to contain the response coming from Twikey, should be considered internal
type Customer ¶
type Customer struct { CustomerNumber string `json:"customerNumber,omitempty"` Email string `json:"email,omitempty"` CompanyName string `json:"companyName"` Coc string `json:"coc"` FirstName string `json:"firstName"` LastName string `json:"lastName"` Address string `json:"address"` City string `json:"city"` Zip string `json:"zip"` Country string `json:"country"` Language string `json:"l"` Mobile string `json:"mobile,omitempty"` }
Customer is a json wrapper for usage inside the Invoice object
type CxlRsn ¶
type CxlRsn struct {
Rsn string
}
CxlRsn contains the reason why something was cancelled
type DbtrAgt ¶
type DbtrAgt struct {
FinInstnId FinInstnId
}
type DefaultTimeProvider ¶ added in v0.1.15
type DefaultTimeProvider struct{}
func (DefaultTimeProvider) Now ¶ added in v0.1.15
func (tp DefaultTimeProvider) Now() time.Time
type FinInstnId ¶
type FinInstnId struct {
BICFI string
}
type HTTPClient ¶ added in v0.1.3
type Invite ¶
type Invite struct { MndtId string // documentNumber Url string // where the customer can sign the document Key string // specific invite key }
Invite is the response containing the documentNumber, key and the url to point the customer too.
type InviteRequest ¶
type InviteRequest struct { Template string // mandatory CustomerNumber string Email string Mobile string Language string Lastname string Firstname string MandateNumber string ContractNumber string CompanyName string Coc string Address string City string Zip string Country string SignDate string Amount string Iban string Bic string Campaign string Method string Extra map[string]string }
InviteRequest contains all possible parameters that can be send to invite a customer to sign a document
func (*InviteRequest) Add ¶ added in v0.1.6
func (request *InviteRequest) Add(key string, value string)
type Invoice ¶
type Invoice struct { Id string `json:"id,omitempty"` Number string `json:"number"` Title string `json:"title"` Remittance string `json:"remittance"` Ct int `json:"ct,omitempty"` Manual bool `json:"manual,omitempty"` State string `json:"state,omitempty"` Amount float64 `json:"amount"` Date string `json:"date"` Duedate string `json:"duedate"` Ref string `json:"ref,omitempty"` CustomerByDocument string `json:"customerByDocument,omitempty"` Customer *Customer `json:"customer,omitempty"` Pdf []byte `json:"pdf,omitempty"` Meta *InvoiceFeedMeta `json:"meta,omitempty"` LastPayment *Lastpayment `json:"lastpayment,omitempty"` }
Invoice is the base object for sending and receiving invoices to Twikey
func (*Invoice) HasMeta ¶
HasMeta convenience method to indicate that there is extra info available on the invoice
type InvoiceAction ¶ added in v0.1.18
type InvoiceAction int64
const ( InvoiceAction_EMAIL InvoiceAction = iota // Send invitation by email InvoiceAction_SMS // Send invitation by sms InvoiceAction_REMINDER // Send a reminder by email InvoiceAction_LETTER // Send the invoice via postal letter InvoiceAction_REOFFER // Reoffer (or try to collect the invoice via a recurring mechanism) )
type InvoiceFeed ¶
type InvoiceFeed struct {
Invoices []Invoice
}
InvoiceFeed is a struct to contain the response coming from Twikey, should be considered internal
type InvoiceFeedMeta ¶ added in v0.1.3
type InvoiceFeedMeta struct {
LastError string `json:"lastError,omitempty"`
}
type KeyValue ¶
type KeyValue struct { Key string Value interface{} }
KeyValue key value pairs of extra data in a document
type Lastpayment ¶ added in v0.1.9
type Lastpayment []map[string]interface{}
type MandateUpdate ¶
type MandateUpdate struct { Mndt *Mndt AmdmntRsn *AmdmntRsn `json:",omitempty"` CxlRsn *CxlRsn `json:",omitempty"` OrgnlMndtId string EvtTime string }
MandateUpdate contains all info regarding a new/update or cancelled document
type MandateUpdates ¶
type MandateUpdates struct {
Messages []MandateUpdate
}
MandateUpdates is a struct to contain the response coming from Twikey, should be considered internal
type MndtDetail ¶ added in v0.1.2
type MndtDetail struct {
Mndt Mndt
}
type NewInvoiceRequest ¶ added in v0.1.19
type Paylink ¶
type Paylink struct { Id int64 `json:"id,omitempty"` Amount float64 `json:"amount,omitempty"` Msg string `json:"msg,omitempty"` Ref string `json:"ref,omitempty"` State string `json:"state,omitempty"` Url string `json:"url,omitempty"` }
Paylink is the response receiving from Twikey upon a request
type PaylinkList ¶ added in v0.1.9
type PaylinkList struct {
Links []Paylink
}
type PaylinkRequest ¶
type PaylinkRequest struct { CustomerNumber string // The customer number (strongly advised) Email string // Email of the debtor (Required to send invite) Lastname string // lastname Firstname string // firstname Language string // Language (en/fr/nl/de/pt/es/it) Mobile string // mobile number Template string // contract template Title string // Message to the debto Remittance string // Payment message, if empty then title will be used Amount float64 // Amount to be billed RedirectUrl string // Optional redirect after pay url (must use http(s)://) Place string // Optional place Expiry string // Optional expiration date SendInvite string // Send out invite email or sms directly (email, sms) Address string // Address (street + number) City string // City of debtor Zip string // Zipcode of debtor Country string // ISO format (2 letters) Txref string // References from existing transactions Method string // Circumvents the payment selection with PSP (bancontact/ideal/maestro/mastercard/visa/inghomepay/kbc/belfius) Invoice string // create payment link for specific invoice number Extra map[string]string }
PaylinkRequest is the base object for sending and receiving paylinks to Twikey
func (*PaylinkRequest) Add ¶ added in v0.1.6
func (request *PaylinkRequest) Add(key string, value string)
type Reservation ¶ added in v0.1.4
type Reservation struct { Id string `json:"id"` MndtId string `json:"mndtId"` ReservedAmount float64 `json:"reservedAmount"` Expires time.Time `json:"expires"` }
Reservation is the response from Twikey when updates are received
type ReservationRequest ¶ added in v0.1.15
type ReservationRequest struct { DocumentReference string Amount float64 Minimum float64 Expiration *time.Time Force bool }
TransactionRequest is the payload to be send to Twikey when a new transaction should be send
type TimeProvider ¶ added in v0.1.15
type Transaction ¶
type Transaction struct { Id int64 `json:"id,omitempty"` DocumentId int64 `json:"contractId,omitempty"` DocumentReference string `json:"mndtId"` Amount float64 `json:"amount"` Message string `json:"msg"` Ref string `json:"ref"` Place string `json:"place"` Final bool `json:"final"` State string `json:"state"` BookedDate string `json:"bkdate"` BookedError string `json:"bkerror"` BookedAmount float64 `json:"bkamount"` RequestedCollection string `json:"reqcolldt"` }
Transaction is the response from Twikey when updates are received
type TransactionList ¶
type TransactionList struct {
Entries []Transaction
}
TransactionList is a struct to contain the response coming from Twikey, should be considered internal
type TransactionRequest ¶
type TransactionRequest struct { DocumentReference string TransactionDate string RequestedCollection string Msg string Ref string Amount float64 Place string ReferenceIsEndToEndIdentifier bool Reservation string // via reservation request Force bool }
TransactionRequest is the payload to be send to Twikey when a new transaction should be send
type TwikeyError ¶ added in v0.1.4
func NewTwikeyError ¶ added in v0.1.4
func NewTwikeyError(code string, msg string, extra string) *TwikeyError
func NewTwikeyErrorFromResponse ¶ added in v0.1.4
func NewTwikeyErrorFromResponse(res *http.Response) *TwikeyError
func (*TwikeyError) Error ¶ added in v0.1.4
func (err *TwikeyError) Error() string
func (*TwikeyError) IsUserError ¶ added in v0.1.4
func (err *TwikeyError) IsUserError() bool
type UpdateRequest ¶
type UpdateRequest struct { MandateNumber string // Document or MandateNumber ContractNumber string // ContractNumber State string // active or passive (activated or suspend mandate) Mobile string // Owner's mobile number Iban string // Debtor's IBAN Bic string // Debtor's BIC code Email string // email address of debtor Firstname string // Firstname of the debtor Lastname string // Lastname of the debtor CompanyName string // Company name on the mandate Coc string // The enterprise number (can only be changed if companyName is changed) CustomerNumber string // The customer number (can be added, updated or used to move a mandate) Language string // language on the mandate (ISO 2 letters) Address string // Address (street + number) City string // City of debtor Zip string // Zipcode of debtor Country string // Country of debtor Extra map[string]string }
UpdateRequest contains all possible parameters that can be send to update a document
func (*UpdateRequest) Add ¶ added in v0.1.6
func (request *UpdateRequest) Add(key string, value string)