twikey

package module
v0.1.35 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2024 License: MIT Imports: 19 Imported by: 0

README

Twikey API client for Go

Want to allow your customers to pay in the most convenient way, then Twikey is right what you need.

Recurring or occasional payments via (Recurring) Credit Card, SEPA Direct Debit or any other payment method by bringing your own payment service provider or by leveraging your bank contract.

Twikey offers a simple and safe multichannel solution to negotiate and collect recurring (or even occasional) payments. Twikey has integrations with a lot of accounting and CRM packages. It is the first and only provider to operate on a European level for Direct Debit and can work directly with all major Belgian and Dutch Banks. However you can use the payment options of your favorite PSP to allow other customers to pay as well.

Requirements

Go Reference Go Report Card

To use the Twikey API client, the following things are required:

  • Get yourself a Twikey account.
  • Go >= 1.6
  • Up-to-date OpenSSL (or other SSL/TLS toolkit)

Installation

The easiest way to install the Twikey API client is with go get

$  go get -u github.com/twikey/twikey-api-go 

How to create anything

The api works the same way regardless if you want to create a mandate, a transaction, an invoice or even a paylink. the following steps should be implemented:

  1. Use the Twikey API client to create or import your item.

  2. Once available, our platform will send an asynchronous request to the configured webhook to allow the details to be retrieved. As there may be multiple items ready for you a "feed" endpoint is provided which acts like a queue that can be read until empty till the next time.

  3. The customer returns, and should be satisfied to see that the action he took is completed.

Find our full documentation online on api.twikey.com.

Getting started

Initializing the Twikey API client by configuring your API key which you can find in the Twikey merchant interface.

package example

import "github.com/twikey/twikey-api-go"

func main() {
   client := twikey.NewClient("YOU_API_KEY")
}

It's possible to further configure the API client if so desired using functional options. For example providing a custom HTTP client with a different timeout and a Custom logger implementation.

package example

import (
   "github.com/twikey/twikey-api-go"
   "log"
   "net/http"
)

func main() {
   client := twikey.NewClient("YOUR_API_KEY",
      twikey.WithHTTPClient(&http.Client{Timeout: time.Minute}),
      twikey.WithLogger(log.Default()),
   )
}

Another example, it's possible to disable logging by setting the value of the logger to NullLogger. By default, the Twikey client will print logs using the default standard library logger.

package example

import (
   "github.com/twikey/twikey-api-go"
   "log"
   "net/http"
)

func main() {
   client := twikey.NewClient("YOUR_API_KEY",
      twikey.WithLogger(twikey.NullLogger),
   )
}

Documents

Invite a customer to sign a SEPA mandate using a specific behaviour template (Template) that allows you to configure the behaviour or flow that the customer will experience. This can be found in the template section of the settings. The extra can be used to pass in extra attributes linked to the mandate.

package example

import (
   "context"
   "fmt"
   "github.com/twikey/twikey-api-go"
   "log"
   "os"
)

func main() {
   client := twikey.NewClient(os.Getenv("TWIKEY_API_KEY"))

   ctx := context.Background()
   invite, err := client.DocumentSign(ctx, &twikey.InviteRequest{
      Template:       "YOUR_TEMPLATE_ID",
      CustomerNumber: "123",
      Email:          "john@doe.com",
      Language:       "en",
      Lastname:       "Doe",
      Firstname:      "John",
      Address:        "Abbey Road",
      City:           "Liverpool",
      Zip:            "1562",
      Country:        "EN",
      Iban:           "GB32BARC20040198915359",
      Bic:            "GEBEBEB",
      Method:         "sms",
      Extra: map[string]string{
         "SomeKey": "VALUE",
      },
   })
   if err != nil {
      log.Fatal(err)
   }

   fmt.Println(invite.Url)
}

After creation, the link available in invite.Url can be used to redirect the customer into the signing flow or even send him a link through any other mechanism. Ideally you store the mandatenumber for future usage (eg. sending transactions).

The DocumentSign function has a similar syntax only that it requires a method and is mostly used for interactive sessions where no screens are involved. See the documentation for more info.

Feed

Once signed, a webhook is sent (see below) after which you can fetch the detail through the document feed, which you can actually think of as reading out a queue. Since it'll return you the changes since the last time you called it.

