RazorpayEx (razorpay_ex v0.1.3)

Copy Markdown View Source

Razorpay Elixir SDK - Unofficial Elixir client for Razorpay API.

This library is modeled after the official Razorpay Ruby SDK (https://github.com/razorpay/razorpay-ruby) and provides a similar API experience for Elixir developers.

Setup

# Basic authentication (like Ruby's Razorpay.setup)
RazorpayEx.setup("your_key_id", "your_key_secret")

# OAuth authentication (like Ruby's Razorpay.setup_with_oauth)
RazorpayEx.setup_with_oauth("your_access_token")

# Set custom headers (like Ruby's Razorpay.headers=)
RazorpayEx.headers(%{"X-Custom-Header" => "value"})

Usage

# Create an order (similar to Razorpay::Order.create)
{:ok, order} = RazorpayEx.Order.create(%{
  amount: 50000,
  currency: "INR",
  receipt: "order_123"
})

# Fetch a payment (similar to Razorpay::Payment.fetch)
{:ok, payment} = RazorpayEx.Payment.fetch("pay_123456")

Supported Resources

This SDK supports all resources from the official Ruby SDK:

  • Account
  • Customer
  • Token
  • Order
  • Payment
  • Refund
  • Invoice
  • Plan
  • Item
  • Subscription
  • AddOn
  • PaymentLink
  • Card
  • UPI
  • QRCode
  • Dispute
  • Document
  • ... and more

Summary

Functions

Set custom headers for all requests - equivalent to Ruby's Razorpay.headers=

Setup basic authentication - equivalent to Ruby's Razorpay.setup(key_id, key_secret)

Setup OAuth authentication - equivalent to Ruby's Razorpay.setup_with_oauth(access_token)

Test API connectivity - useful for debugging setup.

Verify webhook signature - equivalent to Ruby's webhook verification

Returns the library version.

Functions

headers(custom_headers)

@spec headers(map()) :: :ok

Set custom headers for all requests - equivalent to Ruby's Razorpay.headers=

setup(key_id, key_secret)

@spec setup(String.t(), String.t()) :: :ok

Setup basic authentication - equivalent to Ruby's Razorpay.setup(key_id, key_secret)

setup_with_oauth(access_token)

@spec setup_with_oauth(String.t()) :: :ok

Setup OAuth authentication - equivalent to Ruby's Razorpay.setup_with_oauth(access_token)

test_connection()

@spec test_connection() :: {:ok, map()} | {:error, RazorpayEx.Error.t()}

Test API connectivity - useful for debugging setup.

verify_webhook(payload, signature, secret)

@spec verify_webhook(String.t(), String.t(), String.t()) :: boolean()

Verify webhook signature - equivalent to Ruby's webhook verification

version()

@spec version() :: String.t()

Returns the library version.