adyen

package module
Version: v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2021 License: MIT Imports: 10 Imported by: 0

README

adyen

Encrypt secrets for the Adyen payment platform.

This library uses crypto/rand to generate cryptographically secure AES keys and nonces, and re-uses the same key and nonce for each client. Other publicly available libraries typically use math/rand which is insecure for generating secret keys and nonces.

Example

package main

import (
	"fmt"
	"github.com/CrimsonAIO/adyen"
	"os"
)

func main() {
	// create new client with a specific site key.
	client, err := adyen.NewClient(os.Getenv("ADYEN_SITE_KEY"))
	if err != nil {
		panic(err)
	}
	
	// encrypt card number
	// if you need to encrypt multiple values into one string (for example, a map) you can use Encrypt.
	encrypted, err := client.EncryptSingle(adyen.Version118, "number", "5555555555554444", adyen.GenerationTimeNow)
	if err != nil {
		panic(err)
	}
	
	// print encrypted card number 
	fmt.Println(encrypted)
}

Check it out on The Go Playground.

Contributing

Pull requests are welcome to add new version constants or other improvements. Note that you don't need to use one of our version constants; you can use any string you like.

If you open a pull request, please use our MIT copyright header. If you're using GoLand (or any JetBrains IDE) you can do this by going in Settings -> Editor -> Copyright and selecting the copyright profile found in .idea/copyright/MIT_Crimson_Technologies_LLC.xml. You are welcome to add your own name for your contributions.

Documentation

Index

Constants

View Source
const (
	// Version118 is the text representation of Adyen v1.18.
	Version118 = "0_1_18"

	// Version121 is the text representation of Adyen v1.21.
	Version121 = "0_1_21"
)

Variables

This section is empty.

Functions

func NewClient

func NewClient(siteKey string) (*client, error)

NewClient creates a new client with the specified hex encoded site key.

Types

type GenerationTimeFunc added in v1.1.4

type GenerationTimeFunc func(version string, value map[string]interface{}) time.Time

GenerationTimeFunc is a function responsible for returning the correct "generationtime" key given a version and value.

var GenerationTimeNow GenerationTimeFunc = func(version string, value map[string]interface{}) time.Time {
	return time.Now()
}

GenerationTimeNow returns time.Now as the generated time.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL