mollie

package
v0.0.0-...-90bdb73 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2018 License: MIT Imports: 5 Imported by: 1

Documentation

Overview

Package mollie provides a simple access towards the Mollie APIs Supported endpoints:

  • payments
  • refunds
  • chargebacks

Authentication system available:

  • ApiKey

Testing mode is supported.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	StreetAndNumber string `json:"streetAndNumber,omitempty"`
	PostalCode      string `json:"postalCode,omitempty"`
	City            string `json:"city,omitempty"`
	Region          string `json:"region,omitempty"`
	Country         string `json:"country,omitempty"`
}

Address describes where the payee resides

type Amount

type Amount struct {
	Currency string `json:"currency"`
	Value    string `json:"value"`
}

Amount describe the currency and value of the payment

type ChargebackResponse

type ChargebackResponse struct {
	Resource         string                 `json:"resource"`
	ID               string                 `json:"id"`
	Amount           Amount                 `json:"amount"`
	SettlementAmount Amount                 `json:"settlementAmount"`
	CreatedAt        time.Time              `json:"createdAt"`
	ReversedAt       interface{}            `json:"reversedAt"`
	PaymentID        string                 `json:"paymentId"`
	Links            map[string]interface{} `json:"_links"`
}

ChargebackResponse defines the objecy for every response from the Mollie APIs regarding chargebacks https://docs.mollie.com/reference/v2/chargebacks-api/get-chargeback

type ChargebacksResponse

type ChargebacksResponse struct {
	Count              int                    `json:"count"`
	EmbeddedChargeback EmbeddedChargeback     `json:"_embedded"`
	Links              map[string]interface{} `json:"_links"`
}

ChargebacksResponse is an object returned when multiple Chargeback objects are requested

type Client

type Client struct {
	TestMode bool
	// contains filtered or unexported fields
}

Client is a client for working with the Mollie API.

func NewClient

func NewClient(apiKey string, testMode bool) Client

NewClient creates the client that will interface with the Mollie APIs. Only ApiKey is supported at the moments

func (*Client) CancelPayment

func (c *Client) CancelPayment(id string) (*PaymentResponse, error)

CancelPayment cancel the payment with specific id. Not all the payments can be canceled. https://docs.mollie.com/reference/v2/payments-api/cancel-payment

func (*Client) CancelRefund

func (c *Client) CancelRefund(paymentID, refundID string) (*RefundResponse, error)

CancelRefund cancels a specific refund for a given payment id

func (*Client) CreatePayment

func (c *Client) CreatePayment(p *PaymentRequest) (*PaymentResponse, error)

CreatePayment creates an actual payment object in Mollie. After this call you can see it in the Mollie Dashboard https://docs.mollie.com/reference/v2/payments-api/create-payment

func (*Client) CreateRefund

func (c *Client) CreateRefund(r *RefundRequest, paymentID string) (*RefundResponse, error)

CreateRefund creates a Refund for a given payment

func (*Client) GetChargeBack

func (c *Client) GetChargeBack(paymentID, chargebackID string) (*ChargebackResponse, error)

GetChargeBack retrieve the charge back object given both a payment id and the chargeback id

func (*Client) GetPayment

func (c *Client) GetPayment(id string, options *PaymentOptions) (*PaymentResponse, error)

GetPayment gets a Payment object given the payment id from Mollie https://docs.mollie.com/reference/v2/payments-api/get-payment

func (*Client) GetRefund

func (c *Client) GetRefund(paymentID, refundID string) (*RefundResponse, error)

GetRefund returns a specific refund from a given payment and refund ids

func (*Client) ListAllChargeBacks

func (c *Client) ListAllChargeBacks() (*ChargebacksResponse, error)

ListAllChargeBacks returns all the chargebacks in your account

func (*Client) ListAllRefunds

func (c *Client) ListAllRefunds(options *RefundOptions) (*RefundsResponse, error)

ListAllRefunds returns an object with all the reunds in your account

func (*Client) ListChargeBacksOfPayment

func (c *Client) ListChargeBacksOfPayment(paymentID string) (*ChargebacksResponse, error)

ListChargeBacksOfPayment returns all the chargebacks of a specific payment

func (*Client) ListPayments

func (c *Client) ListPayments(options *PaymentOptions) (*PaymentsResponse, error)

ListPayments retrieve all the payments of your account

func (*Client) ListRefundsOfPayment

func (c *Client) ListRefundsOfPayment(options *RefundOptions, paymentID string) (*RefundsResponse, error)

ListRefundsOfPayment returns all the refunds for a given payment

type EmbeddedChargeback

type EmbeddedChargeback struct {
	Chargeback []ChargebackResponse `json:"chargebacks"`
}

EmbeddedChargeback is the object used for marshelling correctly the response when asking for more than one chargeback at the time

type EmbeddedPayments

type EmbeddedPayments struct {
	Payments []PaymentResponse `json:"payments"`
}

