wolfjung / razorpay-go

Razorpay Go SDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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. All methods accept an extraHeaders param of type map[string]string, allowing you to optinally set extra HTTP headers on the request.

Payments

  • Fetch all payments
    body, err := client.Payment.All(nil, nil)
  • Fetch a particular payment
    body, err := client.Payment.Fetch("<payment_id>" , nil, nil)
  • Capture a payment
    body, err := client.Payment.Capture("<payment_id>", <amount>, nil, nil)
    Note: amount is in paisa
  • Refund a payment
    body, err := client.Payment.Refund("<payment_id>", <amount_to_be_refunded>, nil, nil)

Refunds

  • Fetch all refunds
    body, err := client.Refund.All(nil, nil)
  • Fetch a particular refund
    body, err := client.Refund.Fetch("<refund_id>", nil, nil)

Orders

  • Create a new order

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

    Note: data is a map and should contain these keys. See the Orders entity reference for details on 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>", nil, nil)
  • Fetch all orders

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

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

About

Razorpay Go SDK

License:MIT License


Languages

Language:Go 100.0%