err := c.DocumentFeed(context.Background(), func(mandate *Mndt, eventTime string, eventId int64) {
    fmt.println("Document created   ", mandate.MndtId, " @ ", eventTime)
}, func(originalMandateNumber string, mandate *Mndt, reason *AmdmntRsn, eventTime string, eventId int64) {
    fmt.println("Document updated   ", originalMandateNumber, reason.Rsn, " @ ", eventTime)
}, func(mandateNumber string, reason *CxlRsn, eventTime string, eventId int64) {
    fmt.println("Document cancelled ", mandateNumber, reason.Rsn, " @ ", eventTime)
})

Transactions

Send new transactions and act upon feedback from the bank.

tx, err := twikeyClient.TransactionNew(context.Background(), &TransactionRequest{
   DocumentReference: "ABC",
   Msg:               "My Transaction",
   Ref:               "My Reference",
   Amount:            10.90,
})
fmt.println("New tx", tx)

Feed

err := twikeyClient.TransactionFeed(context.Background(), func(transaction *Transaction) {
    fmt.println("Transaction", transaction.Amount, transaction.BookedError, transaction.Final)
})

Webhook

When wants to inform you about new updates about documents or payments a webhookUrl specified in your api settings be called.

err := twikeyClient.VerifyWebhook("55261CBC12BF62000DE1371412EF78C874DBC46F513B078FB9FF8643B2FD4FC2", "abc=123&name=abc")
if err != nil {
    t.Fatal(err)
}

API documentation

If you wish to learn more about our API, please visit the Twikey Api Page. API Documentation is available in English.

Want to help us make our API client even better?

Want to help us make our API client even better? We take pull requests.

Support

Contact: www.twikey.com

Documentation

Overview

Package twikey provides the bindings for Twikey REST APIs.

Index

Constants

This section is empty.

Variables

View Source
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      Logger

	TimeProvider TimeProvider
	// 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

func NewClient(apiKey string, opts ...ClientOption) *Client

NewClient is a convenience method to hit the ground running with the Twikey Rest API

func (*Client) CustomerUpdate added in v0.1.6

func (c *Client) CustomerUpdate(ctx context.Context, request *Customer) error

func (*Client) DocumentCancel

func (c *Client) DocumentCancel(ctx context.Context, mandate string, reason string) error

DocumentCancel allows to cancel (or delete if unsigned) a previously added document

func (*Client) DocumentDetail added in v0.1.2

func (c *Client) DocumentDetail(ctx context.Context, mndtId string, force bool) (*MndtDetail, error)

DocumentDetail allows a snapshot of a particular mandate, note that this is rate limited. Force ignores the state of the mandate which is being returned

func (*Client) DocumentFeed

func (c *Client) DocumentFeed(
	ctx context.Context,
	newDocument func(mandate *Mndt, eventTime string, eventId int64),
	updateDocument func(originalMandateNumber string, mandate *Mndt, reason *AmdmntRsn, eventTime string, eventId int64),
	cancelledDocument func(mandateNumber string, reason *CxlRsn, eventTime string, eventId int64),
	options ...FeedOption) error

DocumentFeed retrieves all documents since the last call with callbacks since there may be many

func (*Client) DocumentInvite

func (c *Client) DocumentInvite(ctx context.Context, request *InviteRequest) (*Invite, error)

DocumentInvite allows to invite a customer to sign a specific document

func (*Client) DocumentSign added in v0.1.4

func (c *Client) DocumentSign(ctx context.Context, request *InviteRequest) (*Invite, error)

DocumentSign allows a customer to sign directly a specific document

func (*Client) DocumentSuspend added in v0.1.27

func (c *Client) DocumentSuspend(ctx context.Context, mandate string, suspend bool) error

DocumentSuspend allows to suspend/resume a signed 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

func (c *Client) DownloadPdf(ctx context.Context, mndtId string, downloadFile string) error

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)

InvoiceAdd 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, feedOptions ...FeedOption) (*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), options ...FeedOption) error

InvoiceFeed Get invoice Feed twikey

func (*Client) InvoicePayment added in v0.1.25

func (c *Client) InvoicePayment(ctx context.Context, invoiceIdOrNumber string, method string, paymentdate string) error

InvoicePayment allows marking an existing invoice as paid

func (*Client) InvoiceUpdate added in v0.1.34

func (c *Client) InvoiceUpdate(ctx context.Context, request *UpdateInvoiceRequest) (*Invoice, error)

func (*Client) PaylinkFeed

func (c *Client) PaylinkFeed(ctx context.Context, callback func(paylink *Paylink), options ...FeedOption) error

PaylinkFeed retrieves the feed of updated paylinks since last call

func (*Client) PaylinkNew

func (c *Client) PaylinkNew(ctx context.Context, paylinkRequest *PaylinkRequest) (*Paylink, error)

