pagarme

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Object       string `json:"object,omitempty" form:"object,omitempty"`
	ID           int64  `json:"id,omitempty" form:"id,omitempty"`
	Street       string `json:"street" form:"street"`
	StreetNumber string `json:"street_number" form:"street_number"`
	// CEP. Para endereço brasileiro, deve conter uma numeração de 8 dígitos
	Zipcode string `json:"zipcode" form:"zipcode"`
	// Obrigatório. País. Duas letras minúsculas. Deve seguir o padão ISO 3166-1 alpha-2
	Country       CountryCode `json:"country" form:"country"`
	State         string      `json:"state" form:"state"`
	City          string      `json:"city" form:"city"`
	Neighborhood  string      `json:"neighborhood,omitempty" form:"neighborhood,omitempty"`
	Complementary string      `json:"complementary,omitempty" form:"complementary,omitempty"`
}

Address TBD

type BankAccount added in v0.0.7

type BankAccount struct {
	BankAccountID  string          `json:"bank_account_id,omitempty"`
	BankCode       string          `json:"bank_code,omitempty"`
	Agencia        string          `json:"agencia,omitempty"`
	AgenciaDV      string          `json:"agencia_dv,omitempty"`
	Conta          string          `json:"conta,omitempty"`
	ContaDV        string          `json:"conta_dv,omitempty"`
	DocumentNumber string          `json:"document_number,omitempty"`
	LegalName      string          `json:"legal_name,omitempty"`
	Type           BankAccountType `json:"type,omitempty"`
}

type BankAccountType

type BankAccountType string
const (
	BnkAccContaCorrente         BankAccountType = "conta_corrente"
	BnkAccContaPoupanca         BankAccountType = "conta_poupanca"
	BnkAccContaCorrenteConjunta BankAccountType = "conta_corrente_conjunta"
	BnkAccContaPoupancaConjunta BankAccountType = "conta_poupanca_conjunta"
)

type Billing

type Billing struct {
	Address *Address `json:"address,omitempty" form:"address,omitempty"`
	Object  string   `json:"object,omitempty" form:"object,omitempty"`
	ID      int64    `json:"id,omitempty" form:"id,omitempty"`
	Name    string   `json:"name,omitempty" form:"name,omitempty"`
}

type Card

type Card struct {
	Object         string    `json:"object,omitempty" form:"object,omitempty"`
	ID             string    `json:"id,omitempty" form:"id,omitempty"`
	DateCreated    time.Time `json:"date_created,omitempty" form:"date_created,omitempty"`
	DateUpdated    time.Time `json:"date_updated,omitempty" form:"date_updated,omitempty"`
	Brand          string    `json:"brand,omitempty" form:"brand,omitempty"`
	HolderName     string    `json:"holder_name,omitempty" form:"holder_name,omitempty"`
	FirstDigits    string    `json:"first_digits,omitempty" form:"first_digits,omitempty"`
	LastDigits     string    `json:"last_digits,omitempty" form:"last_digits,omitempty"`
	Country        string    `json:"country,omitempty" form:"country,omitempty"`
	Fingerprint    string    `json:"fingerprint,omitempty" form:"fingerprint,omitempty"`
	Valid          bool      `json:"valid,omitempty" form:"valid,omitempty"`
	ExpirationDate MMYY      `json:"expiration_date,omitempty" form:"expiration_date,omitempty"`
}

type Config

type Config struct {
	Apikey    string
	Cryptokey string
	Client    *http.Client
	Trace     bool
	Logger    *zap.Logger
}

Config holds the config of pagarme

func Default

func Default(apikey, cryptokey string) *Config

Default configuration uses:

HTTP Client with 60 seconds timeout os.stdout for logging loglevel: error

func (*Config) Do

func (c *Config) Do(method, urlpart string, body io.Reader) (*http.Response, error)

type CountryCode

type CountryCode string
const (
	Brazil CountryCode = "br"
)

func (CountryCode) IsValid

func (cc CountryCode) IsValid() bool

type Customer

