gosdkfull

package module
v2.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 11 Imported by: 0

README

github.com/speakeasy-sdks/go-sdk-full

SDK Installation

go get github.com/speakeasy-sdks/go-sdk-full

SDK Example Usage

Example
package main

import (
	"context"
	gosdkfull "github.com/speakeasy-sdks/go-sdk-full/v2"
	"github.com/speakeasy-sdks/go-sdk-full/v2/pkg/models/operations"
	"log"
)

func main() {
	s := gosdkfull.New()

	ctx := context.Background()
	res, err := s.TokenVault.DeleteSpecificSavedInstrument(ctx, operations.DeleteSpecificSavedInstrumentRequest{
		CustomerID:    "string",
		InstrumentID:  "string",
		XClientID:     "string",
		XClientSecret: "string",
	})
	if err != nil {
		log.Fatal(err)
	}

	if res.FetchAllSavedInstruments != nil {
		// handle response
	}
}

Available Resources and Operations

TokenVault
EligibilityAPIs
Offers
Orders
Authentication
Payments
Refunds
Settlements
Reconciliation
SoftPOS

Special Types

Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or an error, they will never return both. When specified by the OpenAPI spec document, the SDK will return the appropriate subclass.

Error Object Status Code Content Type
sdkerrors.LinkCancelledError 400 application/json
sdkerrors.SDKError 4xx-5xx /
Example
package main

import (
	"context"
	"errors"
	gosdkfull "github.com/speakeasy-sdks/go-sdk-full/v2"
	"github.com/speakeasy-sdks/go-sdk-full/v2/pkg/models/operations"
	"github.com/speakeasy-sdks/go-sdk-full/v2/pkg/models/sdkerrors"
	"log"
)

func main() {
	s := gosdkfull.New()

	ctx := context.Background()
	res, err := s.PaymentLinks.CancelPaymentLink(ctx, operations.CancelPaymentLinkRequest{
		LinkID:        "string",
		XClientID:     "string",
		XClientSecret: "string",
	})
	if err != nil {

		var e *sdkerrors.LinkCancelledError
		if errors.As(err, &e) {
			// handle error
			log.Fatal(e.Error())
		}

		var e *sdkerrors.SDKError
		if errors.As(err, &e) {
			// handle error
			log.Fatal(e.Error())
		}
	}
}

Server Selection

Select Server by Index

You can override the default server globally using the WithServerIndex option when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:

# Server Variables
0 https://sandbox.cashfree.com/pg None
1 https://api.cashfree.com/pg None
Example
package main

import (
	"context"
	gosdkfull "github.com/speakeasy-sdks/go-sdk-full/v2"
	"github.com/speakeasy-sdks/go-sdk-full/v2/pkg/models/operations"
	"log"
)

func main() {
	s := gosdkfull.New(
		gosdkfull.WithServerIndex(1),
	)

	ctx := context.Background()
	res, err := s.TokenVault.DeleteSpecificSavedInstrument(ctx, operations.DeleteSpecificSavedInstrumentRequest{
		CustomerID:    "string",
		InstrumentID:  "string",
		XClientID:     "string",
		XClientSecret: "string",
	})
	if err != nil {
		log.Fatal(err)
	}

	if res.FetchAllSavedInstruments != nil {
		// handle response
	}
}

Override Server URL Per-Client

The default server can also be overridden globally using the WithServerURL option when initializing the SDK client instance. For example:

package main

import (
	"context"
	gosdkfull "github.com/speakeasy-sdks/go-sdk-full/v2"
	"github.com/speakeasy-sdks/go-sdk-full/v2/pkg/models/operations"
	"log"
)

func main() {
	s := gosdkfull.New(
		gosdkfull.WithServerURL("https://sandbox.cashfree.com/pg"),
	)

	ctx := context.Background()
	res, err := s.TokenVault.DeleteSpecificSavedInstrument(ctx, operations.DeleteSpecificSavedInstrumentRequest{
		CustomerID:    "string",
		InstrumentID:  "string",
		XClientID:     "string",
		XClientSecret: "string",
	})
	if err != nil {
		log.Fatal(err)
	}

	if res.FetchAllSavedInstruments != nil {
		// handle response
	}
}

Custom HTTP Client

The Go SDK makes API calls that wrap an internal HTTP client. The requirements for the HTTP client are very simple. It must match this interface:

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

The built-in net/http client satisfies this interface and a default client based on the built-in is provided by default. To replace this default with a client of your own, you can implement this interface yourself or provide your own client configured as desired. Here's a simple example, which adds a client with a 30 second timeout.

import (
	"net/http"
	"time"
	"github.com/myorg/your-go-sdk"
)

var (
	httpClient = &http.Client{Timeout: 30 * time.Second}
	sdkClient  = sdk.New(sdk.WithClient(httpClient))
)

This can be a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration.

Maturity

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributions

While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!

SDK Created by Speakeasy

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ServerList = []string{

	"https://sandbox.cashfree.com/pg",

	"https://api.cashfree.com/pg",
}

ServerList contains the list of servers available to the SDK

Functions

func Bool

func Bool(b bool) *bool

Bool provides a helper function to return a pointer to a bool

func Float32

func Float32(f float32) *float32

Float32 provides a helper function to return a pointer to a float32

func Float64

func Float64(f float64) *float64

Float64 provides a helper function to return a pointer to a float64

func Int

func Int(i int) *int

Int provides a helper function to return a pointer to an int

func Int64

func Int64(i int64) *int64

Int64 provides a helper function to return a pointer to an int64

func String

func String(s string) *string

String provides a helper function to return a pointer to a string

Types

type Authentication

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

The Authentication API allows merchants to show a native screen and capture OTP on their own page and submit to Cashfree. This feature is only available on request.

func (*Authentication) OTPRequest

OTPRequest - Submit or Resend OTP If you accept OTP on your own page, you can use the below API to send OTP to Cashfree.

type EligibilityAPIs

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

func (*EligibilityAPIs) EligibilityCardlessEMI

EligibilityCardlessEMI - Get eligible Cardless EMI Use this API to get eligible Cardless EMI Payment Methods for a customer on an order.

func (*EligibilityAPIs) EligibilityOffer

EligibilityOffer - Get eligible Offers Use this API to get eligible offers for an order or amount.

func (*EligibilityAPIs) EligibilityPaylater

EligibilityPaylater - Get eligible Paylater Use this API to get eligible Paylater Payment Methods for a customer on an order.

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient provides an interface for suplying the SDK with a custom HTTP client

type Offers

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

func (*Offers) CreateOffer

CreateOffer - Create Offer Use this API to create offers with Cashfree from your backend

func (*Offers) GetOffer

GetOffer - Get Offer by ID Use this API to get offer by offer_id

type Orders

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

func (*Orders) CreateOrder

CreateOrder - Create Order Use this API to create orders with Cashfree from your backend and get the payment link. To use this API S2S flag needs to be enabled from the backend. In case you want to use the cards payment option the PCI DSS flag is required, for more information email us at "care@cashfree.com".

func (*Orders) GetOrder

GetOrder - Get Order Use this API to view all details of an order.

func (*Orders) OrderPay

OrderPay - Order Pay Use this API when you have already created the orders and want Cashfree to process the payment. To use this API S2S flag needs to be enabled from the backend. In case you want to use the cards payment option the PCI DSS flag is required, for more information send an email to "care@cashfree.com".

func (*Orders) Preauthorization

Preauthorization Use this API to capture or void a preauthorized payment

type PGLatest

type PGLatest struct {
	// Cashfree's token Vault helps you save cards and tokenize them in a PCI complaint manner. We support creation of network tokens which can be used across acquiring banks
	TokenVault      *TokenVault
	EligibilityAPIs *EligibilityAPIs
	PaymentLinks    *PaymentLinks
	Offers          *Offers
	Orders          *Orders
	// The Authentication API allows merchants to show a native screen and capture OTP on their own page and submit to Cashfree. This feature is only available on request.
	Authentication *Authentication
	Payments       *Payments
	Refunds        *Refunds
	Settlements    *Settlements
	Reconciliation *Reconciliation
	// softPOS' agent and order management system now supported by APIs
	SoftPOS *SoftPOS
	// contains filtered or unexported fields
}

