Skip to content

solidgate-tech/go-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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/solidgate/ – 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() {
	//.....
	someRequestStruct := SomeRequestStruct{}
	someStructJson, err := json.Marshal(someRequestStruct)

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

	solidgateSdk := solidgate.NewSolidGateApi("YourPublicKey", "YourSecretKey")

	response, err := solidgateSdk.Charge(someStructJson)

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

	someResponeStruct = SomeResponeStruct{}
	err := json.Unmarshal(response, &someResponeStruct)

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

Payment form

Returns a FormInitDTO struct in JSON.

package main

import (
	"encoding/json"
	"fmt"

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

func main() {

	solidgateSdk := solidgate.NewSolidGateApi("YourPublicKey", "YourSecretKey")
	someRequestStruct := SomeRequestStruct{}
	someStructJson, err := json.Marshal(someRequestStruct)

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

	formInitDto, err := solidgateSdk.FormMerchantData(someStructJson)

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

	// ...
}

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 := solidgate.NewSolidGateApi("YourPublicKey", "YourSecretKey")
	someRequestStruct := UpdateParams{}
	someStructJson, err := json.Marshal(someRequestStruct)

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

	formUpdateDto, err := solidgateSdk.FormUpdate(someStructJson)

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

	// ...
}

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 := solidgate.NewSolidGateApi("YourPublicKey", "YourSecretKey")
	someRequestStruct := SomeRequestStruct{}
	someStructJson, err := json.Marshal(someRequestStruct)

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

	formResignDto, err := solidgateSdk.FormResign(someStructJson)

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

	// ...
}

Errors

Handle errors.

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