Skip to content

cashfree/cashfree-pg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Cashfree PG Go SDK

GitHub Discord GitHub last commit (branch) GitHub release (with filter) GitHub forks Coverage Status GoDoc

The Cashfree PG Go SDK offers a convenient solution to access Cashfree PG APIs from a server-side Go applications.

Documentation

Cashfree's PG API Documentation - https://docs.cashfree.com/reference/pg-new-apis-endpoint

Learn and understand payment gateway workflows at Cashfree Payments here

Try out our interactive guides at Cashfree Dev Studio !

Getting Started

Installation

go get github.com/cashfree/cashfree-pg/v4

Configuration

import (
    cashfree "github.com/cashfree/cashfree-pg/v4"
)

clientId := "<x-client-id>"
clientSecret := "<x-client-secret>"
cashfree.XClientId = &clientId
cashfree.XClientSecret = &clientSecret
cashfree.XEnvironment = cashfree.SANDBOX

Generate your API keys (x-client-id , x-client-secret) from Cashfree Merchant Dashboard

Basic Usage

Create Order

returnUrl := "https://www.cashfree.com/devstudio/preview/pg/web/checkout?order_id={order_id}"

request := cashfree.CreateOrderRequest{
	OrderAmount:   1.0,
	OrderCurrency: "INR",
	CustomerDetails: cashfree.CustomerDetails{
		CustomerId:    "walterwNrcMi",
		CustomerPhone: "9999999999",
	},
	OrderMeta: &cashfree.OrderMeta{
		ReturnUrl: &returnUrl,
	},
}

version := "2022-09-01"

response, httpResponse, err := cashfree.PGCreateOrder(&version, &request, nil, nil, nil)
if err != nil {
	fmt.Println(err.Error())
} else {
	fmt.Println(httpResponse.StatusCode)
	fmt.Println(response)
}

Get Order

version := "2022-09-01"
response, httpResponse, err := cashfree.PGFetchOrder(&version, "<order_id>", nil, nil, nil)
if err != nil {
	fmt.Println(err.Error())
} else {
	fmt.Println(httpResponse.StatusCode)
	fmt.Println(response)
}

Supported Resources

Licence

Apache Licensed. See LICENSE.md for more details