type Customer struct {
	Object       string       `json:"object,omitempty" form:"object,omitempty"`
	ID           int64        `json:"id,omitempty" form:"id,omitempty"`
	ExternalID   string       `json:"external_id,omitempty" form:"external_id,omitempty"`
	Type         CustomerType `json:"type" form:"type"`
	Name         string       `json:"name,omitempty" form:"name,omitempty"`
	Email        string       `json:"email,omitempty" form:"email,omitempty"`
	Country      CountryCode  `json:"country,omitempty" form:"country,omitempty"`
	Birthday     YYYYMMDD     `json:"birthday,omitempty" form:"birthday,omitempty"`
	Gender       string       `json:"gender,omitempty" form:"gender,omitempty"`
	Documents    []*Document  `json:"documents,omitempty" form:"documents,omitempty"`
	PhoneNumbers []string     `json:"phone_numbers,omitempty" form:"phone_numbers,omitempty"`
}

Customer TODO: godoc

type CustomerType

type CustomerType string
const (
	CustomerIndividual  CustomerType = "individual"
	CustomerCorporation CustomerType = "corporation"
)

type Document

type Document struct {
	Object string       `json:"object,omitempty" form:"object,omitempty"`
	ID     string       `json:"id,omitempty" form:"id,omitempty"`
	Type   DocumentType `json:"type,omitempty" form:"type,omitempty"`
	Number string       `json:"number,omitempty" form:"number,omitempty"`
}

Document TBD

type DocumentType

type DocumentType string
const (
	DocCPF      DocumentType = "cpf"
	DocCNPJ     DocumentType = "cnpj"
	DocPassport DocumentType = "passport"
)

type Float64String added in v0.0.2

type Float64String float64

func (*Float64String) MarshalJSON added in v0.0.2

func (n *Float64String) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (*Float64String) Scan added in v0.0.2

func (n *Float64String) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*Float64String) UnmarshalJSON added in v0.0.2

func (n *Float64String) UnmarshalJSON(v []byte) error

UnmarshalJSON implements json.Unmarshaler

func (Float64String) Value added in v0.0.2

func (n Float64String) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Int64String added in v0.0.9

type Int64String int64

func (*Int64String) MarshalJSON added in v0.0.9

func (n *Int64String) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (*Int64String) Scan added in v0.0.9

func (n *Int64String) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*Int64String) UnmarshalJSON added in v0.0.9

func (n *Int64String) UnmarshalJSON(v []byte) error

UnmarshalJSON implements json.Unmarshaler

func (Int64String) Value added in v0.0.9

func (n Int64String) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Item

type Item struct {
	ID        string `json:"id,omitempty" form:"id,omitempty"`
	Object    string `json:"object,omitempty" form:"object,omitempty"`
	Title     string `json:"title,omitempty" form:"title,omitempty"`
	UnitPrice int    `json:"unit_price,omitempty" form:"unit_price,omitempty"`
	Quantity  int    `json:"quantity,omitempty" form:"quantity,omitempty"`
	Category  string `json:"category,omitempty" form:"category,omitempty"`
	Tangible  bool   `json:"tangible,omitempty" form:"tangible,omitempty"`
	Venue     string `json:"venue,omitempty" form:"venue,omitempty"`
	Date      string `json:"date,omitempty" form:"date,omitempty"`
}

Item TODO: godoc

type MMYY

type MMYY string

MMYY represents a two digit MM (month) and YY (last two digits of the year) combined

func (MMYY) Month added in v0.0.2

func (s MMYY) Month() time.Month

Month returns the month

func (MMYY) Year added in v0.0.2

func (s MMYY) Year(prefix ...string) int

Year returns the year

type NCard added in v0.0.10

type NCard struct {
	CardNumber     string `json:"card_number"`
	HolderName     string `json:"card_holder_name"`
	ExpirationDate string `json:"card_expiration_date"`
	CVV            string `json:"card_cvv"`
}

type Payable added in v0.0.5

type Payable struct {
	Object           string        `json:"object"`
	ID               int           `json:"id"`
	Status           PayableStatus `json:"status"`
	Amount           int           `json:"amount"`
	Fee              int           `json:"fee"`
	AnticipationFee  int           `json:"anticipation_fee"`
	FraudCoverageFee int           `json:"fraud_coverage_fee"`
	Installment      int           `json:"installment"`
	TransactionID    int           `json:"transaction_id"`
	SplitRuleID      string        `json:"split_rule_id,omitempty"`
	//TODO: bulk_anticipation_id
	RecipientID         string        `json:"recipient_id,omitempty"`
	PaymentDate         time.Time     `json:"payment_date"`
	OriginalPaymentDate time.Time     `json:"original_payment_date,omitempty"`
	Type                PayableType   `json:"type"`
	PaymentMethod       PaymentMethod `json:"payment_method"`
	AccrualDate         time.Time     `json:"accrual_date,omitempty"`
	DateCreated         time.Time     `json:"date_created"`
}

