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
- Variables
- func AuthMethod(auth AuthMode) option
- func NewDefaultHTTPClientRetryWrap(client httpClient) *httpClientRetryWrap
- func Verbosity(v Level) option
- type AccountType
- type AuthMode
- type BankAccount
- type BankAccountList
- type BankingAlias
- type BankingAliasList
- type BankwireDirectPayIn
- type Card
- type CardList
- type CardRegistration
- type Config
- type Consumer
- type ConsumerList
- type DirectDebitWebPayIn
- type DirectPayIn
- type Document
- type DocumentList
- type DocumentRefusedReasonType
- type DocumentStatus
- type DocumentType
- type ErrPayInFailed
- type ErrPayOutFailed
- type ErrTransferFailed
- type Event
- type EventList
- type EventType
- type ExecEnvironment
- type HTTPError
- type Hook
- type HookList
- type IBANBankAccount
- type JsonObject
- type LegalUser
- type Level
- type MangoPay
- func (m *MangoPay) BankAccount(user Consumer, id string) (*BankAccount, error)
- func (m *MangoPay) BankAccounts(user Consumer) (BankAccountList, error)
- func (m *MangoPay) BankingAlias(id string) (*BankingAlias, error)
- func (m *MangoPay) BankingAliases(wallet Wallet) (BankAccountList, error)
- func (m *MangoPay) Card(id string) (*Card, error)
- func (m *MangoPay) Cards(user Consumer) (CardList, error)
- func (m *MangoPay) Document(id string) (*Document, error)
- func (m *MangoPay) Documents(user Consumer) (DocumentList, error)
- func (m *MangoPay) Events() (EventList, error)
- func (m *MangoPay) Hook(id string) (*Hook, error)
- func (m *MangoPay) HookByEventType(eventType EventType) (*Hook, error)
- func (m *MangoPay) Hooks() (HookList, error)
- func (m *MangoPay) LegalUser(id string) (*LegalUser, error)
- func (m *MangoPay) NaturalUser(id string) (*NaturalUser, error)
- func (m *MangoPay) NewBankAccount(user Consumer, ownerName, ownerAddress string, t AccountType) (*BankAccount, error)
- func (m *MangoPay) NewBankingAlias(wallet Wallet, ownerName string, country string) (*BankingAlias, error)
- func (m *MangoPay) NewBankwireDirectPayIn(author Consumer, credited *Wallet, amount, fees Money) (*BankwireDirectPayIn, error)
- func (m *MangoPay) NewCardRegistration(user Consumer, currency string) (*CardRegistration, error)
- func (m *MangoPay) NewDirectDebitWebPayIn(author Consumer, credited *Wallet, amount, fees Money, ...) (*DirectDebitWebPayIn, error)
- func (m *MangoPay) NewDirectPayIn(from, to Consumer, src *Card, dst *Wallet, amount, fees Money, ...) (*DirectPayIn, error)
- func (m *MangoPay) NewDocument(user Consumer, docType DocumentType, tag string) (*Document, error)
- func (m *MangoPay) NewHook(eventType EventType, url string) (*Hook, error)
- func (m *MangoPay) NewLegalUser(name string, email string, userCategory string, address string, ...) *LegalUser
- func (m *MangoPay) NewNaturalUser(first, last string, email string, userCategory string, birthday int64, ...) *NaturalUser
- func (m *MangoPay) NewPayOut(author Consumer, amount Money, fees Money, from *Wallet, to *BankAccount) (*PayOut, error)
- func (m *MangoPay) NewTransfer(author Consumer, amount Money, fees Money, from, to *Wallet) (*Transfer, error)
- func (m *MangoPay) NewWallet(owners ConsumerList, desc string, currency string) (*Wallet, error)
- func (m *MangoPay) NewWebPayIn(author Consumer, amount Money, fees Money, credit *Wallet, returnUrl string, ...) (*WebPayIn, error)
- func (m *MangoPay) Option(opts ...option)
- func (m *MangoPay) PayIn(id string) (*WebPayIn, error)
- func (m *MangoPay) PayOut(id string) (*PayOut, error)
- func (m *MangoPay) Refund(id string) (*Refund, error)
- func (m *MangoPay) Transfer(id string) (*Transfer, error)
- func (m *MangoPay) Transfers(user Consumer) (TransferList, error)
- func (m *MangoPay) User(id string) (*User, error)
- func (m *MangoPay) Users() (UserList, error)
- func (m *MangoPay) Wallet(id string) (*Wallet, error)
- func (m *MangoPay) Wallets(user Consumer) (WalletList, error)
- type Money
- type NaturalUser
- type PayIn
- type PayOut
- type ProcessIdent
- type ProcessReply
- type Refund
- type RefundList
- type RefundReason
- type TemplateUrlOptions
- type Transfer
- type TransferList
- type User
- type UserList
- type Wallet
- type WalletList
- type WebPayIn
Constants ¶
const ( // PayIn web errors ErrUserNotRedirected = "001031" ErrUserCancelledPayment = "001031" ErrUserFillingPaymentCardDetails = "001032" ErrUserNotRedirectedPaymentSessionExpired = "001033" ErrUserLetPaymentSessionExpireWithoutPaying = "001034" // Generic transaction errors ErrUserNotCompleteTransaction = "101001" ErrTransactionCancelledByUser = "101002" ErrTransactionAmountTooHigh = "001011" // 3DSecure errors Err3DSNotAvailable = "101399" Err3DSSessionExpired = "101304" Err3DSCardNotCompatible = "101303" Err3DSCardNotEnrolled = "101302" Err3DSAuthenticationFailed = "101301" )
const ( EventPayinNormalCreated EventType = "PAYIN_NORMAL_CREATED" EventPayinNormalSucceeded = "PAYIN_NORMAL_SUCCEEDED" EventPayinNormalFailed = "PAYIN_NORMAL_FAILED" EventPayoutNormalCreated = "PAYOUT_NORMAL_CREATED" EventPayoutNormalSucceeded = "PAYOUT_NORMAL_SUCCEEDED" EventPayoutNormalFailed = "PAYOUT_NORMAL_FAILED" EventTransferNormalCreated = "TRANSFER_NORMAL_CREATED" EventTransferNormalSucceeded = "TRANSFER_NORMAL_SUCCEEDED" EventTransferNormalFailed = "TRANSFER_NORMAL_FAILED" EventPayinRefundCreated = "PAYIN_REFUND_CREATED" EventPayinRefundSucceeded = "PAYIN_REFUND_SUCCEEDED" EventPayinRefundFailed = "PAYIN_REFUND_FAILED" EventPayoutRefundCreated = "PAYOUT_REFUND_CREATED" EventPayoutRefundSucceeded = "PAYOUT_REFUND_SUCCEEDED" EventPayoutRefundFailed = "PAYOUT_REFUND_FAILED" EventTransferRefundCreated = "TRANSFER_REFUND_CREATED" EventTransferRefundSucceeded = "TRANSFER_REFUND_SUCCEEDED" EventTransferRefundFailed = "TRANSFER_REFUND_FAILED" EventPayinRepudiationCreated = "PAYIN_REPUDIATION_CREATED" EventPayinRepudiationSucceeded = "PAYIN_REPUDIATION_SUCCEEDED" EventPayinRepudiationFailed = "PAYIN_REPUDIATION_FAILED" EventKycCreated = "KYC_CREATED" EventKycSucceeded = "KYC_SUCCEEDED" EventKycFailed = "KYC_FAILED" EventKycValidationAsked = "KYC_VALIDATION_ASKED" EventDisputeDocumentCreated = "DISPUTE_DOCUMENT_CREATED" EventDisputeDocumentValidationAsked = "DISPUTE_DOCUMENT_VALIDATION_ASKED" EventDisputeDocumentSucceeded = "DISPUTE_DOCUMENT_SUCCEEDED" EventDisputeDocumentFailed = "DISPUTE_DOCUMENT_FAILED" EventDisputeCreated = "DISPUTE_CREATED" EventDisputeSubmitted = "DISPUTE_SUBMITTED" EventDisputeActionRequired = "DISPUTE_ACTION_REQUIRED" EventDisputeFurtherActionRequired = "DISPUTE_FURTHER_ACTION_REQUIRED" EventDisputeClosed = "DISPUTE_CLOSED" EventDisputeSentToBank = "DISPUTE_SENT_TO_BANK" EventTransferSettlementCreated = "TRANSFER_SETTLEMENT_CREATED" EventTransferSettlementSucceeded = "TRANSFER_SETTLEMENT_SUCCEEDED" EventTransferSettlementFailed = "TRANSFER_SETTLEMENT_FAILED" EventMandateCreated = "MANDATE_CREATED" EventMandatedFailed = "MANDATED_FAILED" EventMandateActivated = "MANDATE_ACTIVATED" EventMandateSubmitted = "MANDATE_SUBMITTED" )
const ( TransactionNatureRegular = "REGULAR" TransactionNatureRepudiation = "REPUDIATION" TransactionNatureRefund = "REFUND" TransactionNature = "SETTLEMENT" )
const ( TransactionStatusCreated = "CREATED" TransactionStatusSucceeded = "SUCCEEDED" TransactionStatusFailed = "FAILED" )
const ( TransactionTypePayIn = "PAYIN" TransactionTypeTransfer = "TRANSFER" TransactionTypePayOut = "PAYOUT" )
const ( PayInPaymentTypeCard = "CARD" PayInPaymentTypeDirectDebit = "DIRECT_DEBIT" PayInPaymentTypeBankWire = "BANK_WIRE" )
const ( PayInExecutionTypeWeb = "WEB" PayInExecutionTypeDirect = "DIRECT" )
const ( CardTypeCBVisaMasterCard = "CB_VISA_MASTERCARD" CardTypeAmex = "AMEX" CardTypeDiners = "DINERS" CardTypeMasterPass = "MASTERPASS" CardTypeMaestro = "MAESTRO" CardTypeP24 = "P24" CardTypeIdeal = "IDEAL" CardTypeBcMC = "BCMC" CardTypePaylib = "PAYLIB" )
const ( SecureModeDefault = "DEFAULT" SecureModeForce = "FORCE" )
const ( DirectDebitTypeSofort = "SOFORT" DirectDebitTypeELV = "ELV" DirectDebitTypeGiroPay = "GIROPAY" )
const ( RefundReasonInitializedByClient = "INITIALIZED_BY_CLIENT" RefundReasonBankaccountIncorrect = "BANKACCOUNT_INCORRECT" RefundReasonOwnerDoNotMatchBankaccount = "OWNER_DOT_NOT_MATCH_BANKACCOUNT" RefundReasonBankaccountHasBeenClosed = "BANKACCOUNT_HAS_BEEN_CLOSED" RefundReasonWithdrawalImpossibleOnSavingsAccounts = "WITHDRAWAL_IMPOSSIBLE_ON_SAVINGS_ACCOUNTS" RefundReasonOther = "OTHER" )
const ( KYCLevelLight = "LIGHT" KYCLevelRegular = "REGULAR" )
const ( PersonTypeNatural = "NATURAL" PersonTypeLegal = "LEGAL" )
const ( FundsTypeDefault = "DEFAULT" FundsTypeFees = "FEES" FundsTypeCreadit = "CREDIT" )
const PayinFailedAmountTooHigh = "Transaction amount is higher than maximum permitted amount"
PayinFailedAmountTooHigh is ErrPayInFailed.Msg value when transaction amount is too high.
Variables ¶
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 NewDefaultHTTPClientRetryWrap ¶
func NewDefaultHTTPClientRetryWrap(client httpClient) *httpClientRetryWrap
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.
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 BankingAlias ¶
type BankingAlias struct { ProcessIdent CreditedUserId string WalletId string Type string // IBAN Country string OwnerName string Active bool IBAN string BIC string // contains filtered or unexported fields }
func (*BankingAlias) Save ¶
func (b *BankingAlias) Save() error
Save sends the HTTP query to create the bank alias.
type BankwireDirectPayIn ¶
type BankwireDirectPayIn struct { PayIn DeclaredDebitedFunds Money DeclaredFees Money WireReference string `json:",omitempty"` BankAccount map[string]string `json:",omitempty"` }
func (*BankwireDirectPayIn) Save ¶
func (t *BankwireDirectPayIn) Save() error
func (*BankwireDirectPayIn) String ¶
func (p *BankwireDirectPayIn) String() string
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 }
Card holds all credit card details.
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 RegisterClient ¶
func RegisterClient(clientId, name, email string, env ExecEnvironment) (*Config, error)
RegisterClient asks MangoPay to create a new client account.
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 DirectDebitWebPayIn ¶
type DirectDebitWebPayIn struct { PayIn RedirectURL string `json:,omitempty` ReturnURL string DirectDebitType string Culture string TemplateURLOptions *TemplateUrlOptions `json:",omitempty"` TemplateURL string `json:",omitempty"` }
func (*DirectDebitWebPayIn) Save ¶
func (t *DirectDebitWebPayIn) Save() error
func (*DirectDebitWebPayIn) String ¶
func (p *DirectDebitWebPayIn) String() string
type DirectPayIn ¶
type DirectPayIn struct { PayIn SecureModeReturnUrl string SecureModeRedirectURL string CardId string DebitedWalletId 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 Document ¶
type Document struct { ProcessIdent UserId string Status DocumentStatus Type DocumentType RefusedReasonMessage string RefusedReasonType DocumentRefusedReasonType // contains filtered or unexported fields }
func (*Document) CreatePage ¶
type DocumentList ¶
type DocumentList []*Document
type DocumentRefusedReasonType ¶
type DocumentRefusedReasonType string
const ( DocumentRefusedReasonTypeUnreadable DocumentRefusedReasonType = "DOCUMENT_UNREADABLE" DocumentRefusedReasonTypeNotAccepted DocumentRefusedReasonType = "DOCUMENT_NOT_ACCEPTED" DocumentRefusedReasonTypeHasExpired DocumentRefusedReasonType = "DOCUMENT_HAS_EXPIRED" DocumentRefusedReasonTypeIncomplete DocumentRefusedReasonType = "DOCUMENT_INCOMPLETE" DocumentRefusedReasonTypeNotMatchUserData DocumentRefusedReasonType = "DOCUMENT_DO_NOT_MATCH_USER_DATA" DocumentRefusedReasonTypeNotMatchAccountData DocumentRefusedReasonType = "DOCUMENT_DO_NOT_MATCH_ACCOUNT_DATA" DocumentRefusedReasonTypeFalsified DocumentRefusedReasonType = "DOCUMENT_FALSIFIED" DocumentRefusedReasonTypeUnderagePerson DocumentRefusedReasonType = "UNDERAGE PERSON" DocumentRefusedReasonTypeSpecificCase DocumentRefusedReasonType = "SPECIFIC_CASE" )
type DocumentStatus ¶
type DocumentStatus string
const ( DocumentStatusCreated DocumentStatus = "CREATED" DocumentStatusValidationAsked DocumentStatus = "VALIDATION_ASKED" DocumentStatusValidated DocumentStatus = "VALIDATED" DocumentStatusRefused DocumentStatus = "REFUSED" )
type DocumentType ¶
type DocumentType string
const ( IdentityProof DocumentType = "IDENTITY_PROOF" RegistrationProof DocumentType = "REGISTRATION_PROOF" ArticlesOfAssociation DocumentType = "ARTICLES_OF_ASSOCIATION" AddressProof DocumentType = "ADDRESS_PROOF" )
type ErrPayInFailed ¶
ErrPayInFailed is 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 { ResourceId string `json:"RessourceId"` // ReSSource - Mistake in MangoPay API Type EventType `json:"EventType"` Date time.Time }
An event ressource.
type ExecEnvironment ¶
type ExecEnvironment int
Request execution environment (production or sandbox).
const ( Production ExecEnvironment = iota Sandbox )
type Hook ¶
type Hook struct { ProcessIdent Url string EventType EventType Status string Validity string // contains filtered or unexported fields }
type IBANBankAccount ¶
type IBANBankAccount struct { }
type LegalUser ¶
type LegalUser struct { User Name string LegalPersonType string UserCategory string HeadquartersAddress string LegalRepresentativeFirstName string LegalRepresentativeLastName string LegalRepresentativeAddress string LegalRepresentativeEmail string LegalRepresentativeBirthday int64 LegalRepresentativeNationality string LegalRepresentativeCountryOfResidence string Statute string ProofOfRegistration string CompanyNumber string TermsAndConditionsAccepted bool // contains filtered or unexported fields }
LegalUser describes all the properties of a MangoPay legal user object.
func (*LegalUser) Save ¶
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) 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 MangoPay ¶
type MangoPay struct {
// contains filtered or unexported fields
}
The Mangopay service.
func NewMangoPay ¶
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) BankingAlias ¶
func (m *MangoPay) BankingAlias(id string) (*BankingAlias, error)
BankingAlias returns a user's banking alias.
func (*MangoPay) BankingAliases ¶
func (m *MangoPay) BankingAliases(wallet Wallet) (BankAccountList, error)
BankingAliases finds all user's bank aliases.
func (*MangoPay) Events ¶
Events returns a list of all financial events. This include PayIns, PayOuts and transfers.
TODO: add support for pagination and date range.
func (*MangoPay) HookByEventType ¶
HookByEventType returns the only hook for given event type. see https://docs.mangopay.com/endpoints/v2.01/hooks#e247_create-a-hook
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().
func (*MangoPay) NewBankingAlias ¶
func (m *MangoPay) NewBankingAlias(wallet Wallet, ownerName string, country string) (*BankingAlias, error)
NewBankingAlias creates a new banking alias.
See https://docs.mangopay.com/endpoints/v2.01/banking-aliases
func (*MangoPay) NewBankwireDirectPayIn ¶
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:
- Create a new CardRegistration object
- 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
- Insert those tokens in an HTML form submitted by the user directly to the external banking service
- Get the final token from the external banking service
- 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) NewDirectDebitWebPayIn ¶
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 (optional, defaults to dst owner)
- 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) NewDocument ¶
func (*MangoPay) NewLegalUser ¶
func (m *MangoPay) NewLegalUser(name string, email string, userCategory string, address string, companyNumber string, personType string, legalFirstName string, legalLastName string, birthday int64, nationality string, country string, terms bool) *LegalUser
NewLegalUser creates a new legal user.
func (*MangoPay) NewNaturalUser ¶
func (m *MangoPay) NewNaturalUser(first, last string, email string, userCategory string, birthday int64, nationality, country string, terms bool) *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 ¶
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, cardType string, culture string, templateUrl *TemplateUrlOptions) (*WebPayIn, error)
NewWebPayIn creates a new payment.
func (*MangoPay) Option ¶
func (m *MangoPay) Option(opts ...option)
Option set various options like verbosity etc.
func (*MangoPay) Transfers ¶
func (m *MangoPay) Transfers(user Consumer) (TransferList, error)
Transfer finds all user's transactions. Provided for convenience.
type NaturalUser ¶
type NaturalUser struct { User FirstName, LastName string Address string UserCategory string TermsAndConditionsAccepted bool Birthday int64 Nationality string CountryOfResidence string Occupation string IncomeRange int 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 `json:",omitempty"` 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) // 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 ¶
Cancelled returns true if the payment has been cancelled by user.
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 BankWireRef 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/
type ProcessIdent ¶
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 RefundReason RefundReason // 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/
type RefundReason ¶
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.
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.
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 ¶
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) Transactions ¶
func (w *Wallet) Transactions() (TransferList, error)
Transactions returns a wallet's transactions.
type WebPayIn ¶
type WebPayIn struct { PayIn ReturnUrl string TemplateURLOptions *TemplateUrlOptions `json:",omitempty"` TemplateURL string `json:",omitempty"` Culture string CardType string RedirectUrl string DirectDebitType string `json:",omitempty"` WireReference string `json:",omitempty"` BankAccount json.RawMessage `json:",omitempty"` Tag string `json:",omitempty"` // 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/