-
Notifications
You must be signed in to change notification settings - Fork 3.9k
docs: update connector guide #8739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This is not ready, getting early feedback |
341aa93
to
d2e7796
Compare
This is ready for review |
07524e8
to
6af9f32
Compare
6af9f32
to
2b801b7
Compare
@deepanshu-iiitu incorporated your feedback, if you want to take a look |
2b801b7
to
da92600
Compare
b697b7f
…ms, reworked the tests instructions, added more details for the open api generator
…n utility functions
…rs based on pr feedback
b697b7f
to
371489c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you do the same for the rest of the source code links, please use permalinks instead of links to code on the main
branch.
* Familiarity with the Connector API you’re integrating | ||
* A locally set up and running Router repository | ||
* API credentials for testing (sign up for sandbox/UAT credentials on the connector’s website). | ||
* Need help? Join the [Hyperswitch Slack Channel](https://join.slack.com/t/hyperswitch-io/shared_invite/zt-39d4w0043-CgAyb75Kn0YldNyZpd8hWA). We also have weekly office hours every Thursday at 8:00 AM PT (11:00 AM ET, 4:00 PM BST, 5:00 PM CEST, and 8:30 PM IST). Link to office hours are shared in the **#general channel**. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to include the inviter link here?
From the root of the project, generate a new connector by running the following command. Use a single-word name for your `ConnectorName`: | ||
|
||
```bash | ||
sh scripts/add_connector.sh <ConnectorName> <ConnectorBaseUrl> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we're running this script, we would need cargo-generate
tool to be installed. Have we documented anywhere that it must be installed?
|
||
--- | ||
|
||
### 1. Flow Summary Table |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: The source code links in this table may go stale, if new lines are added in the file. We can consider including permalinks to lines in code instead, if that helps.
1. **Tokenization** – e.g., Billwerk’s implementation: | ||
- [Tokenization](https://github.com/juspay/hyperswitch/blob/main/crates/hyperswitch_connectors/src/connectors/billwerk.rs#L178-L271) | ||
- [Authorization](https://github.com/juspay/hyperswitch/blob/main/crates/hyperswitch_connectors/src/connectors/billwerk.rs#L273-L366) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, please use permalinks instead.
- **Authorize.net** – [code](https://github.com/juspay/hyperswitch/blob/main/crates/hyperswitch_connectors/src/connectors/authorizedotnet.rs#L401-L497) | ||
Builds `CreateTransactionRequest` directly from payment data in `get_request_body()`. | ||
|
||
- **Helcim** – [code](https://github.com/juspay/hyperswitch/blob/main/crates/hyperswitch_connectors/src/connectors/helcim.rs#L295-L385) | ||
Chooses purchase (auto‑capture) or preauth endpoint in `get_url()` and processes payment data directly. | ||
|
||
- **Deutsche Bank** – [code](https://github.com/juspay/hyperswitch/blob/main/crates/hyperswitch_connectors/src/connectors/deutschebank.rs#L330-L461) | ||
Selects flow based on 3DS and payment type (card or direct debit). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here as well, use permalinks instead.
- 4xx → [`get_error_response`](https://github.com/juspay/hyperswitch/blob/main/crates/hyperswitch_connectors/src/connectors/billwerk.rs#L256) | ||
- 5xx → [`get_5xx_error_response`](https://github.com/juspay/hyperswitch/blob/main/crates/hyperswitch_connectors/src/connectors/billwerk.rs#L264) | ||
- 2xx → [`handle_response`](https://github.com/juspay/hyperswitch/blob/main/crates/hyperswitch_connectors/src/connectors/billwerk.rs#L332) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, use permalinks instead.
- `mod.rs` - This file implements the standardized Hyperswitch connector interface using the transformers. | ||
|
||
### The `mod.rs` Implementation Pattern | ||
The file creates the bridge between the data transformation logic (defined in `transformers.rs`) and the connector interface requirements. It serves as the main connector implementation file that brings together all the components defined in the transformers module and implements all the required traits for payment processing. Looking at the connector template structure [`connector-template/mod.rs:54-67`](https://github.com/juspay/hyperswitch/blob/main/connector-template/mod.rs#L54-L67), you can see how it: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, use permalinks.
``` | ||
|
||
- `get_error_response` method to manage error responses. As the handling of checkout errors remains consistent across various flows, we've incorporated it from the `build_error_response` method within the `ConnectorCommon` trait. | ||
## ConnectorCommon: The Foundation Trait | ||
The `ConnectorCommon` trait defines the standardized interface required by Hyperswitch (as outlined in [`crates/hyperswitch_interfaces/src/api.rs`](https://github.com/juspay/hyperswitch/blob/main/crates/hyperswitch_interfaces/src/api.rs#L319-L367) and acts as the bridge to your PSP-specific logic in `transformers.rs`. The `connector-template/mod.rs` file implements this trait using the data types and transformation functions from `transformers.rs`. This allows Hyperswitch to interact with your connector in a consistent, processor-agnostic manner. Every connector must implement the `ConnectorCommon` trait, which provides essential connector properties: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, use permalinks instead.
- **Defined in `api.rs`** | ||
[`crates/hyperswitch_interfaces/src/api.rs:150–153`](https://github.com/juspay/hyperswitch/blob/main/crates/hyperswitch_interfaces/src/api.rs#L150) | ||
Provides the standardized interface contracts for connector integration. | ||
|
||
**PaymentCapture :** This trait extends the `api::ConnectorIntegration `trait with specific types related to manual payment capture. | ||
- **Implemented in `mod.rs`** | ||
Each connector’s main file (`mod.rs`) implements the trait methods for specific payment flows like authorize, capture, refund, etc. You can see how the Tsys connector implements [ConnectorIntegration](https://github.com/juspay/hyperswitch/blob/main/crates/hyperswitch_connectors/src/connectors/tsys.rs#L219) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, use permalinks instead.
|
||
**RefundSync :** This trait extends the `api::ConnectorIntegration `trait with specific types related to refunds retrieve. | ||
### Request/Response Flow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here as well, we can use permalinks instead wherever source code links are included.
Type of Change
Description
Updating the connector documentation
Additional Changes
Motivation and Context
Make it easier for developers to contribute
How did you test it?
Checklist
cargo +nightly fmt --all
cargo clippy