func New

func New(opts ...SDKOption) *PGLatest

New creates a new instance of the SDK with the provided options

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

CancelPaymentLink - Cancel Payment Link Use this API to cancel a payment link. No further payments can be done against a cancelled link. Only a link in ACTIVE status can be cancelled.

CreatePaymentLink - Create Payment Link Use this API to create a new payment link. The created payment link url will be available in the API response parameter link_url.

func (*PaymentLinks) GetPaymentLinkDetails

GetPaymentLinkDetails - Fetch Payment Link Details Use this API to view all details and status of a payment link.

func (*PaymentLinks) GetPaymentLinkOrders

GetPaymentLinkOrders - Get Orders for a Payment Link Use this API to view all order details for a payment link.

type Payments

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

func (*Payments) GetPaymentbyID

GetPaymentbyID - Get Payment by ID Use this API to view payment details of an order for a payment ID.

func (*Payments) GetPaymentsfororder

GetPaymentsfororder - Get Payments for an Order Use this API to view all payment details for an order.

type Reconciliation

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

func (*Reconciliation) PostRecon

PostRecon - PG Reconciliation Use this API to get the payment gateway reconciliation details with date range.

func (*Reconciliation) PostSettlementRecon

PostSettlementRecon - Settlement Reconciliation Use this API to get settlement reconciliation details using Settlement ID, settlement UTR or date range.

type Refunds

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

func (*Refunds) Createrefund

Createrefund - Create Refund Use this API to initiate refunds.

func (*Refunds) GetRefund

GetRefund - Get Refund Use this API to fetch a specific refund processed on your Cashfree Account.

func (*Refunds) Getallrefundsfororder

Getallrefundsfororder - Get All Refunds for an Order Use this API to fetch all refunds processed against an order.

type SDKOption

type SDKOption func(*PGLatest)

func WithClient

func WithClient(client HTTPClient) SDKOption

WithClient allows the overriding of the default HTTP client used by the SDK

func WithRetryConfig

func WithRetryConfig(retryConfig utils.RetryConfig) SDKOption

func WithServerIndex

func WithServerIndex(serverIndex int) SDKOption

WithServerIndex allows the overriding of the default server by index

func WithServerURL

func WithServerURL(serverURL string) SDKOption

WithServerURL allows the overriding of the default server URL

func WithTemplatedServerURL

func WithTemplatedServerURL(serverURL string, params map[string]string) SDKOption

WithTemplatedServerURL allows the overriding of the default server URL with a templated URL populated with the provided parameters

type Settlements

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

func (*Settlements) Getsettlements

Getsettlements - Get Settlements by Order ID Use this API to view all the settlements of a particular order.

func (*Settlements) PostSettlements

PostSettlements - Get All Settlements Use this API to get all settlement details by specifying the settlement ID, settlement UTR or date range.

type SoftPOS

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

SoftPOS - softPOS' agent and order management system now supported by APIs

func (*SoftPOS) CreateTerminals

CreateTerminals - Create Terminal Use this API to create new terminals to use softPOS.

func (*SoftPOS) GetTerminalByMobileNumber

GetTerminalByMobileNumber - Get terminal status using phone number Use this API to view all details of a terminal.

type TokenVault

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

TokenVault - Cashfree's token Vault helps you save cards and tokenize them in a PCI complaint manner. We support creation of network tokens which can be used across acquiring banks

func (*TokenVault) DeleteSpecificSavedInstrument

DeleteSpecificSavedInstrument - Delete Saved Instrument To delete a saved instrument for a customer id and instrument id

func (*TokenVault) FetchAllSavedInstruments

FetchAllSavedInstruments - Fetch All Saved Instruments To get all saved instruments for a customer id

func (*TokenVault) FetchCryptogram

FetchCryptogram - Fetch cryptogram for saved instrument To get the card network token, token expiry and cryptogram for a saved instrument using instrument id

func (*TokenVault) FetchSpecificSavedInstrument

FetchSpecificSavedInstrument - Fetch Single Saved Instrument To get specific saved instrument for a customer id and instrument id

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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