razorpay

package module
v0.0.0-...-dbdd42c Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2020 License: MIT Imports: 5 Imported by: 0

README

Razorpay Go Client

Golang bindings for interacting with the Razorpay API

This is primarily meant for merchants who wish to perform interactions with the Razorpay API programatically

Usage

You need to setup your key and secret using the following: You can find your API keys at https://dashboard.razorpay.com/#/app/keys.

import (
razorpay "github.com/razorpay/razorpay-go"
)

client := razorpay.NewClient("<YOUR_API_KEY>", "<YOUR_API_SECRET>")

Note: All methods below return a map[string]interface{} and error.

Payments
  • Fetch all payments
    body, err := client.Payment.All()
    
  • Fetch a particular payment
    body, err := client.Payment.Fetch(<payment_id>)
    
  • Capture a payment
    body, err := client.Payment.Capture(<payment_id>, <amount>)
    
    Note: amount is in paisa
  • Refund a payment
    body, err := client.Payment.Refund(<payment_id>, <amount_to_be_refunded>)
    
Refunds
  • Fetch all refunds
    body, err := client.Refund.All()
    
  • Fetch a particular refund
    body, err := client.Refund.Fetch(<refund_id>)
    
Orders
  • Create a new order

    data := map[string]interface{}{
        "amount":          1234,
        "currency":        "INR",
        "receipt_id":      "some_receipt_id",
        "payment_capture": 1,
    }
    body, err := client.Order.Create(data)
    

    Note: data is a map and should contain these keys

      amount           : amount of order(in paisa)
      currency         : currency of order
      receipt          : receipt id of order
      payment_capture  : 1 if capture should be done automatically or else 0
      notes(optional)  : optional notes for order
    
  • Fetch a particular order

    body, err := client.Order.Fetch(<order_id>)
    
  • Fetch all orders

    body, err := client.Order.All()
    
  • Fetch all payments for order

    body, err := client.Order.Payments(<order_id>)
    

Documentation

Index

Constants

View Source
const SDKName = "razorpay-go"

SDKName ...Name of this SDK

View Source
const SDKVersion = "0.1"

SDKVersion ...

Variables

Request ...

Functions

This section is empty.

Types

type Client

type Client struct {
	Addon          *resources.Addon
	Card           *resources.Card
	Customer       *resources.Customer
	Invoice        *resources.Invoice
	Order          *resources.Order
	Payment        *resources.Payment
	Plan           *resources.Plan
	Refund         *resources.Refund
	Subscription   *resources.Subscription
	Token          *resources.Token
	Transfer       *resources.Transfer
	VirtualAccount *resources.VirtualAccount
}

Client provides various helper methods to make HTTP requests to Razorpay's APIs.

func NewClient

func NewClient(key string, secret string) *Client

NewClient creates and returns a new Razorpay client. key and secret are used to authenticate the requests made to Razorpay's APIs.

func (*Client) AddHeaders

func (client *Client) AddHeaders(headers map[string]string)

AddHeaders adds additional headers to Razorpay's client. All requests made using the client will contain these additional headers in the HTTP request.

func (*Client) SetTimeout

func (client *Client) SetTimeout(timeout int16)

SetTimeout sets the timeout of Razorpay's Client. The default timeout will be overridden for all HTTP requests made using this client.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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