mollie

package module
v0.0.0-...-cd9508b Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2017 License: MIT Imports: 8 Imported by: 0

README

Go Mollie API

Build Status Go Report Card GoDoc codecov

The Go Mollie API is designed for use with the Mollie Payment Service Provider. Mollie is a Dutch Payment Service Provider. This API is an interface to Mollie for Golang.

Installation

Installation is very simple:

go get -u github.com/rikvdh/go-mollie

Usage

A very basic example is shown below. Just get an instance of the API with mollie.Get("<API-KEY>") and use one of the available API's. Other examples are show in the _examples directory.

package main

import (
	"fmt"

	"github.com/rikvdh/go-mollie"
)

func main() {
	m := mollie.Get("<apikey>")

	methods, err := m.Methods().List()
	if err != nil {
		panic(err)
	}

	for _, method := range methods {
		fmt.Printf("method %s: %s\n", method.ID, method.Description)
	}
}

Status

It works and I myself use it in production without issues. Currently only authentication by API keys. See the documentation of Mollie for more information on the API's. Currently implemented API's:

  • Payments API
  • Methods API
  • Issuers API
  • Refunds API
  • Customers API
  • Mandates API
  • Subscriptions API

Other API's which require OAuth API authentication:

  • Connect API
  • Permissions API
  • Organizations API
  • Profiles API
  • Settlements API
  • Invoices API

Contributing

Please read the Contribution Guidelines. Furthermore: Fork -> Patch -> Push -> Pull Request

License

This project is licensed under the MIT License. See the LICENSE file for the full license text.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Customer

type Customer struct {
	Resource            string    `json:"resource"`
	ID                  string    `json:"id"`
	Mode                string    `json:"mode"`
	Name                string    `json:"name"`
	Email               string    `json:"email"`
	Locale              string    `json:"locale"`
	Metadata            string    `json:"metadata,omitempty"`
	RecentlyUsedMethods []string  `json:"recentlyUsedMethods"`
	CreatedDatetime     time.Time `json:"createdDatetime"`
}

type CustomerAPI

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

CustomerAPI is the part of the API which handles Mollie customers

func (*CustomerAPI) Get

func (api *CustomerAPI) Get(id string) (*Customer, error)

Get retrieves customer information with the specified ID

func (*CustomerAPI) List

func (api *CustomerAPI) List(offset, limit uint64) (*ListCustomersResponse, error)

List returns a list of customers

func (*CustomerAPI) New

func (api *CustomerAPI) New(data NewCustomerData) (*Customer, error)

New creates a new customer

func (*CustomerAPI) NewPayment

func (api *CustomerAPI) NewPayment(id string, data PaymentData) (*PaymentReply, error)

NewPayment creates a new payment for a customer with the specified ID

func (*CustomerAPI) Payments

func (api *CustomerAPI) Payments(id string, offset uint64, limit uint64) ([]PaymentReply, error)

Payments returns a list of payments for a customer with the specified ID

type Issuer

type Issuer struct {
	ID       string
	Name     string
	Method   string
	Resource string
}

Issuer for, for example, the iDeal payment method

type IssuerAPI

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

IssuerAPI type, holds reference to the core

func (*IssuerAPI) Get

func (a *IssuerAPI) Get(issuerID string) (*Issuer, error)

Get returns a single issuer with the ID given

func (*IssuerAPI) List

func (a *IssuerAPI) List() ([]Issuer, error)

List returns a full listing of all issuers

type Links struct {
	Previous string `json:"previous,omitempty"`
	Next     string `json:"next,omitempty"`
	First    string `json:"first,omitempty"`
	Last     string `json:"last,omitempty"`
}

type ListCustomersResponse

type ListCustomersResponse struct {
	Totalcount uint       `json:"totalcount"`
	Offset     uint       `json:"offset"`
	Count      uint       `json:"count"`
	Data       []Customer `json:"data"`
	Links      Links      `json:"links,omitempty"`
}

type Method

type Method struct {
	ID          string
	Description string
	Amount      MethodAmount
	Image       MethodImage
	Resource    string
}

type MethodAPI

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

func (*MethodAPI) Get

func (a *MethodAPI) Get(methodID string) (*Method, error)

func (*MethodAPI) List

func (a *MethodAPI) List() ([]Method, error)

type MethodAmount

