Go

Pine Labs Server SDK for Go.

pinelabs-go is the official Go SDK for the Pine Labs Online Payment Gateway (Plural). It is generated from the same OpenAPI spec that powers this documentation, so every operation, request, and response model is fully typed.

Install

Bash
go get github.com/plural-pinelabs/pinelabs-go

Quickstart

The Pine Labs API uses OAuth2 with the client_credentials grant. Exchange your credentials for an access token, then pass it to client.NewClient.

Go
package main

import (
  "context"
  "fmt"
  "os"

  pinelabs "github.com/plural-pinelabs/pinelabs-go"
  pinelabsclient "github.com/plural-pinelabs/pinelabs-go/client"
  "github.com/plural-pinelabs/pinelabs-go/option"
)



func main() {
  ctx := context.Background()
  baseURL := "https://pluraluat.v2.pinepg.in" // UAT
  // baseURL := "https://api.pluralpay.in"     // Production

  // 1. Get a token (the auth call itself does not need a bearer token)
  auth := pinelabsclient.NewClient(option.WithBaseURL(baseURL))

  tokenResp, err := auth.Authentication.GenerateToken(ctx, &pinelabs.GenerateTokenRequest{
    GrantType:    "client_credentials",
    ClientId:     os.Getenv("PINELABS_CLIENT_ID"),
    ClientSecret: os.Getenv("PINELABS_CLIENT_SECRET"),
  })
  if err != nil {
    panic(err)
  }


  // 2. Build an authenticated client
  client := pinelabsclient.NewClient(
    option.WithBaseURL(baseURL),
    option.WithToken(tokenResp.AccessToken),
  )


  // 3. Call any operation
  order, err := client.Orders.CreateOrder(ctx, &pinelabs.CreateOrderRequest{
    MerchantOrderReference: "order-001",
    OrderAmount: &pinelabs.Amount{
      Value:    pinelabs.Int(50000),
      Currency: pinelabs.String("INR"), // ₹500.00
    },
  })
  if err != nil {
    panic(err)
  }
  fmt.Println(order)
}

Environments

EnvironmentBase URL
UAThttps://pluraluat.v2.pinepg.in
Productionhttps://api.pluralpay.in

Pass the URL via option.WithBaseURL(). The exported Environments.Production constant is also available.

Sub-clients

Client exposes one sub-client per API tag. All are initialised when the client is created.

Sub-clientPurpose
client.AuthenticationOAuth token generation
client.OrdersCreate, capture, cancel, and fetch orders
client.RefundsCreate and look up refunds
client.SettlementsSettlement reports + UTR lookup
client.CheckoutHosted-checkout related operations
client.PaymentLinksSingle + bulk payment links
client.CardPaymentsDirect card payment + OTP flow
client.BnplBuy-Now-Pay-Later eligibility and flows
client.ConvenienceFeeConvenience-fee config and computation
client.EChallansGovernment e-challan integration
client.ApplePayApple Pay session + decryption
client.InternationalPaymentsCross-border (DCC / MCC) payments
client.CustomersCustomer profile management
client.TokenizationCard / network tokenization
client.PayoutsPayouts: balance, create, cancel, list
client.SubscriptionsPlansRecurring-billing plans
client.SubscriptionsSubscriptionsSubscription lifecycle
client.SubscriptionsPresentationsSubscription debit presentations
client.PayByPointsLoyalty / points-based payments
client.AffordabilitySuiteEMI / offer eligibility
client.SplitSettlementsSplit settlements between sub-merchants

For the full operation list and request/response schemas, see the API reference.

Error handling

The SDK returns errors as standard Go error values. Use type assertions to inspect HTTP-level details:

Go
order, err := client.Orders.GetOrderById(ctx, &pinelabs.GetOrderByIdRequest{
  OrderId: "missing",
})
if err != nil {
  fmt.Fprintf(os.Stderr, "error: %v\n", err)
  return
}

Request options

Every operation accepts variadic option.RequestOption arguments for per-call overrides:

Go
order, err := client.Orders.CreateOrder(
  ctx,
  &pinelabs.CreateOrderRequest{ /* ... */ },
  option.WithMaxAttempts(1),
)

Source & support

New chat
Responses are generated using AI and may contain mistakes.
Hi! I'm Pine, your AI developer assistant. Ask me anything about Pine Labs APIs, integrations, or troubleshooting.

Tip: you can create a new chat with ⌘ + E