Payable -> Objeto-resposta Recebível

Objeto contendo os dados de um recebível. O recebível (payable) é gerado automaticamente após uma transação ser paga. Para cada parcela de uma transação é gerado um recebível, que também pode ser dividido por recebedor (no caso de um split ter sido feito).

type PayableStatus added in v0.0.5

type PayableStatus string
const (
	PbsPaid         PayableStatus = "paid"
	PbsWaitingFunds PayableStatus = "waiting_funds"
)

type PayableType added in v0.0.5

type PayableType string
const (
	PtChargeback       PayableType = "chargeback"
	PtRefund           PayableType = "refund"
	PtChargebackRefund PayableType = "chargeback_refund"
	PtCredit           PayableType = "credit"
)

type PaymentMethod

type PaymentMethod string
const (
	PaymentCreditCard PaymentMethod = "credit_card"
	PaymentBoleto     PaymentMethod = "boleto"
)

type Perror

type Perror struct {
	Message       string `json:"message,omitempty" form:"message,omitempty"`
	ParameterName string `json:"parameter_name,omitempty" form:"parameter_name,omitempty"`
	Type          string `json:"type,omitempty" form:"type,omitempty"`
}

type Querier added in v0.0.5

type Querier interface {
	Format() string
	PName() string
}

type QueryBuilder added in v0.0.5

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

func (*QueryBuilder) Add added in v0.0.5

func (b *QueryBuilder) Add(q Querier)

Add a querier item

func (*QueryBuilder) Build added in v0.0.5

func (b *QueryBuilder) Build() string

Build the query

func (*QueryBuilder) Get added in v0.1.2

func (b *QueryBuilder) Get(name string) Querier

Get a querier item

func (*QueryBuilder) Set added in v0.1.1

func (b *QueryBuilder) Set(q Querier)

Set a querier item

type QueryInt added in v0.0.5

type QueryInt struct {
	Name string
	Op   QueryOp
	V    int
}

QueryInt is used on integer queries

func (*QueryInt) Format added in v0.0.5

func (qt *QueryInt) Format() string

Format to pagarme query

func (*QueryInt) PName added in v0.1.1

func (qt *QueryInt) PName() string

PName of the query param

type QueryOp added in v0.0.5

type QueryOp string

QueryOp is the operator of a query item

const (
	// QueryOpEquals =
	QueryOpEquals QueryOp = "="
	// QueryOpGreaterThan >
	QueryOpGreaterThan QueryOp = "=%3E"
	// QueryOpLessThan <
	QueryOpLessThan QueryOp = "=%3C"
	// QueryOpGreaterOrEqualThan >=
	QueryOpGreaterOrEqualThan QueryOp = "=%3E%3D"
	// QueryOpLessOrEqualThan <=
	QueryOpLessOrEqualThan QueryOp = "=%3C%3D"
)

type QueryString added in v0.0.5

type QueryString struct {
	Name string
	Op   QueryOp
	V    string
}

QueryString is used on string queries

func (*QueryString) Format added in v0.0.5

func (qt *QueryString) Format() string

Format to pagarme query

func (*QueryString) PName added in v0.1.1

func (qt *QueryString) PName() string

PName of the query param

type QueryTime added in v0.0.5

type QueryTime struct {
	Name string
	Op   QueryOp
	T    time.Time
}

QueryTime is used on datetime queries

func (*QueryTime) Format added in v0.0.5

func (qt *QueryTime) Format() string

Format to pagarme query

func (*QueryTime) PName added in v0.1.1

func (qt *QueryTime) PName() string

PName of the query param

type Response

type Response struct {
	Code   ResponseCode `json:"code,omitempty" form:"code,omitempty"`
	Errors []Perror     `json:"errors,omitempty" form:"errors,omitempty"`
	URL    string       `json:"url,omitempty" form:"url,omitempty"`
	Method string       `json:"method,omitempty" form:"method,omitempty"`
}

