mango

package module
v0.0.0-...-50fa83b Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: MIT Imports: 12 Imported by: 0

README

mangopay logo

GoDoc

Purpose

This project is a Go implementation of the MangoPay HTTP REST api version 2.

Installation

Use the api with

$ go get github.com/gotsunami/mangopay2-go-sdk

A command line tool is also available for testing the MangoPay service easily:

$ go get github.com/gotsunami/mangopay2-go-sdk/mangopay

Before using it, you must fill a JSON config file with your client credentials (get your sandbox environment credentials):

{
    "ClientId":"myclientid",
    "Name":"Your company name",
    "Email":"contact@company.com",
    "Passphrase":"AlOnGpAsSpHrAsE",
    "Env":"sandbox"
}

Now run mangopay from a terminal to get the list of supported actions:

Usage: ./mangopay [options] action configfile
 
where action is one of: 
  conf              show config
  events            list all events (PayIns, PayOuts, Transfers)
  users             list all users
  user*             fetch a user (natural or legal)

  addnatuser*       create a natural user
  editnatuser*      update natural user info
  natuser*          fetch natural user info

  addlegaluser*     create a legal user
  editlegaluser*    update legal user info
  legaluser*        fetch legal user info

  addwallet*        create a new wallet
  editwallet*       update wallet info
  trwallet*         fetch all wallet's transactions
  wallet*           fetch wallet info
  wallets*          list all user's wallet

  addtransfer*      create a new tranfer
  transfer*         fetch transfer info
  transfers*        list all user's transactions

  addwebpayin*      create a payIn through web interface
  adddirectpayin*   create a direct payIn (with tokenized card)
  payin*            fetch a payIn

  addcard*          register a credit card
  card*             fetch a credit card
  cards*            list all user's cards

  addrefund*        refund a payment (provide TransferId or PayInId)
  refund*           fetch a refund (transfer or payin)

  addaccount*       create an IBAN bank account
  account*          fetch a user's bank account
  accounts*         list all user's bank accounts

  addpayout*        create a bank wire
  payout*           fetch a bank wire

Actions with an asterisk(*) require input JSON data (-d).

Options:
  -d="": JSON data part of the HTTP request
  -v=0: Verbosity level (1 for debug)

API Docs

The API is available on GoDoc.

License

MIT, see LICENSE.

Documentation

Overview

Package mango is a library for the MangoPay service v2.

MangoPay is a platform that allows to accept payments and manage e-money using wallets. See http://www.mangopay.com.

First, create an account with a unique Id to authenticate to the service:

conf, err := mango.RegisterClient("myclientid", "My Company",
    "contact@company.com", mango.Sandbox)
if err != nil {
    panic(err)
}

Or use existing credentials:

conf, err := mango.NewConfig("myclientid", "My Company",
    "contact@company.com", "passwd", "sandbox")

Then, choose an authentication mode (OAuth2.0 or Basic) to use with the service:

service, err := mango.NewMangoPay(conf, mango.OAuth)

Index

Constants

View Source
const (
	// PayIn web errors
	ErrUserNotRedirected                        = "001031"
	ErrUserCancelledPayment                     = "001031"
	ErrUserFillingPaymentCardDetails            = "001032"
	ErrUserNotRedirectedPaymentSessionExpired   = "001033"
	ErrUserLetPaymentSessionExpireWithoutPaying = "001034"

	// Generic transaction errors
	ErrUserNotCompleteTransaction = "101001"
	ErrTransactionCancelledByUser = "101002"
)

Variables

View Source
var DefaultClient = &http.Client{
	Transport: &http.Transport{

		TLSClientConfig: &tls.Config{MaxVersion: tls.VersionTLS12},
	},
}

The default HTTP client to use with the MangoPay api.

Functions

func AuthMethod

func AuthMethod(auth AuthMode) option

AuthMethod sets the preferred method for authenticating against the service.

func Verbosity

func Verbosity(v Level) option

Sets verbosity level. Default verbosity level is Info.

Types

type AccountType

type AccountType int

