solidgate

package module
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

README

Solidgate API

Go project version

GO SDK provides API options for integrating Solidgate’s payment orchestrator into your GO applications.

Check our

Structure

SDK for GO contains Table of contents
api.go – main file for API integration
encryption.go – library for encryption-related operations
entries.go – contains form-related methods (e.g., form resign)
go.mod – dependency file for managing module imports
Requirements
Installation
Usage
Errors

Requirements


Installation

To install the GO SDK:

  1. Ensure you have your public and secret key.
  2. Run:
    go get github.com/solidgate-tech/go-sdk
    
  3. Import the library into your Go application:
    import solidgate "github.com/solidgate-tech/go-sdk"
    
  4. Use test credentials to validate your integration before deploying to production.

Usage

Charge a payment

Returns a raw JSON response.

package main

import (
	"encoding/json"
	"fmt"

	solidgate "github.com/solidgate-tech/go-sdk"
)

func main() { 
	//.....
	solidgateSdk, err := solidgate.NewAPI("YourPublicKey", "YourSecretKey")
	if err != nil {
		fmt.Print(err)
		return
	}
	
	someRequestStruct := SomeRequestStruct{}
	someStructJson, err := json.Marshal(someRequestStruct)

	if err != nil {
		fmt.Print(err)
		return
	}

	response, err := solidgateSdk.Auth(someStructJson)
	if err != nil {
		fmt.Print(err)
		return
	}

	someResponeStruct = SomeResponeStruct{}
	err = json.Unmarshal(response, &someResponeStruct)
	if err != nil {
		fmt.Print(err)
		return
	}
	//.....
}

Payment form

Returns a FormInitDTO struct in JSON.

package main

import (
	"encoding/json"
	"fmt"

	solidgate "github.com/solidgate-tech/go-sdk"
)

func main() {
	//.....
	solidgateSdk, err := solidgate.NewAPI("YourPublicKey", "YourSecretKey")
	if err != nil {
		fmt.Print(err)
		return
	}

	someRequestStruct := SomeRequestStruct{}
	someStructJson, err := json.Marshal(someRequestStruct)
	if err != nil {
		fmt.Print(err)
		return
	}

	formInitDto, err := solidgateSdk.FormMerchantData(someStructJson)
	if err != nil {
		fmt.Print(err)
		return
	}
	// ...
}

Update payment form

Returns a FormUpdateDTO struct in JSON.

package main

import (
	"encoding/json"
	"fmt"

	solidgate "github.com/solidgate-tech/go-sdk"
)

type UpdateParams struct {
	...
}

func main() {
	//.....
	solidgateSdk, err := solidgate.NewAPI("YourPublicKey", "YourSecretKey")
	if err != nil {
		fmt.Print(err)
		return
	}
	
	someRequestStruct := UpdateParams{}
	someStructJson, err := json.Marshal(someRequestStruct)
	if err != nil {
		fmt.Print(err)
		return
	}
	
	formUpdateDto, err := solidgateSdk.FormUpdate(someStructJson)
	if err != nil {
		fmt.Print(err)
		return
	}
	// ...
}

Resign payment form

Returns a FormResignDTO struct in JSON.

package main

import (
	"encoding/json"
	"fmt"

	solidgate "github.com/solidgate-tech/go-sdk"
)

func main() {
	//.....
	solidgateSdk, err := solidgate.NewAPI("YourPublicKey", "YourSecretKey")
	if err != nil {
		fmt.Print(err)
		return
	}
   
	someRequestStruct := SomeRequestStruct{}
	someStructJson, err := json.Marshal(someRequestStruct)
	if err != nil {
		fmt.Print(err)
		return
	}

	formResignDto, err := solidgateSdk.FormResign(someStructJson)
	if err != nil {
		fmt.Print(err)
		return
	}
	// ...
}


Errors

Handle errors.

if err != nil {
   fmt.Println(err)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidBlockSize is returned when the block size is invalid
	ErrInvalidBlockSize = errors.New("block size must be greater than 0")

	// ErrEmptyData is returned when the data to encrypt is empty
	ErrEmptyData = errors.New("data to encrypt cannot be empty")

	// ErrInvalidKeySize is returned when the key size is invalid
	ErrInvalidKeySize = errors.New("key size must be 32 bytes")
)
View Source
var ErrEmptyPayload = errors.New("empty payload")

ErrEmptyPayload is returned when the request payload is empty

Functions

func EncryptCBC

func EncryptCBC(key, data []byte) ([]byte, error)

EncryptCBC encrypts data using AES-CBC mode with PKCS#7 padding key must be 32 bytes long

Types

type API added in v1.7.0

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

API represents the SolidGate API client

func NewAPI added in v1.7.0

func NewAPI(merchantID, privateKey string, baseURI *string) (*API, error)

NewAPI creates a new SolidGate API client

func (API) ApplePay added in v1.7.0

func (api API) ApplePay(data []byte) ([]byte, error)

ApplePay processes an Apple Pay payment

func (API) ArnCode added in v1.7.0

func (api API) ArnCode(data []byte) ([]byte, error)

ArnCode retrieves the ARN code

func (API) Auth added in v1.7.0

func (api API) Auth(data []byte) ([]byte, error)

Auth performs an authorization request

func (API) FormMerchantData added in v1.7.0

func (api API) FormMerchantData(data []byte) (*FormInitDTO, error)

FormMerchantData prepares merchant data for form initialization

func (API) FormResign added in v1.7.0

func (api API) FormResign(data []byte) (*FormResignDTO, error)

FormResign prepares data for form resignation

func (API) FormUpdate added in v1.7.0

func (api API) FormUpdate(data []byte) (*FormUpdateDTO, error)

FormUpdate prepares data for form update

func (API) GenerateSignature added in v1.7.0

func (api API) GenerateSignature(data []byte) string

GenerateSignature generates a signature for the request

func (API) GooglePay added in v1.7.0

func (api API) GooglePay(data []byte) ([]byte, error)

GooglePay processes a Google Pay payment

func (API) Recurring added in v1.7.0

func (api API) Recurring(data []byte) ([]byte, error)

Recurring performs a recurring payment request

func (API) Refund added in v1.7.0

func (api API) Refund(data []byte) ([]byte, error)

Refund performs a refund request

func (API) Resign added in v1.7.0

func (api API) Resign(data []byte) ([]byte, error)

Resign performs a resign request

func (API) Settle added in v1.7.0

func (api API) Settle(data []byte) ([]byte, error)

Settle performs a settlement request

func (API) Status added in v1.7.0

func (api API) Status(data []byte) ([]byte, error)

Status checks the status of a transaction

func (API) Void added in v1.7.0

func (api API) Void(data []byte) ([]byte, error)

Void performs a void request

type FormInitDTO

type FormInitDTO struct {
	PaymentIntent string
	Merchant      string
	Signature     string
}

type FormResignDTO added in v1.5.0

type FormResignDTO struct {
	ResignIntent string
	Merchant     string
	Signature    string
}

type FormUpdateDTO

type FormUpdateDTO struct {
	PartialIntent string
	Signature     string
}

Jump to

Keyboard shortcuts

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