Skip to main content
This guide introduces how to get started with using the Cobo Payments Go SDK, which allows you to integrate the Cobo payments service into your existing application using the Go programming language. To learn more about the initial setup steps necessary for utilizing the Payments API, see Send your first request. You can go to GitHub to access the source code of the SDK.

Prerequisites

  • You have installed Go 1.18 or newer.
  • Follow the instructions in Preparation for development environment to set up your Cobo account and create your organization. If an organization has already been set up, ask your organization admin to invite you to join the organization.
  • Follow the instructions in Send your first request to generate an API key and an API secret, and register the API key on Cobo Portal.

Install the SDK

  1. Create a Go project if you have not already done so.
  2. In the go.mod file of your project, add the following line:
    require github.com/CoboGlobal/cobo-waas2-go-sdk {VERSION}
    
    Replace {VERSION} with the lastest version number, for example, v1.2.0. Obtain the latest version number from the GitHub repository.
  3. Run the go mod tidy command in a terminal or in your IDE to install the dependencies.
  4. In your main.go file, import the WaaS SDK as follows:
    import (
        ...
        coboWaas2 "github.com/CoboGlobal/cobo-waas2-go-sdk/cobo_waas2"
        ...
    )
    

Configure API key and HTTP host

In the main function in your main.go file, configure the HTTP host by selecting the environment and provide your API secret. The following code snippet shows the configuration for the development environment.
// Select the environment that you use and comment out the other line of code
ctx = context.WithValue(ctx, coboWaas2.ContextEnv, coboWaas2.DevEnv)
// ctx = context.WithValue(ctx, coboWaas2.ContextEnv, coboWaas2.ProdEnv)
ctx = context.WithValue(ctx, coboWaas2.ContextPortalSigner, crypto.Ed25519Signer{
    // Replace `<YOUR_API_SECRET>` with your API secret.
    Secret: "<YOUR_API_SECRET>",
})

Sample code

For operation-specific documentation and sample code, see the docs folder in the Payments API SDK GitHub repository.