Bank account type.

const (
	IBAN AccountType = iota
	GB
	US
	CA
	OTHER
)

type AuthMode

type AuthMode int

AuthMode defines authentication methods for communicating with the service.

const (
	// Basic Access Authentication
	BasicAuth AuthMode = iota
	// OAuth 2.0, token based authentication
	OAuth
)

type BankAccount

type BankAccount struct {
	ProcessIdent
	Type         string // IBAN, GB, US, CA or OTHER
	OwnerName    string
	OwnerAddress string
	UserId       string
	// Required for IBAN type
	IBAN          string
	BIC           string // For IBAN, OTHER
	AccountNumber string // For GB, US, CA, OTHER
	// Required for GB type
	SortCode string
	// Required for US type
	ABA string
	// Required for CA type
	BankName          string
	InstitutionNumber string
	BranchCode        string
	// Required for OTHER type
	Country string
	// contains filtered or unexported fields
}

BankAccount is an item mainly used for pay-out bank wire request. It is used as a generic bank account container for all supported account types: IBAN, GB, US, CA or OTHER.

This way, only one structure is used to unmarshal any JSON response related to bank accounts.

See http://docs.mangopay.com/api-references/bank-accounts/

func (*BankAccount) Save

func (b *BankAccount) Save() error

Save sends the HTTP query to create the bank account.

func (*BankAccount) String

func (b *BankAccount) String() string

type BankAccountList

type BankAccountList []*BankAccount

List of bank accounts.

type BrowserInfo

type BrowserInfo struct {
	AcceptHeader      string `json:",omitempty"`
	JavaEnabled       bool   `json:",omitempty"`
	Language          string `json:",omitempty"`
	ColorDepth        int    `json:",omitempty"`
	ScreenHeight      int    `json:",omitempty"`
	ScreenWidth       int    `json:",omitempty"`
	TimeZoneOffset    int    `json:",omitempty"` //modified to int else the unmarshall in the save part does not work ? originally string
	UserAgent         string `json:",omitempty"`
	JavascriptEnabled bool   `json:",omitempty"`
}

BrowserInfo holds the filed

type Card

type Card struct {
	ProcessIdent
	ExpirationDate string // MMYY
	Alias          string // Obfuscated card number, i.e 497010XXXXXX4414
	CardProvider   string // CB, VISA, MASTERCARD etc.
	CardType       string // CB_VISA_MASTERCARD
	Product        string
	BankCode       string
	Active         bool
	Currency       string // Currency accepted in the waller, i.e EUR, USD etc.
	Validity       string // UNKNOWN, VALID, INVALID
	// contains filtered or unexported fields
}

Card holds all credit card details.

func (*Card) String

func (c *Card) String() string

type CardList

type CardList []*Card

List of cards.

type CardRegistration

type CardRegistration struct {
	ProcessReply
	// Id of the author.
	UserId string
	// Currency of the registered card.
	Currency string
	// Key sent with the card details and the PreregistrationData.
	AccessKey string
	// This passphrase is sent with the card details and the AccessKey.
	PreregistrationData string
	// The actual URL to POST the card details, the access key and the
	// PreregistrationData.
	CardRegistrationUrl string
	// Part of the reply, once the card details, the AccessKey and the
	// PreregistrationData has been sent.
	CardRegistrationData string
	CardType             string
	// CardId if part of the reply, once the CardRegistration has been
	// edited with the CardRegistrationData.
	CardId string
	// contains filtered or unexported fields
}

CardRegistration is used to register a credit card.

http://docs.mangopay.com/api-references/card-registration/

func (*CardRegistration) Init

func (c *CardRegistration) Init() error

Init initiates the process of getting pre-registration data and access key from MangoPay to allow a user to post his credit card info to the c.CardRegistrationUrl (which is an external banking service).

User's card details must be sent directly through an HTML form to the c.CardRegistrationUrl.

