Processor Agnostic Payments
- Introduction
- Architecture Overview
- Component/Implementation Overview
- Supported Payment Processors and Methods
- Getting Started
- Contribution
- Related Projects
The "Linux moment" for payments.
Connector Service is an open source, stateless merchant payments abstraction service (built using gRPC) that enables developers to integrate with a wide variety of payment processors using a unified contract. It offers the following capabilities.
- Unified contract across multiple payment processors
- Establishing and accepting connections to numerous remote endpoints of payment processors like Stripe/Adyen/Razorpay
- Supports all payment payment life-cycle management operations like including authorization, capture, refunds, status and chargebacks across processors
- Client-SDKs in multiple programming languages (Java, Python, Go, Rust, PHP) for rapid integration.
The objective is to liberate merchants and fintechs from being locked-in to the contract of a single payment processor and make switching payment processors a breeze. Given its open source nature, we expect it to eventually encompass the widest variety of processor support across the globe through community contributions and support.
The Connector Service has been in production since Jan 2023 and is a part of Hyperswitch - Composable & Open Source Payment Orchestration platform, built by the team from Juspay.
Built for scalability and portability, it allows businesses to seamlessly switch processors without disrupting their internal business logic. One can think of this as the payments equivalent of the open telemetry and open feature.
The connector service comprises of two major runtime components:
- a gRPC service that offers a unified interface for all merchant payment operations supported by different payment processors around the world. This service would run as part of your application deployment. Some of these operations include:
- authorization
- capture
- refund
- chargeback
- dispute
- webhook normalization
- a client (typically in the language of your choice) that integrates in your application to invoke the above gRPC service.
The code for the project is organized in the following directory structure. The details for the key directories is explained below:
connector-service/
βββ backend/
β βββ connector-integration/
β βββ grpc-api-types/
β β βββ proto/
β βββ grpc-server/
β βββ domain-types/
βββ sdk/
β βββ node-grpc-client/
β βββ python-grpc-client/
β βββ rust-grpc-client/
βββ README.md
grpc-server - Implements the gRPC server. It receives requests via defined gRPC interfaces, performs flow-type conversions, interacts with connector-integration to generate the connector-specific CURL request, sends the request to the connector, and constructs the appropriate response
connector-integration - Contains payment processor specific transformations and logic for each flow. It is responsible for converting generic flow data into payment processor specific formats and generating the corresponding HTTP (CURL) requests
grpc-api-types - Auto-generated gRPC API types and interface definitions, generated from .proto files. These types are used for communication between services and clients. Also contains .proto files for each gRPC service, which define the data structures and service interfaces used for communication
domain-types - Common intermediate representation for the grpc-server
and the connector-integration
components to operate on.
sdk - Provides client SDKs for different languages to interact with the gRPC server, allowing users to integrate easily with their system
The connector-integration
component uses Rust's trait mechanism to allow each payment processor to define its implementation for a particular payment operation. Each payment operation is expected to implement the following set of functions that enables the framework to create and invoke the appropriate API of the payment processor.
trait ConnectorIntegration<Flow, ResourceCommonData, Req, Resp> {
fn get_headers();
fn get_content_type();
fn get_http_method();
fn get_url();
fn get_request_body();
fn build_request();
fn handle_response();
fn get_error_response();
}
On similar lines there is a trait to implement the processing of webhooks and convert it to the common representation.
trait IncomingWebhook {
fn verify_webhook_source();
fn get_event_type();
fn process_payment_webhook();
fn process_refund_webhook();
}
Before setting up the project, ensure you have the following pre-requisites installed:
-
Setup Rust/Cargo
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
When prompted, proceed with the
default
profile, which installs the stable toolchain.Optionally, verify that the Rust compiler and
cargo
are successfully installed:rustc --version
Be careful when running shell scripts downloaded from the Internet. We only suggest running this script as there seems to be no
rustup
package available in the Ubuntu package repository. -
Setup grpcurl
brew install grpcurl
grpcurl --version
- Setup Rust/Cargo
Option 1: Using the installer Download the Rust installer from https://www.rust-lang.org/tools/install Run the downloaded executable (rustup-init.exe) Follow the on-screen instructions
Option 2: Using powershell
winget install -e --id Rustlang.Rust.GNU
- Setup grpcurl
choco install grpcurl
- Setup Rust/Cargo
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Setup grpcurl
# Download the latest grpcurl release (replace version if needed)
curl -sLO https://github.com/fullstorydev/grpcurl/releases/latest/download/grpcurl_$(uname -s)_$(uname -m).tar.gz
# Extract the binary
tar -xzf grpcurl_$(uname -s)_$(uname -m).tar.gz
# Move it to a directory in your PATH
sudo mv grpcurl /usr/local/bin/
# Verify the installation
grpcurl --version
Test the gRPC endpoints using client SDKs or Postman alternatives that support gRPC. Sample SDKs are available in the sdk
directory for Python, Rust, etc.
-
Clone the Project
git clone https://github.com/juspay/connector-service.git
-
Navigate into your project directory
cd connector-service
-
Compile the project
cargo compile
-
Build the project
cargo build
-
Start the server
cargo run
You can test your gRPC service with a command like this:
grpcurl -plaintext -d '{
"connector_request_reference_id": "YOUR_CONNECTOR_REFERENCE_ID",
"connector": "ADYEN",
"auth_creds": {
"signature_key": {
"api_key": "CONNECTOR_API_KEY",
"key1": "CONNECTOR_KEY`",
"api_secret": "CONNECTOR_API_SECRET"
}
}
}' localhost:8000 ucs.payments.PaymentService/VoidPayment
The final part of the command β localhost:8000 ucs.payments.PaymentService/VoidPayment β corresponds to the VoidPayment RPC defined in your payment.proto file. Depending on which RPC method you want to invoke, you can replace VoidPayment with any of the following method names defined under PaymentService.
Note: π‘ Replace all placeholders (YOUR_CONNECTOR_REFERENCE_ID, CONNECTOR_API_KEY, etc.) with actual values for your payments processors.
On running the above grpcURL command, you'll should see a response like the following:
{
"resourceId": {
"connectorTransactionId": "W6CDD8BLRRRPDKV5"
},
"connectorResponseReferenceId": "W6CDD8BLRRRPDKV5",
"status": "VOIDED"
}
We welcome contributions from the community and enterprises alike. If you're integrating a new payment processor or improving performance, feel free to fork and submit a PR!
git checkout -b feature/new-connector
# make changes
git commit -m "Add support for [NewProcessor]"
git push origin feature/new-connector
# Open Pull Request
Ensure all code is linted and tested:
Ensure that all your code is linted and formatted properly by running the following commands:
- Lint the code with Clippy:
cargo clippy
What clippy does:
- Checks for style issues and enforces Rust's best practices.
- Catches potential bugs like unused variables or inefficient code.
- Suggests performance optimizations and refactoring opportunities.
- Format the code with Nightly rustfmt:
cargo +nightly fmt --all
What cargo fmt does:
- Uses the nightly Rust compiler, enabling experimental features.
- Formats your code consistently according to Rust's style guide.
Connector | Authorize | Capture | Sale | Refunds | Disputes | Status | Webhooks |
---|---|---|---|---|---|---|---|
Stripe | |||||||
Adyen | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ |
Paypal | |||||||
Braintree | |||||||
Authorize.net | |||||||
Checkout.com | |||||||
JP Morgan | |||||||
Bank of America | |||||||
Fiserv | |||||||
Wells Fargo | |||||||
Global Payments | |||||||
Elavon | |||||||
Paytm | |||||||
Razorpay | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | |
Phonepe | |||||||
PayU | |||||||
Billdesk |
Built on top of Connector Service, Hyperswitch offers a complete payments orchestration layer with routing, retries, and full lifecycle management.