type MethodAmount struct {
	Minimum float64 `json:",string"`
	Maximum float64 `json:",string"`
}

type MethodImage

type MethodImage struct {
	Normal string
	Buffer string
}

type Mollie

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

Mollie holds references to all sections of the API use the access functions to retrieve instances of this structure

func Get

func Get(apikey string) Mollie

Get generates a new API structure with the provided API-Key

func (Mollie) Customers

func (m Mollie) Customers() *CustomerAPI

Customers returns a reference to the CustomerAPI

func (Mollie) Issuers

func (m Mollie) Issuers() *IssuerAPI

Issuers returns a reference to the IssuerAPI

func (Mollie) Methods

func (m Mollie) Methods() *MethodAPI

Methods returns a reference to the MethodAPI

func (Mollie) Payments

func (m Mollie) Payments() *PaymentAPI

Payments returns a reference to the PaymentAPI

type NewCustomerData

type NewCustomerData struct {
	Name     string `json:"name"`
	Email    string `json:"email"`
	Locale   string `json:"locale,omitempty"` // One of de_DE en_US es_ES fr_FR nl_BE fr_BE nl_NL
	Metadata string `json:"metadata,omitempty"`
}

type PaymentAPI

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

PaymentAPI structure holds a pointer to the core

func (*PaymentAPI) Delete

func (a *PaymentAPI) Delete(id string) (*PaymentReply, error)

Delete a payment with the given ID

func (*PaymentAPI) Get

func (a *PaymentAPI) Get(id string) (*PaymentReply, error)

Get retrieves a payment with the given ID

func (*PaymentAPI) List

func (a *PaymentAPI) List(offset, limit uint64) ([]PaymentReply, error)

List returns a list of payments

func (*PaymentAPI) New

func (a *PaymentAPI) New(data PaymentData) (*PaymentReply, error)

New Creates a new payment

type PaymentData

type PaymentData struct {
	Amount      float64     `json:"amount,string"`
	Description string      `json:"description"`
	RedirectURL string      `json:"redirectUrl"`
	WebhookURL  string      `json:"webhookUrl"`
	Method      string      `json:"method,omitempty"`
	Metadata    interface{} `json:"metadata"`
	// One of de_DE en_US es_ES fr_FR nl_BE fr_BE nl_NL
	Locale string `json:"locale,omitempty"`

	Issuer string `json:"issuer,omitempty"`
}

PaymentData needed for a payment request

type PaymentReply

type PaymentReply struct {
	ID                string
	Mode              string
	CreatedDatetime   time.Time `json:"createdDatetime"`
	ExpiredDatetime   time.Time `json:"expiredDatetime"`
	CancelledDatetime time.Time `json:"cancelledDatetime"`
	PaidDatetime      time.Time `json:"paidDatetime"`
	Status            PaymentStatus
	ExpiryPeriod      string  `json:"expiryPeriod"`
	Amount            float64 `json:",string"`
	AmountRefunded    float64 `json:"amountRefunded,string,omitempty"`
	AmountRemaining   float64 `json:"amountRemaining,string,omitempty"`
	Description       string
	Method            string
	Metadata          interface{}
	Details           interface{} `json:",omitempty"`
	ProfileID         string      `json:"profileId"`
	Links             map[string]string
}

PaymentReply for a payment

type PaymentStatus

type PaymentStatus string

PaymentStatus for a payment

const (
	// StatusOpen means a payment is open for payment
	StatusOpen PaymentStatus = "open"
	// StatusCancelled means a payment is cancelled by a user
	StatusCancelled PaymentStatus = "cancelled"
	// StatusExpired means a payment is expired and not accepting payments anymore
	StatusExpired PaymentStatus = "expired"
	// StatusFailed means a payment has failed
	StatusFailed PaymentStatus = "failed"
	// StatusPending means a payment is on hold and not confirmed (yet)
	StatusPending PaymentStatus = "pending"
	// StatusPaid informs you that a payment is marked as paid
	StatusPaid PaymentStatus = "paid"
	// StatusPaidout means ?
	StatusPaidout PaymentStatus = "paidout"
	// StatusRefunded means this payment is refunded
	StatusRefunded PaymentStatus = "refunded"
	// StatusChargedBack means a payment is charged back by the customer
	StatusChargedBack PaymentStatus = "charged_back"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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