The HTML form must have the following input fields:

  • "data" (hidden) equals to c.PreregistrationData
  • "accessKeyRef" (hidden) equals to c.AccessKey
  • "cardNumber" equals to the user's credit card number
  • "cardExpirationDate" equals to the user's card expiration date (format: MMYY)
  • "cardCvx" equals to user's 3-digits cvx code
  • "returnURL" so we can retrieve the final registration data token

A successful call to Init() will fill in the PreregistrationData and AccessKey fields of the current CardRegistration object automatically.

func (*CardRegistration) Register

func (c *CardRegistration) Register(registrationData string) error

Register effectively registers the credit card against the MangoPay service. The registrationData value is returned by the external banking service that deals with the credit card information, and is obtained by submitting an HTML form to the external banking service.

func (*CardRegistration) String

func (c *CardRegistration) String() string

type Config

type Config struct {
	ClientId   string
	Name       string
	Email      string
	Passphrase string
	Env        string
	// contains filtered or unexported fields
}

Config hold environment credentials required for using the API.

See http://docs.mangopay.com/api-references/sandbox-credentials/

func NewConfig

func NewConfig(clientId, name, email, passwd, env string) (*Config, error)

NewConfig creates a config suitable for NewMangoPay().

func RegisterClient

func RegisterClient(clientId, name, email string, env ExecEnvironment) (*Config, error)

RegisterClient asks MangoPay to create a new client account.

func (*Config) String

func (c *Config) String() string

type Consumer

type Consumer interface {
	// All user's wallets
	Wallets() (WalletList, error)
	// All user's transactions
	Transfers() (TransferList, error)
}

A Consumer is a legal or natural user with zero, one or more wallets and tranfers.

type ConsumerList

type ConsumerList []Consumer

List of wallet's owners.

type DirectPayIn

type DirectPayIn struct {
	PayIn
	SecureModeReturnUrl   string
	CardId                string
	DebitedWalletId       string
	SecureModeNeeded      bool
	SecureModeRedirectUrl string
	// contains filtered or unexported fields
}

DirectPayIn is used to process a payment with registered (tokenized) cards.

func (*DirectPayIn) Save

func (p *DirectPayIn) Save() error

Save sends an HTTP query to create a direct payIn. Upon successful creation, it may return an ErrPayInFailed error if the payment has failed.

func (*DirectPayIn) String

func (p *DirectPayIn) String() string

type ErrPayInFailed

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

Custom error returned in case of failed payIn.

func (*ErrPayInFailed) Error

func (e *ErrPayInFailed) Error() string

type ErrPayOutFailed

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

Custom error returned in case of failed payOut.

func (*ErrPayOutFailed) Error

func (e *ErrPayOutFailed) Error() string

type ErrTransferFailed

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

Custom error returned in case of failed transaction.

func (*ErrTransferFailed) Error

func (e *ErrTransferFailed) Error() string

type Event

type Event struct {
	RessourceId string
	Type        EventType `json:"EventType"`
	Date        *time.Time
}

An event ressource.

type EventList

type EventList []*Event

type EventType

type EventType int
const (
	PAYIN_NORMAL_CREATED EventType = iota
	PAYIN_NORMAL_SUCCEEDED
	PAYIN_NORMAL_FAILED
	PAYOUT_NORMAL_CREATED
	PAYOUT_NORMAL_SUCCEEDED
	PAYOUT_NORMAL_FAILED
	TRANSFER_NORMAL_CREATED
	TRANSFER_NORMAL_SUCCEEDED
	TRANSFER_NORMAL_FAILED
	PAYIN_REFUND_CREATED
	PAYIN_REFUND_SUCCEEDED
	PAYIN_REFUND_FAILED
	PAYOUT_REFUND_CREATED
	PAYOUT_REFUND_SUCCEEDED
	PAYOUT_REFUND_FAILED
	TRANSFER_REFUND_CREATED
	TRANSFER_REFUND_SUCCEEDED
	TRANSFER_REFUND_FAILED
)

type ExecEnvironment

type ExecEnvironment int

Request execution environment (production or sandbox).

const (
	Production ExecEnvironment = iota
	Sandbox
)

type IBANBankAccount