PaylinkNew sends the new paylink to Twikey for creation

func (*Client) Ping added in v0.1.7

func (c *Client) Ping() error

Ping Try the current credentials

func (*Client) RefundFeed added in v0.1.30

func (c *Client) RefundFeed(ctx context.Context, callback func(refund *Refund), options ...FeedOption) error

RefundFeed retrieves the feed of updated refunds since last call

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, opts ...CollectionOptionFunc) (string, error)

TransactionCollect collects all open transaction

func (*Client) TransactionFeed

func (c *Client) TransactionFeed(ctx context.Context, callback func(transaction *Transaction), options ...FeedOption) 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

func (*Client) VerifyWebhook

func (c *Client) VerifyWebhook(signatureHeader string, payload string) error

VerifyWebhook allows the verification of incoming webhooks.

type ClientOption added in v0.1.27

type ClientOption = func(*Client)

func WithBaseURL added in v0.1.27

func WithBaseURL(baseURL string) ClientOption

WithBaseURL will set the base URL of the API used when making requests.

In production, you will probably want to use the default but if you want to make request to some mock API in a test environment you can use this to make the Client make requests to a different host.

The default: https://api.twikey.com

func WithHTTPClient added in v0.1.27

func WithHTTPClient(httpClient HTTPClient) ClientOption

WithHTTPClient configures the underlying HTTP client used to make HTTP requests.

func WithLogger added in v0.1.27

func WithLogger(logger Logger) ClientOption

WithLogger sets the Logger for the Client. If you don't want the Client to log anything you can pass in the NullLogger

func WithSalt added in v0.1.27

func WithSalt(salt string) ClientOption

WithSalt sets the salt used in generating one-time-passwords

func WithTimeProvider added in v0.1.27

func WithTimeProvider(provider TimeProvider) ClientOption

WithTimeProvider sets the TimeProvider for this Client.

func WithUserAgent added in v0.1.27

func WithUserAgent(userAgent string) ClientOption

WithUserAgent will configure the value that is passed on in the HTTP User-Agent header for all requests to the Twikey API made with this Client

type CollectOptions added in v0.1.29

type CollectOptions struct {
	// Until is used to filter the eventual transactions that will be sent for collection
	// this value is interpreted as a unix timestamp using milliseconds precision. Any
	// transaction that was logged before this timestamp will be ignored.
	// The default value is 0 and will result in this parameter not being used.
	Until int64
}

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 CollectionOptionFunc added in v0.1.29

type CollectionOptionFunc = func(options *CollectOptions)

func WithUntil added in v0.1.29

func WithUntil(until int64) CollectionOptionFunc

WithUntil will set the value for the "until" parameter. It is used to filter the eventual transactions that will be sent for collection this value is interpreted as a unix timestamp using milliseconds precision. Any transaction that was logged before this timestamp will be ignored. The default value is 0 and will result in this parameter not being used.

type CtctDtls

type CtctDtls struct {
	EmailAdr string
	MobNb    string
	Othr     string
}

CtctDtls contains all contact details for a specific document

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 DebugLogger added in v0.1.28

type DebugLogger struct {
	// contains filtered or unexported fields
}

DebugLogger allows the logging of both basic payloads as well as responses

func (DebugLogger) Debugf added in v0.1.28

func (t DebugLogger) Debugf(format string, v ...interface{})

func (DebugLogger) Tracef added in v0.1.28

func (t DebugLogger) Tracef(format string, v ...interface{})

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 FeedOption added in v0.1.30

type FeedOption = func(*FeedOptions)

func FeedInclude added in v0.1.30

func FeedInclude(include ...string) FeedOption

func FeedStartPosition added in v0.1.30

func FeedStartPosition(start int64) FeedOption

type FeedOptions added in v0.1.30

type FeedOptions struct {
	// contains filtered or unexported fields
}

type FinInstnId

type FinInstnId struct {
	BICFI string
}

type HTTPClient added in v0.1.3

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

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"`
	RelatedInvoice     string            `json:"relatedInvoiceNumber"` // RelatedInvoice in case this is a creditNote
	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"`
	Extra              map[string]string `json:"extra,omitempty"` // extra attributes
}

Invoice is the base object for sending and receiving invoices to Twikey

func (*Invoice) HasMeta

func (inv *Invoice) HasMeta() bool

HasMeta convenience method to indicate that there is extra info available on the invoice

func (*Invoice) IsFailed

func (inv *Invoice) IsFailed() bool

IsFailed allows to distinguish invoices since they go from pending to booked or expired when payment failed