EmbeddedPayments is the object used for marshelling correctly the response when asking for more than one payment at the time

type EmbeddedRefunds

type EmbeddedRefunds struct {
	Refunds []RefundResponse `json:"refunds"`
}

EmbeddedRefunds is convenient struct for marshalling/unmarshalling when multiple Refunds

type ErrorMollie

type ErrorMollie struct {
	Status int         `json:"status"`
	Title  string      `json:"title"`
	Detail string      `json:"detail"`
	Field  string      `json:"field"`
	Links  interface{} `json:"_links"`
}

ErrorMollie represents an error returned by the Mollie API.

func (ErrorMollie) Error

func (e ErrorMollie) Error() string

Error string reformat

type PaymentOptions

type PaymentOptions struct {
	IncludeQrCode    string // value: "details.qrCode"
	EmbedRefunds     string // value: "refunds"
	EmbedChargebacks string // value: "chargebacks"
	From             string // value: "from"
	Limit            string // value: "limit"
}

PaymentOptions are the options that can be passed as query parameters when getting a Payment(s) https://docs.mollie.com/reference/v2/payments-api/get-payment

type PaymentRequest

type PaymentRequest struct {
	Amount            Amount      `json:"amount" validate:"required"`
	Description       string      `json:"description" validate:"required"`
	RedirectURL       string      `json:"redirectUrl" validate:"required"`
	WebhookURL        string      `json:"webhookUrl" validate:"required"`
	Method            string      `json:"method" validate:"required"`
	Locale            string      `json:"locale,omitempty"`
	Metadata          interface{} `json:"metadata,omitempty"`
	SequenceType      string      `json:"sequenceType,omitempty"`
	CustomerID        string      `json:"customerId,omitempty"`
	MandateID         string      `json:"mandateId,omitempty"`
	BillingEmail      string      `json:"billingEmail,omitempty"`
	DueDate           string      `json:"dueDate,omitempty"`
	BillingAddress    Address     `json:"billingAddress,omitempty"`
	ShippingAddress   Address     `json:"shippingAddress,omitempty"`
	VoucherNumber     string      `json:"voucherNumber,omitempty"`
	VoucherPin        string      `json:"voucherPin,omitempty"`
	Issuer            string      `json:"issuer,omitempty"`
	CustomerReference string      `json:"customerReference,omitempty"`
}

PaymentRequest describe the object necessary to create a Payment in Mollie https://docs.mollie.com/reference/v2/payments-api/create-payment

type PaymentResponse

type PaymentResponse struct {
	Resource         string      `json:"resource"`
	ID               string      `json:"id"`
	Mode             string      `json:"mode"`
	CreatedAt        time.Time   `json:"createdAt"`
	Amount           Amount      `json:"amount"`
	Description      string      `json:"description"`
	Method           interface{} `json:"method"`
	Metadata         interface{} `json:"metadata"`
	Status           string      `json:"status"`
	IsCancelable     bool        `json:"isCancelable"`
	ExpiresAt        time.Time   `json:"expiresAt"`
	Details          interface{} `json:"details"`
	ProfileID        string      `json:"profileId"`
	SettlementAmount Amount      `json:"settlementAmount"`
	SequenceType     string      `json:"sequenceType"`
	RedirectURL      string      `json:"redirectUrl"`
	WebhookURL       string      `json:"webhookUrl"`
	Links            interface{} `json:"_links"`
}

PaymentResponse describes the object obtained in the response from every Payment operation https://docs.mollie.com/reference/v2/payments-api/get-payment

type PaymentsResponse

type PaymentsResponse struct {
	Count            int                    `json:"count"`
	EmbeddedPayments EmbeddedPayments       `json:"_embedded"`
	Links            map[string]interface{} `json:"_links"`
}

PaymentsResponse is an object returned when multiple Payment objects are requested

type RefundOptions

type RefundOptions struct {
	From  string
	Limit string
}

RefundOptions is a convenient struct to add query parametes when getting a refund(s)

type RefundRequest

type RefundRequest struct {
	Amount      map[string]string `json:"amount" validate:"required"`
	Description string            `json:"description" validate:"required"`
}

RefundRequest represents the object to create a Refund in Mollie API

type RefundResponse

type RefundResponse struct {
	Resource    string            `json:"resource"`
	ID          string            `json:"id"`
	Amount      map[string]string `json:"amount"`
	Status      string            `json:"status"`
	CreatedAt   time.Time         `json:"createdAt"`
	Description string            `json:"description"`
	PaymentID   string            `json:"paymentId"`
	Links       interface{}       `json:"_links"`
}

RefundResponse represents a convenient object for every response of the refunds endpoint from Mollie APIs

type RefundsResponse

type RefundsResponse struct {
	Count           int                    `json:"count"`
	EmbeddedRefunds EmbeddedRefunds        `json:"_embedded"`
	Links           map[string]interface{} `json:"_links"`
}

RefundsResponse is the object when asking for multiple refunds object

Jump to

Keyboard shortcuts

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