type IBANBankAccount struct {
}

type JsonObject

type JsonObject map[string]interface{}

JsonObject is used to manage JSON data.

type LegalUser

type LegalUser struct {
	User
	Name                                  string
	LegalPersonType                       string
	HeadquartersAddress                   string
	LegalRepresentativeFirstName          string
	LegalRepresentativeLastName           string
	LegalRepresentativeAddress            string
	LegalRepresentativeEmail              string
	LegalRepresentativeBirthday           int64
	LegalRepresentativeNationality        string
	LegalRepresentativeCountryOfResidence string
	Statute                               string
	ProofOfRegistration                   string
	ShareholderDeclaration                string
	// contains filtered or unexported fields
}

LegalUser describes all the properties of a MangoPay legal user object.

func (*LegalUser) Save

func (u *LegalUser) Save() error

Save creates or updates a legal user. The Create API is used if the user's Id is an empty string. The Edit API is used when the Id is a non-empty string.

func (*LegalUser) String

func (u *LegalUser) String() string

func (*LegalUser) Transfers

func (u *LegalUser) Transfers() (TransferList, error)

Transfer gets all user's transaction.

func (*LegalUser) Wallets

func (u *LegalUser) Wallets() (WalletList, error)

Wallets returns user's wallets.

type Level

type Level int
const (
	Info Level = iota
	Debug
)

type MangoPay

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

The Mangopay service.

func NewMangoPay

func NewMangoPay(auth *Config, mode AuthMode) (*MangoPay, error)

NewMangoPay creates a suitable environment for accessing the web service. Default verbosity level is set to Info, which can be changed through the use of Option().

func (*MangoPay) BankAccount

func (m *MangoPay) BankAccount(user Consumer, id string) (*BankAccount, error)

BankAccount returns a user's bank account.

func (*MangoPay) BankAccounts

func (m *MangoPay) BankAccounts(user Consumer) (BankAccountList, error)

BankAccounts finds all user's bank accounts.

func (*MangoPay) Card

func (m *MangoPay) Card(id string) (*Card, error)

Card fetches a registered credit card.

func (*MangoPay) Cards

func (m *MangoPay) Cards(user Consumer) (CardList, error)

Card finds all user's cards.

func (*MangoPay) DeactivateCard

func (m *MangoPay) DeactivateCard(cardId string) (*Card, error)

Save creates or updates a legal user. The Create API is used if the user's Id is an empty string. The Edit API is used when the Id is a non-empty string.

func (*MangoPay) Events

func (m *MangoPay) Events() (EventList, error)

Events returns a list of all financial events. This include PayIns, PayOuts and transfers.

TODO: add support for pagination and date range.

func (*MangoPay) LegalUser

func (m *MangoPay) LegalUser(id string) (*LegalUser, error)

LegalUser finds a legal user using the user_id attribute.

func (*MangoPay) NaturalUser

func (m *MangoPay) NaturalUser(id string) (*NaturalUser, error)

NaturalUser finds a natural user using the user_id attribute.

func (*MangoPay) NewBankAccount

func (m *MangoPay) NewBankAccount(user Consumer, ownerName, ownerAddress string, t AccountType) (*BankAccount, error)

NewBankAccount creates a new bank account. Note that depending on the account's type, some fields of the newly BankAccount instance must be filled (they are required) before a call to Save().

See http://docs.mangopay.com/api-references/bank-accounts/

func (*MangoPay) NewCardRegistration

func (m *MangoPay) NewCardRegistration(user Consumer, currency string) (*CardRegistration, error)

NewCardRegistration creates a new credit card registration object that can be used to register a new credit card for a given user.

Registering a new credit card involves the following workflow:

  1. Create a new CardRegistration object
  2. Call .Init() to pre-register the card against MangoPay services and get access tokens required to register the credit card againts an external banking service
  3. Insert those tokens in an HTML form submitted by the user directly to the external banking service
  4. Get the final token from the external banking service
  5. Call .Register() with this token to commit credit card registration at MangoPay

