redsys

package module
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: MIT Imports: 10 Imported by: 0

README

go-redsys-api

Godoc reference Build Status Code Climate

Redsys api implementation with new the key-hashed message autentication code (HMAC) SHA256 for the virtual payment gateway integration.

Installation

go get github.com/GerardSoleCa/go-redsys-api

Tests

go test

Based on

https://github.com/santiperez/node-redsys-api

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MerchantParametersRequest

type MerchantParametersRequest struct {
	// Optional fields are tagged with omitempty
	MerchantMerchantCode       string `json:"Ds_Merchant_MerchantCode"`
	MerchantTerminal           string `json:"Ds_Merchant_Terminal"`
	MerchantTransactionType    string `json:"Ds_Merchant_TransactionType"`
	MerchantAmount             string `json:"Ds_Merchant_Amount"`
	MerchantCurrency           string `json:"Ds_Merchant_Currency"`
	MerchantOrder              string `json:"Ds_Merchant_Order"`
	MerchantMerchantUrl        string `json:"Ds_Merchant_MerchantURL,omitempty"`
	MerchantProductDescription string `json:"Ds_Merchant_ProductDescription,omitempty"`
	MerchantTitular            string `json:"Ds_Merchant_Titular,omitempty"`
	MerchantUrlOK              string `json:"Ds_Merchant_UrlOK,omitempty"`
	MerchantUrlKO              string `json:"Ds_Merchant_UrlKO,omitempty"`
	MerchantMerchantName       string `json:"Ds_Merchant_MerchantName,omitempty"`
	MerchantConsumerLanguage   string `json:"Ds_Merchant_ConsumerLanguage,omitempty"`
	MerchantIdentifier         string `json:"Ds_Merchant_Identifier,omitempty"`
	MerchantCofIni             string `json:"Ds_Merchant_Cof_Ini,omitempty"`
	MerchantCofType            string `json:"Ds_Merchant_Cof_Type,omitempty"`
	MerchantData               string `json:"Ds_Merchant_MerchantData,omitempty"`
	MerchantCofTxnid           string `json:"Ds_Merchant_Cof_Txnid,omitempty"`
	MerchantExcepSca           string `json:"Ds_Merchant_Excep_SCA,omitempty"`
	MerchantDirectPayment      string `json:"Ds_Merchant_DirectPayment,omitempty"`
	MerchantGroup              string `json:"Ds_Merchant_Group,omitempty"`
}

MerchantParametersRequest struct to construct Redsys API requests

type MerchantParametersResponse

type MerchantParametersResponse struct {
	Date              string `json:"Ds_Date"`
	Hour              string `json:"Ds_Hour"`
	SecurePayment     string `json:"Ds_SecurePayment"`
	CardCountry       string `json:"Ds_Card_Country,omitempty"`
	Amount            string `json:"Ds_Amount"`
	Currency          string `json:"Ds_Currency"`
	Order             string `json:"Ds_Order"`
	MerchantCode      string `json:"Ds_MerchantCode"`
	Terminal          string `json:"Ds_Terminal"`
	Response          string `json:"Ds_Response"`
	MerchantData      string `json:"Ds_MerchantData"`
	TransactionType   string `json:"Ds_TransactionType"`
	ConsumerLanguage  string `json:"Ds_ConsumerLanguage,omitempty"`
	AuthorisationCode string `json:"Ds_AuthorisationCode,omitempty"`
	Identifier        string `json:"Ds_Merchant_Identifier,omitempty"`
	CofTxnid          string `json:"Ds_Merchant_Cof_Txnid,omitempty"`
	ExpiryDate        string `json:"Ds_ExpiryDate,omitempty"`
	Description       string `json:"Ds_Response_Description,omitempty"`
	CardNumber        string `json:"Ds_Card_Number,omitempty"`
	CardBrand         string `json:"Ds_Card_Brand,omitempty"`
}

MerchantParametersResponse struct to read Redsys API responses

type Redsys

type Redsys struct {
	Key string
}

Redsys Init this struct with your key to operate with the corresponding functions

func (*Redsys) CreateMerchantParameters

func (r *Redsys) CreateMerchantParameters(data *MerchantParametersRequest) string

CreateMerchantParameters Return a string corresponding to a marshalled MerchantParametersRequest

func (*Redsys) CreateMerchantSignature

func (r *Redsys) CreateMerchantSignature(data *MerchantParametersRequest) string

CreateMerchantSignature generates a merchant signature from MerchantParametersRequest

func (*Redsys) CreateMerchantSignatureNotif

func (r *Redsys) CreateMerchantSignatureNotif(data string) string

CreateMerchantSignatureNotif generates a signature for MerchantParametersResponse representing string

func (*Redsys) DecodeMerchantParameters

func (r *Redsys) DecodeMerchantParameters(data string) MerchantParametersResponse

DecodeMerchantParameters Decode a response into a MerchantParametersResponse

func (*Redsys) MerchantSignatureIsValid

func (r *Redsys) MerchantSignatureIsValid(mac1 string, mac2 string) bool

MerchantSignatureIsValid checks that two hmacs are equal

type RequestErrorMessage added in v1.0.3

type RequestErrorMessage struct {
	ErrorCode        string `json:"errorCode"`
	ErrorDescription string `json:"errorCodeDescription"`
}

type RequestPreauthorization added in v1.0.2

type RequestPreauthorization struct {
	Ds_MerchantParameters string `json:"Ds_MerchantParameters"`
	Ds_SignatureVersion   string `json:"Ds_SignatureVersion"`
	Ds_Signature          string `json:"Ds_Signature"`
}

Jump to

Keyboard shortcuts

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