redsys

package module
v0.0.0-...-0e6644b Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 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"`
}

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"`
}

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

Jump to

Keyboard shortcuts

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