See http://docs.mangopay.com/api-references/card-registration/

Example:

user := NewNaturalUser(...)
cr, err := NewCardRegistration(user, "EUR")
if err != nil {
    log.Fatal(err)
}
if err := cr.Init(); err != nil {
    log.Fatal(err)
}}

Now render an HTML form for user card details (see Init()). Once submitted, you get the final token as a string starting with "data=". Use this token to finally register the card:

if err := cr.Register(token); err != nil {
    log.Fatal(err)
}}

func (*MangoPay) NewDirectPayIn

func (m *MangoPay) NewDirectPayIn(from, to Consumer, src *Card, dst *Wallet, amount, fees Money, returnUrl string) (*DirectPayIn, error)

NewDirectPayIn creates a direct payment from a tokenized credit card.

  • from : AuthorId value
  • to : CreditedUserId value
  • src : CardId value
  • dst : CreditedWalletId value
  • amount : DebitedFunds value
  • fees : Fees value
  • returnUrl: SecureModeReturnUrl value

See http://docs.mangopay.com/api-references/payins/payindirectcard/

func (*MangoPay) NewDirectPayIn3DS2

func (m *MangoPay) NewDirectPayIn3DS2(from, to Consumer, src *Card, dst *Wallet, amount, fees Money, returnUrl string, secureMode string, ipAddress string, browserInfo *BrowserInfo) (*DirectPayIn, error)

NewDirectPayIn3DS2 creates a direct payment from a tokenized credit card.

  • from : AuthorId value
  • to : CreditedUserId value
  • src : CardId value
  • dst : CreditedWalletId value
  • amount : DebitedFunds value
  • fees : Fees value
  • returnUrl: SecureModeReturnUrl value
  • secureMode: SecureMode value
  • ipAddress : Ip Address of user
  • browserInfo : User's browser info

See http://docs.mangopay.com/api-references/payins/payindirectcard/

func (*MangoPay) NewLegalUser

func (m *MangoPay) NewLegalUser(name string, email string, personType string, legalFirstName, legalLastName string, birthday int64, nationality string, country string) *LegalUser

NewLegalUser creates a new legal user.

func (*MangoPay) NewNaturalUser

func (m *MangoPay) NewNaturalUser(first, last string, email string, birthday int64, nationality, country string) *NaturalUser

NewNaturalUser creates a new natural user.

func (*MangoPay) NewPayOut

func (m *MangoPay) NewPayOut(author Consumer, amount Money, fees Money, from *Wallet, to *BankAccount) (*PayOut, error)

NewPayOut creates a new bank wire.

func (*MangoPay) NewTransfer

func (m *MangoPay) NewTransfer(author Consumer, amount Money, fees Money, from, to *Wallet) (*Transfer, error)

NewTransfer creates a new tranfer (or transaction).

func (*MangoPay) NewWallet

func (m *MangoPay) NewWallet(owners ConsumerList, desc string, currency string) (*Wallet, error)

NewWallet creates a new wallet. Owners must have a well-defined Id. Empty Ids will return an error.

func (*MangoPay) NewWebPayIn

func (m *MangoPay) NewWebPayIn(author Consumer, amount Money, fees Money, credit *Wallet, returnUrl string, culture string, templateUrl *TemplateUrlOptions) (*WebPayIn, error)

NewWebPayIn creates a new payment.

func (*MangoPay) NewWebPayIn3DS2

func (m *MangoPay) NewWebPayIn3DS2(author Consumer, amount Money, fees Money, credit *Wallet, returnUrl string, culture string, templateUrl *TemplateUrlOptions, secureMode string) (*WebPayIn, error)

NewWebPayIn3DS2 creates a new payment.

func (*MangoPay) Option

func (m *MangoPay) Option(opts ...option)

Option set various options like verbosity etc.

func (*MangoPay) PayIn

func (m *MangoPay) PayIn(id string) (*WebPayIn, error)

PayIn finds a payment.

func (*MangoPay) PayOut

func (m *MangoPay) PayOut(id string) (*PayOut, error)

