tpv

package module
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2020 License: MIT Imports: 14 Imported by: 0

README

redsys-golang

GoDoc

Redsys integration for golang

Install
go get github.com/altipla-consulting/redsys-golang

This library has the following external dependencies outside the Go standard library:

  • github.com/juju/errors
  • github.com/altipla-consulting/collections
  • golang.org/x/net/context
Contributing

You can make pull requests or create issues in GitHub. Any code you send should be formatted using gofmt.

License

MIT License

Documentation

Overview

Package tpv integrates redsys payments in Go.

Index

Constants

View Source
const (
	EndpointProduction = "https://sis.redsys.es/sis/realizarPago"
	EndpointDebug      = "https://sis-t.redsys.es:25443/sis/realizarPago"
)
View Source
const (
	TransactionTypeSimpleAuthorization = TransactionType(0)
	TransactionTypeRefund              = TransactionType(3)
)
View Source
const (
	LangES = Lang("001")
	LangEN = Lang("002")
	LangCA = Lang("003")
	LangFR = Lang("004")
	LangDE = Lang("005")
	LangIT = Lang("007")
	LangPT = Lang("009")
)
View Source
const (
	StatusUnknown   = Status("")
	StatusApproved  = Status("approved")
	StatusCancelled = Status("cancelled")
	StatusRepeated  = Status("repeated")
)
View Source
const (
	CurrencyEuros = Currency(978)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Currency

type Currency int64

type Lang

type Lang string

type Merchant

type Merchant struct {
	// Merchant code assigned by the bank.
	Code string

	// Merchant name to show in the receipt.
	Name string

	// Terminal number assigned by the bank.
	Terminal int64

	// Secret to sign transactions assigned by the bank.
	Secret string

	// URL where the notification will be sent.
	URLNotification string

	// Enable debug endpoint.
	Debug bool
}

Merchant data

type Operation

type Operation struct {
	Status       Status
	Sent         time.Time
	Params       Params
	IsCreditCard bool

	// Raw response code of the bank.
	ResponseCode int64
}

func Confirm

func Confirm(ctx context.Context, secret string, signed Signed) (Operation, error)

type Params

type Params struct {
	Response int64  `json:"-"`
	Order    string `json:"Ds_Order"`
	Date     string `json:"Ds_Date"`
	Time     string `json:"Ds_Hour"`
	Country  string `json:"Ds_Card_Country"`
	AuthCode string `json:"Ds_AuthorisationCode"`
	CardType string `json:"Ds_Card_Type"`
	Data     string `json:"Ds_MerchantData"`

	RawResponse string `json:"Ds_Response"`
}

func ParseParams

func ParseParams(signed Signed) (Params, error)

type Session

type Session struct {
	// Code of the session. It should have 4 digits and 8 characters.
	Code string

	// Two-letters code of the language. Use English if unknown, please.
	Lang Lang

	// Name of the client to show in the receipt.
	Client string

	// Amount in cents to pay.
	Amount int32

	// Product name to show in the receipt.
	Product string

	// URL to return to when the transaction is approved.
	URLOK string

	// URL to return to when the transaction is cancelled.
	URLKO string

	// Raw data that will be sent back in the confirmation.
	Data string

	// The transaction type, e.g a refund.
	Type TransactionType
}

Session data

type Signed

type Signed struct {
	// Signature of the parameters.
	Signature string

	// Version of the signature.
	SignatureVersion string

	// Params to send.
	Params string

	// Output only. It will return the endpoint of the call.
	Endpoint string
}

Signed TPV transaction to send to the bank.

func Sign

func Sign(ctx context.Context, merchant Merchant, session Session) (Signed, error)

type Status

type Status string

type TransactionType

type TransactionType int64

Jump to

Keyboard shortcuts

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