webhook

package
v1.0.49 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FlexibleNotes

type FlexibleNotes map[string]interface{}

FlexibleNotes handles both array and object formats from Razorpay Razorpay sometimes sends empty array [] instead of empty object {}

func (*FlexibleNotes) UnmarshalJSON

func (fn *FlexibleNotes) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom unmarshaling to handle both [] and {} formats

type Handler

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

Handler handles Razorpay webhook events

func NewHandler

func NewHandler(
	client razorpay.RazorpayClient,
	paymentSvc *razorpay.PaymentService,
	entityIntegrationMappingRepo entityintegrationmapping.Repository,
	logger *logger.Logger,
) *Handler

NewHandler creates a new Razorpay webhook handler

func (*Handler) HandleWebhookEvent

func (h *Handler) HandleWebhookEvent(ctx context.Context, event *RazorpayWebhookEvent, environmentID string, services *ServiceDependencies) error

HandleWebhookEvent processes a Razorpay webhook event This function never returns errors to ensure webhooks always return 200 OK All errors are logged internally to prevent Razorpay from retrying

type PayloadPayment

type PayloadPayment struct {
	Entity Payment `json:"entity"`
}

PayloadPayment represents the payment entity in the webhook payload

type Payment

type Payment struct {
	ID               string        `json:"id"`
	Entity           string        `json:"entity"`
	Amount           int64         `json:"amount"`            // Amount in smallest currency unit (paise)
	Currency         string        `json:"currency"`          // Currency code (INR, USD, etc.)
	Status           string        `json:"status"`            // created, authorized, captured, refunded, failed
	OrderID          string        `json:"order_id"`          // Razorpay order ID
	InvoiceID        string        `json:"invoice_id"`        // Razorpay invoice ID
	Method           string        `json:"method"`            // Payment method (card, netbanking, wallet, upi)
	Description      string        `json:"description"`       // Payment description
	CardID           string        `json:"card_id"`           // Card ID (if payment method is card)
	Bank             string        `json:"bank"`              // Bank name (if payment method is netbanking)
	Wallet           string        `json:"wallet"`            // Wallet name (if payment method is wallet)
	VPA              string        `json:"vpa"`               // Virtual Payment Address (if payment method is UPI)
	AmountRefunded   int64         `json:"amount_refunded"`   // Amount refunded
	Refunded         bool          `json:"refunded"`          // Whether payment is refunded
	Captured         bool          `json:"captured"`          // Whether payment is captured
	Email            string        `json:"email"`             // Customer email
	Contact          string        `json:"contact"`           // Customer contact
	Fee              int64         `json:"fee"`               // Gateway fee
	Tax              int64         `json:"tax"`               // Tax on fee
	ErrorCode        string        `json:"error_code"`        // Error code if payment failed
	ErrorDescription string        `json:"error_description"` // Error description if payment failed
	ErrorSource      string        `json:"error_source"`      // Error source
	ErrorStep        string        `json:"error_step"`        // Error step
	ErrorReason      string        `json:"error_reason"`      // Error reason
	Notes            FlexibleNotes `json:"notes"`             // Custom notes (can be object or array)
	CreatedAt        int64         `json:"created_at"`        // Unix timestamp
}

Payment represents a Razorpay payment

type RazorpayEventType

type RazorpayEventType string

RazorpayEventType represents the type of Razorpay webhook event

const (
	// Payment events
	EventPaymentCaptured   RazorpayEventType = "payment.captured"
	EventPaymentFailed     RazorpayEventType = "payment.failed"
	EventPaymentAuthorized RazorpayEventType = "payment.authorized"
)

type RazorpayPaymentMethod

type RazorpayPaymentMethod string

RazorpayPaymentMethod represents the payment method used in Razorpay

const (
	RazorpayPaymentMethodCard       RazorpayPaymentMethod = "card"
	RazorpayPaymentMethodUPI        RazorpayPaymentMethod = "upi"
	RazorpayPaymentMethodWallet     RazorpayPaymentMethod = "wallet"
	RazorpayPaymentMethodNetbanking RazorpayPaymentMethod = "netbanking"
	RazorpayPaymentMethodEMI        RazorpayPaymentMethod = "emi"
	RazorpayPaymentMethodCardless   RazorpayPaymentMethod = "cardless_emi"
	RazorpayPaymentMethodPaylater   RazorpayPaymentMethod = "paylater"
)

type RazorpayWebhookEvent

type RazorpayWebhookEvent struct {
	Entity    string                 `json:"entity"`
	AccountID string                 `json:"account_id"`
	Event     string                 `json:"event"`
	Contains  []string               `json:"contains"`
	Payload   RazorpayWebhookPayload `json:"payload"`
	CreatedAt int64                  `json:"created_at"`
}

RazorpayWebhookEvent represents a Razorpay webhook event

type RazorpayWebhookPayload

type RazorpayWebhookPayload struct {
	Payment PayloadPayment `json:"payment"`
}

RazorpayWebhookPayload represents the payload of a Razorpay webhook

type ServiceDependencies

type ServiceDependencies = interfaces.ServiceDependencies

ServiceDependencies contains all service dependencies needed by webhook handlers

Jump to

Keyboard shortcuts

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