PayOut finds a bank wire.

func (*MangoPay) Refund

func (m *MangoPay) Refund(id string) (*Refund, error)

Refund fetches a refund (tranfer or payin).

func (*MangoPay) Transfer

func (m *MangoPay) Transfer(id string) (*Transfer, error)

Transfer finds a transaction by id.

func (*MangoPay) Transfers

func (m *MangoPay) Transfers(user Consumer) (TransferList, error)

Transfer finds all user's transactions. Provided for convenience.

func (*MangoPay) User

func (m *MangoPay) User(id string) (*User, error)

User fetch a user (natural or legal) using the Id attribute.

func (*MangoPay) Users

func (m *MangoPay) Users() (UserList, error)

Users returns a list of all registered users, either natural or legal.

func (*MangoPay) Wallet

func (m *MangoPay) Wallet(id string) (*Wallet, error)

Wallet finds a legal user using the user_id attribute.

func (*MangoPay) Wallets

func (m *MangoPay) Wallets(user Consumer) (WalletList, error)

Wallet finds all user's wallets. Provided for convenience.

type Money

type Money struct {
	Currency string
	Amount   int // in cents, i.e 120 for 1.20 EUR
}

Money specifies which currency and amount (in cents!) to use in a payment transaction.

func (Money) String

func (b Money) String() string

type NaturalUser

type NaturalUser struct {
	User
	FirstName, LastName string
	Address             string
	Birthday            int64
	Nationality         string
	CountryOfResidence  string
	Occupation          string
	IncomeRange         string
	ProofOfIdentity     string
	ProofOfAddress      string
	// contains filtered or unexported fields
}

NaturalUser describes all the properties of a MangoPay natural user object.

func (*NaturalUser) Save

func (u *NaturalUser) Save() error

Save creates or updates a natural user. The Create API is used if the user's Id is an empty string. The Edit API is used when the Id is a non-empty string.

func (*NaturalUser) String

func (u *NaturalUser) String() string

func (*NaturalUser) Transfers

func (u *NaturalUser) Transfers() (TransferList, error)

Transfer gets all user's transaction.

func (*NaturalUser) Wallets

func (u *NaturalUser) Wallets() (WalletList, error)

Wallets returns user's wallets.

type PayIn

type PayIn struct {
	ProcessReply
	AuthorId         string
	CreditedUserId   string
	DebitedFunds     Money
	Fees             Money
	CreditedWalletId string
	SecureMode       string
	CreditedFunds    Money
	Type             string // PAY_IN, PAY_OUT or TRANSFER
	Nature           string // REGULAR, REFUND or REPUDIATION
	PaymentType      string
	ExecutionType    string // WEB or DIRECT (with tokenized card)

	IpAddress   string       `json:",omitempty"`
	BrowserInfo *BrowserInfo `json:",omitempty"`
	// contains filtered or unexported fields
}

PayIn holds common fields to all MangoPay's supported payment means (through web, direct, preauthorized, bank wire).

func (*PayIn) CancelledByUser

func (p *PayIn) CancelledByUser() bool

Cancelled returns true if the payment has been cancelled by user.

func (*PayIn) Refund

func (p *PayIn) Refund() (*Refund, error)

Refund allows to refund a pay-in. Call the Refund's Save() method to make a request to reimburse a user on his payment card.

func (*PayIn) String

func (p *PayIn) String() string

type PayOut

type PayOut struct {
	ProcessReply
	AuthorId          string
	CreditedUserId    string
	DebitedFunds      Money
	Fees              Money
	Type              string // PAY_IN, PAY_OUT or TRANSFER
	Nature            string // REGULAR, REFUND or REPUDIATION
	PaymentType       string
	DebitedWalletId   string
	BankAccountId     string
	CreditedFunds     Money
	MeanOfPaymentType string
	// contains filtered or unexported fields
}

A PayOut Bank wire is a request to withdraw money from a wallet to a registered bank account.

See http://docs.mangopay.com/api-references/pay-out-bank-wire/

func (*PayOut) Save

func (p *PayOut) Save() error

Save sends an HTTP query to create a bank wire. It may return an ErrPayOutFailed error if the payment has failed.

func (*PayOut) String

func (p *PayOut) String() string

type ProcessIdent

type ProcessIdent struct {
	Id           string
	Tag          string
	CreationDate int64
}

ProcessIdent identifies the current operation.

type ProcessReply

type ProcessReply struct {
	ProcessIdent
	Status        string
	ResultCode    string
	ResultMessage string
	ExecutionDate int64
}

ProcessReply holds commong fields part of MangoPay API replies.

type Refund

type Refund struct {
	ProcessReply
	AuthorId               string
	DebitedFunds           Money
	Fees                   Money
	CreditedFunds          Money
	Type                   string // PAY_IN, PAY_OUT or TRANSFER
	Nature                 string
	CreditedUserId         string
	InitialTransactionId   string
	InitialTransactionType string
	DebitedWalletId        string
	CreditedWalletId       string
	// contains filtered or unexported fields
}

A refund is a request to pay a wallet back.

http://docs.mangopay.com/api-references/refund/%E2%80%A2-refund-a-transfer/

func (*Refund) String

func (r *Refund) String() string

type RefundList

type RefundList []*Refund

List of refunds.

type TemplateUrlOptions

type TemplateUrlOptions struct {
	Payline string `json:"PAYLINE"`
}

type Transfer

type Transfer struct {
	ProcessReply
	AuthorId         string
	CreditedUserId   string
	DebitedFunds     Money
	Fees             Money
	DebitedWalletId  string
	CreditedWalletId string
	CreditedFunds    Money
	// contains filtered or unexported fields
}

Transfer hold details about relocating e-money from a wallet to another one.

See http://docs.mangopay.com/api-references/transfers/.

func (*Transfer) Refund

func (t *Transfer) Refund() (*Refund, error)

func (*Transfer) Save

func (t *Transfer) Save() error

Save sends an HTTP query to create a transfer. Upon successful creation, it may return an ErrTransferFailed error if the transaction has been rejected (unsufficient wallet balance for example).

func (*Transfer) String

func (t *Transfer) String() string

type TransferList

type TransferList []*Transfer

List of transactions.

type User

type User struct {
	ProcessIdent
	PersonType string
	Email      string
}

User is used by the user activity API and describe common fields to both natural and legal users.

func (*User) String

func (u *User) String() string

type UserList

type UserList []*User

type Wallet

type Wallet struct {
	ProcessIdent
	Owners      []string
	Description string
	Currency    string
	Balance     Money
	// contains filtered or unexported fields
}

Wallet stores all payins and tranfers from users in order to collect money.

func (*Wallet) Save

func (w *Wallet) Save() error

Save creates or updates a legal user. The Create API is used if the user's Id is an empty string. The Edit API is used when the Id is a non-empty string.

func (*Wallet) String

func (u *Wallet) String() string

func (*Wallet) Transactions

func (w *Wallet) Transactions() (TransferList, error)

Transactions returns a wallet's transactions.

type WalletList

type WalletList []*Wallet

List of wallets.

type WebPayIn

type WebPayIn struct {
	PayIn
	ReturnUrl          string
	TemplateURLOptions *TemplateUrlOptions `json:",omitempty"`
	TemplateURL        string              `json:",omitempty"`
	Culture            string
	CardType           string
	RedirectUrl        string
	// contains filtered or unexported fields
}

WebPayIn hold details about making a payment through a web interface.

See http://docs.mangopay.com/api-references/payins/payins-card-web/

func (*WebPayIn) Save

func (t *WebPayIn) Save() error

Save sends an HTTP query to create a payIn. Upon successful creation, it may return an ErrPayInFailed error if the payment has failed.

func (*WebPayIn) String

func (p *WebPayIn) String() string

Directories

Path Synopsis
bin
mangopay
Package mango is a library for the MangoPay service v2.
Package mango is a library for the MangoPay service v2.

Jump to

Keyboard shortcuts

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