func (*Invoice) IsPaid

func (inv *Invoice) IsPaid() bool

IsPaid convenience method

func (*Invoice) IsPending added in v0.1.15

func (inv *Invoice) IsPending() bool

IsPending convenience method

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 Logger added in v0.1.27

type Logger interface {
	// Debugf is the level for basic functions and arguments
	Debugf(format string, v ...interface{})
	// Tracef is the level for http calls
	Tracef(format string, v ...interface{})
}

func NewDebugLogger added in v0.1.28

func NewDebugLogger(logger *log.Logger) Logger

type MandateUpdate

type MandateUpdate struct {
	Mndt        *Mndt
	AmdmntRsn   *AmdmntRsn `json:",omitempty"`
	CxlRsn      *CxlRsn    `json:",omitempty"`
	OrgnlMndtId string
	EvtId       int64
	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 Mndt

type Mndt struct {
	MndtId      string
	Dbtr        Prty
	DbtrAcct    string
	DbtrAgt     DbtrAgt
	RfrdDoc     string
	SplmtryData []KeyValue
}

type MndtDetail added in v0.1.2

type MndtDetail struct {
	State       string
	Collectable bool
	Mndt        Mndt
}

type NewInvoiceRequest added in v0.1.19

type NewInvoiceRequest struct {
	IdempotencyKey   string //   Avoid double entries
	Id               string // Allow passing the id for ubl's too
	Origin           string
	Reference        string
	Purpose          string
	Manual           bool // Don't automatically collect
	ForceTransaction bool // Ignore the state of the contract if passed
	Template         string
	Contract         string
	Invoice          *Invoice          // either UBL
	UblBytes         []byte            // or an invoice item
	Extra            map[string]string // extra attributes
}

type NullLogger added in v0.1.27

type NullLogger struct{}

NullLogger is the (default) logger that ignores all logging

func (NullLogger) Debugf added in v0.1.28

func (n NullLogger) Debugf(format string, v ...interface{})

func (NullLogger) Tracef added in v0.1.28

func (n NullLogger) Tracef(format string, v ...interface{})
type Paylink struct {
	Id     int64   `json:"id,omitempty"`
	Seq    int64   `json:"seq,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 struct {
	Links []Paylink
}

type PaylinkRequest

type PaylinkRequest struct {
	CustomerNumber string  //	The customer number (strongly advised)
	IdempotencyKey string  //   Avoid double entries
	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 Prty

type Prty struct {
	Nm       string
	PstlAdr  PstlAdr
	Id       string
	CtctDtls CtctDtls
}

Prty contains party details for a specific document

type PstlAdr

type PstlAdr struct {
	AdrLine string
	PstCd   string
	TwnNm   string
	Ctry    string
}

PstlAdr contains address data for a specific document

type Refund added in v0.1.30

type Refund struct {
	Id     string    `json:"id"`
	Seq    int64     `json:"seq"`
	Iban   string    `json:"iban"`
	Bic    string    `json:"bic"`
	Amount float64   `json:"amount"`
	Msg    string    `json:"msg"`
	Place  string    `json:"place"`
	Ref    string    `json:"ref"`
	Date   string    `json:"date"`
	State  string    `json:"state"`
	Bkdate time.Time `json:"bkdate"`
}

Refund is the response receiving from Twikey upon a request

type RefundList added in v0.1.30

type RefundList struct {
	Entries []Refund
}

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 {
	IdempotencyKey    string
	DocumentReference string
	Amount            float64
	Minimum           float64
	Expiration        *time.Time
	Force             bool
}

ReservationRequest is the payload to be send to Twikey when a new transaction should be send

type TimeProvider added in v0.1.15

type TimeProvider interface {
	Now() time.Time
}

type Transaction

type Transaction struct {
	Id                  int64   `json:"id,omitempty"`
	Seq                 int64   `json:"seq,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 {
	IdempotencyKey                string
	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

type TwikeyError struct {
	Status  int
	Code    string `json:"code"`
	Message string `json:"message"`
	Extra   string `json:"extra"`
}

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 UpdateInvoiceRequest added in v0.1.34

type UpdateInvoiceRequest struct {
	ID      string            `json:"-"`
	Date    string            `json:"date,omitempty"`
	DueDate string            `json:"duedate,omitempty"`
	Title   string            `json:"title,omitempty"`
	Ref     string            `json:"ref,omitempty"`
	Pdf     []byte            `json:"pdf,omitempty"`
	Extra   map[string]string `json:"extra,omitempty"`
}

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)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL