Skip to main content

Stripe, PayPal, and Razorpay behind one Go interface

gopay is a unified payment-processing library for Go — provider-agnostic types, sentinel errors, and a mock provider for tests. Each provider ships as its own Go module, so importing one never pulls in the SDKs of the others.

go get github.com/KARTIKrocks/gopay

Unified Interface

One API across Stripe, PayPal, and Razorpay

Dependency Isolation

Each provider is its own Go module — only pull in the SDKs you use

Payments

Create, capture (automatic or manual), get, and cancel

Refunds

Full and partial refund processing

Customer Management

Create and manage customers (Stripe, Razorpay)

Payment Methods

Attach and manage saved payment methods

Setup Intents

Save a card for later, off-session charges (Stripe)

Subscriptions

Plans and recurring billing (Stripe, Razorpay)

Invoices

Read-only invoice retrieval with hosted invoice URLs

Webhooks

Signature-verified, normalized events across providers

Cursor Pagination

A consistent List/paginate pattern across providers

Mock Provider

A full-featured in-memory provider for tests — no network

Why gopay?

Calling a payment provider's SDK directly gets you a working integration with exactly one provider. Everything past that — the parts that turn "I can charge a card with Stripe" into "I can swap in Razorpay for a region without rewriting my checkout code" — is what gopay provides.

Capability
One interface across Stripe, PayPal, and Razorpay
Sentinel errors (errors.Is) instead of per-SDK error types
Builder + Validate() requests catch mistakes before the API call
Cursor-based pagination, normalized across providers
Webhook signature verification + normalized event kinds
Mock provider for tests — no network, no API keys
Dependency isolation — only the SDKs you actually use

Supported Providers

Providers only implement what they support — PayPal's Orders API has no customer or list endpoint, and only Stripe implements setup intents. See the docs for provider-specific quirks.

ProviderPaymentsRefundsCustomersPayment MethodsSetup IntentsSubscriptionsInvoicesWebhooksListing
StripeSupportedSupportedSupportedSupportedSupportedSupportedSupportedSupportedSupported
PayPalSupportedSupportedNot supportedNot supportedNot supportedNot supportedNot supportedSupportedNot supported
RazorpaySupportedSupportedSupportedNot supportedNot supportedSupportedSupportedSupportedSupported