func (*Response) String

func (r *Response) String() string

type ResponseCode

type ResponseCode int
const (
	// ResponseCodeOk 200 - Tudo ocorreu como deveria e sua requisição foi processada com sucesso.
	ResponseCodeOk ResponseCode = 200
	// ResponseCodeMissingParameter 400 - Algum parâmetro obrigatório não foi passado, ou os parâmetros passados não estão corretos.
	ResponseCodeMissingParameter ResponseCode = 400
	ResponseCodeAuthError        ResponseCode = 401
	ResponseCodeNotFound         ResponseCode = 404
	ResponseCodeInternalError    ResponseCode = 500
)

type Shipping

type Shipping struct {
	Address      *Address `json:"address,omitempty" form:"address,omitempty"`
	Object       string   `json:"object,omitempty" form:"object,omitempty"`
	ID           int64    `json:"id,omitempty" form:"id,omitempty"`
	Name         string   `json:"name,omitempty" form:"name,omitempty"`
	Fee          int      `json:"fee" form:"fee"`
	DeliveryDate YYYYMMDD `json:"delivery_date,omitempty" form:"delivery_date,omitempty"`
	Expedited    bool     `json:"expedited,omitempty" form:"expedited,omitempty"`
}

type SplitRule

type SplitRule struct {
	Object              string        `json:"object,omitempty" form:"object,omitempty"`
	ID                  string        `json:"id,omitempty" form:"id,omitempty"`
	Liable              bool          `json:"liable" form:"liable"`
	ChargeProcessingFee bool          `json:"charge_processing_fee" form:"charge_processing_fee"`
	Percentage          Float64String `json:"percentage,omitempty" form:"percentage,omitempty"`
	Amount              Int64String   `json:"amount,omitempty" form:"amount,omitempty"`
	ChargeRemainderFee  bool          `json:"charge_remainder_fee" form:"charge_remainder_fee"`
	RecipientID         string        `json:"recipient_id" form:"recipient_id"`
	DateCreated         time.Time     `json:"date_created" form:"date_created"`
	DateUpdated         time.Time     `json:"date_updated" form:"date_updated"`
	BlockID             string        `json:"block_id" form:"block_id"`
}

SplitRule TBD

type TrStatus

type TrStatus string
const (
	TrProcessing     TrStatus = "processing"
	TrAuthorized     TrStatus = "authorized"
	TrPaid           TrStatus = "paid"
	TrRefunded       TrStatus = "refunded"
	TrWaitingPayment TrStatus = "waiting_payment"
	TrPendingRefund  TrStatus = "pending_refund"
	TrRefused        TrStatus = "refused"
)

type Transaction

type Transaction struct {
	Amount               int                    `json:"amount" form:"amount"`
	CardHash             string                 `json:"card_hash,omitempty" form:"card_hash,omitempty"`
	CardID               string                 `json:"card_id,omitempty" form:"card_id,omitempty"`
	CardHolderName       string                 `json:"card_holder_name,omitempty" form:"card_holder_name,omitempty"`
	CardExpirationDate   MMYY                   `json:"card_expiration_date,omitempty" form:"card_expiration_date,omitempty"`
	CardNumber           string                 `json:"card_number,omitempty" form:"card_number,omitempty"`
	CardCVV              string                 `json:"card_cvv,omitempty" form:"card_cvv,omitempty"`
	PaymentMethod        PaymentMethod          `json:"payment_method,omitempty" form:"payment_method,omitempty"`
	PostbackURL          string                 `json:"postback_url,omitempty" form:"postback_url,omitempty"`
	Async                bool                   `json:"async,omitempty" form:"async,omitempty"`
	Installments         int                    `json:"installments,omitempty" form:"installments,omitempty"`
	BoletoExpirationDate string                 `json:"boleto_expiration_date,omitempty" form:"boleto_expiration_date,omitempty"`
	SoftDescriptor       string                 `json:"soft_descriptor,omitempty" form:"soft_descriptor,omitempty"`
	Capture              string                 `json:"capture,omitempty" form:"capture,omitempty"`
	BoletoInstructions   string                 `json:"boleto_instructions,omitempty" form:"boleto_instructions,omitempty"`
	SplitRules           []*SplitRule           `json:"split_rules,omitempty" form:"split_rules,omitempty"`
	Customer             *Customer              `json:"customer" form:"customer"`
	Billing              *Billing               `json:"billing" form:"billing"`
	Shipping             *Shipping              `json:"shipping" form:"shipping"`
	Items                []*Item                `json:"items,omitempty" form:"items,omitempty"`
	Metadata             map[string]interface{} `json:"metadata,omitempty" form:"metadata,omitempty"`
	Session              string                 `json:"session,omitempty" form:"session,omitempty"`
	LocalTime            *time.Time             `json:"local_time,omitempty" form:"local_time,omitempty"`
	//
	// Data returned by pagar-me
	//
	Object               string     `json:"object,omitempty" form:"object,omitempty"`
	Status               TrStatus   `json:"status,omitempty" form:"status,omitempty"`
	RefuseReason         string     `json:"refuse_reason,omitempty" form:"refuse_reason,omitempty"`
	StatusReason         string     `json:"status_reason,omitempty" form:"status_reason,omitempty"`
	AcquirerResponseCode string     `json:"acquirer_response_code,omitempty" form:"acquirer_response_code,omitempty"`
	AcquirerName         string     `json:"acquirer_name,omitempty" form:"acquirer_name,omitempty"`
	AcquirerID           string     `json:"acquirer_id,omitempty" form:"acquirer_id,omitempty"`
	AuthorizationCode    string     `json:"authorization_code,omitempty" form:"authorization_code,omitempty"`
	TID                  int        `json:"tid,omitempty" form:"tid,omitempty"`
	NSU                  int        `json:"nsu,omitempty" form:"nsu,omitempty"`
	DateCreated          *time.Time `json:"date_created,omitempty" form:"date_created,omitempty"`
	DateUpdated          *time.Time `json:"date_updated,omitempty" form:"date_updated,omitempty"`
	AuthorizedAmount     int        `json:"authorized_amount,omitempty" form:"authorized_amount,omitempty"`
	PaidAmount           int        `json:"paid_amount,omitempty" form:"paid_amount,omitempty"`
	RefundedAmount       int        `json:"refunded_amount,omitempty" form:"refunded_amount,omitempty"`
	ID                   int64      `json:"id,omitempty" form:"id,omitempty"`
	Cost                 int        `json:"cost,omitempty" form:"cost,omitempty"`
	CardFirstDigits      string     `json:"card_first_digits,omitempty" form:"card_first_digits,omitempty"`
	CardLastDigits       string     `json:"card_last_digits,omitempty" form:"card_last_digits,omitempty"`
	CardBrand            string     `json:"card_brand,omitempty" form:"card_brand,omitempty"`
	Card                 *Card      `json:"card,omitempty" form:"card,omitempty"`
	CaptureMethod        string     `json:"capture_method,omitempty" form:"capture_method,omitempty"`
	CardPinMode          string     `json:"card_pin_mode,omitempty" form:"card_pin_mode,omitempty"`
	// card_magstripe_fallback
	AntifraudScore float64 `json:"antifraud_score,omitempty" form:"antifraud_score,omitempty"`
	BoletoURL      string  `json:"boleto_url,omitempty" form:"boleto_url,omitempty"`
	BoletoBarcode  string  `json:"boleto_barcode,omitempty" form:"boleto_barcode,omitempty"`
	Referer        string  `json:"referer,omitempty" form:"referer,omitempty"`
	IP             string  `json:"ip,omitempty" form:"ip,omitempty"`
	SubscriptionID string  `json:"subscription_id,omitempty" form:"subscription_id,omitempty"`
	// phone
	// address
	AntifraudMetadata map[string]interface{} `json:"antifraud_metadata,omitempty" form:"antifraud_metadata,omitempty"`
	// reference_key
	// device
	// local_transaction_id
	// fraud_covered
	// order_id
	RiskLevel string `json:"risk_level,omitempty" form:"risk_level,omitempty"`
}

type UnixMS added in v0.0.15

type UnixMS int64

func UnixMSFromTime added in v0.0.15

func UnixMSFromTime(t time.Time) UnixMS

type YYYYMMDD

type YYYYMMDD string

func YYYYMMDDFromTime

func YYYYMMDDFromTime(t time.Time) YYYYMMDD

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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