-
Notifications
You must be signed in to change notification settings - Fork 7
feat(archipel): add authorize flow #253
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
| request: Request, | ||
| _flow_name: &str, | ||
| ) -> CustomResult<Result<Response, Response>, ApiClientError> { | ||
| println!(">>> {:?}", request.body); |
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.
remove this.
| /// Represents details of a payment method. | ||
| #[derive(Debug, Clone)] | ||
| pub struct PaymentMethodDetails { | ||
| /// Indicates whether mandates are supported by this payment method. | ||
| pub mandates: common_enums::FeatureStatus, | ||
| /// Indicates whether refund is supported by this payment method. | ||
| pub refunds: common_enums::FeatureStatus, | ||
| /// List of supported capture methods | ||
| pub supported_capture_methods: Vec<common_enums::CaptureMethod>, | ||
| /// Payment method specific features | ||
| pub specific_features: Option<PaymentMethodSpecificFeatures>, | ||
| } | ||
|
|
||
| /// list of payment methods, payment method types and metadata related to them | ||
| pub type SupportedPaymentMethods = HashMap<common_enums::PaymentMethod, PaymentMethodTypeMetadata>; |
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.
are these changes required?
| use std::collections::HashMap; | ||
|
|
||
| use common_utils::Method; | ||
| use crate::types::{PaymentMethodSpecificFeatures, PaymentMethodTypeMetadata}; |
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.
is this required?
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.
no removed
| Cybersource, Dlocal, Elavon, Fiserv, Fiuu, Helcim, Mifinity, Nexinets, Noon, Novalnet, Paytm, | ||
| Payu, Phonepe, Placetopay, Rapyd, Razorpay, RazorpayV2, Stripe, Trustpay, Volt, Worldpay, | ||
| Xendit, | ||
| Xendit, Archipel |
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.
maintain alphabetical order here
backend/common_enums/src/enums.rs
Outdated
|
|
||
| pub enum PaymentMethodStatus { | ||
| Active, | ||
| Inactive, | ||
| Processing, | ||
| AwaitingData, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone)] | ||
| pub enum FeatureStatus { | ||
| NotSupported, | ||
| Supported, | ||
| } |
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.
is this required?
| pub fn connector_base_url_refunds<'a, F, Req, Res>( | ||
| &self, | ||
| req: &'a RouterDataV2<F, RefundFlowData, Req, Res>, | ||
| ) -> &'a str { | ||
| &req.resource_common_data.connectors.archipel.base_url | ||
| } | ||
| } |
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.
Please check if we can remove this function from here. This function should be included in refunds PR.
| // TODO: Implement proper error response parsing | ||
| Ok(ErrorResponse { | ||
| status_code: res.status_code, | ||
| code: NO_ERROR_CODE.to_string(), |
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.
Check if code can be filled from the error response.
| code: NO_ERROR_CODE.to_string(), | ||
| attempt_status: None, | ||
| connector_transaction_id: None, | ||
| message: NO_ERROR_MESSAGE.to_string(), |
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.
Check if message can be filled from the error response.
| attempt_status: None, | ||
| connector_transaction_id: None, | ||
| message: NO_ERROR_MESSAGE.to_string(), | ||
| reason: None, |
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.
Check if reason can be filled from the error response.
|
Resolve Merge Conflicts. |
|
Run |
| let capture_method = req | ||
| .request | ||
| .capture_method | ||
| .ok_or(errors::ConnectorError::CaptureMethodNotSupported)?; |
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.
Use MissingRequiredField: capture_method here
| build_env_specific_endpoint(self.connector_base_url_payments(req), &req.request.metadata)?; | ||
| match capture_method { | ||
| enums::CaptureMethod::Automatic | enums::CaptureMethod::SequentialAutomatic => { | ||
| println!("here"); |
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.
remove this println line
| utils::CardIssuer, | ||
| }; | ||
| use error_stack::{ report}; | ||
| // use hyperswitch_interfaces::{consts, errors}; |
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.
remove this comment if it's not required
| use serde_json::Value; | ||
|
|
||
| use crate::{ | ||
| // connectors::archipel::ArchipelRouterData, |
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.
remove this comment if it's not required
| // impl TryFrom<&Option<pii::SecretSerdeValue>> for ArchipelConfigData { | ||
| // type Error = error_stack::Report<errors::ConnectorError>; | ||
| // fn try_from(connector_metadata: &Option<pii::SecretSerdeValue>) -> Result<Self, Self::Error> { | ||
| // let config_data = utils::to_connector_meta_from_secret::<Self>(connector_metadata.clone()) | ||
| // .change_context(errors::ConnectorError::InvalidConnectorConfig { | ||
| // config: "metadata. Required fields: tenant_id, platform_url", | ||
| // })?; | ||
| // Ok(config_data) | ||
| // } | ||
| // } |
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.
remove this comment if it's not required
| // fn to_connector_meta( | ||
| // connector_meta: Option<Value>, | ||
| // ) -> CustomResult<ArchipelConfigData, ConnectorError> { | ||
| // Ok(connector_meta | ||
| // .map(|meta| { | ||
| // print!("meta value {:?}",meta); | ||
| // serde_json::from_value::<ArchipelConfigData>(meta) | ||
| // .map_err(|_| report!(errors::ConnectorError::InvalidDataFormat { field_name: "metadata" })) | ||
| // }) | ||
| // .transpose()? | ||
| // .ok_or_else(|| ConnectorError::NoConnectorMetaData)?) | ||
| // } |
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.
remove this comment if it's not required
| #[serde(rename_all = "camelCase")] | ||
| pub struct ArchipelOrderRequest { | ||
| amount: MinorUnit, | ||
| currency: String, |
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.
| currency: String, | |
| currency: enums::Currency, |
| + Serialize, | ||
| > { | ||
| card_data: ArchipelTokenizedCard<T>, | ||
| // wallet_information: ArchipelWalletInformation, |
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.
remove this line
| AttemptStatus::AuthenticationFailed => Ok(Self::Verify), | ||
| AttemptStatus::Authorizing | ||
| | AttemptStatus::Authorized | ||
| | AttemptStatus::AuthorizationFailed => Ok(Self::Authorize), |
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.
Why AuthorizationFailed is mapped with Authorize?
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.
should it be cancel then ?
| amount: Option<i64>, | ||
| currency: Option<Currency>, | ||
| captured_amount: Option<i64>, | ||
| authorized_amount: Option<i64>, |
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.
Use MinorUnit instead of i64.
| .router_data | ||
| .request | ||
| .capture_method | ||
| .ok_or_else(|| errors::ConnectorError::CaptureMethodNotSupported)?; |
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.
use MissingRequiredField: capture_method here.
| AttemptStatus::Authorizing | ||
| | AttemptStatus::Authorized | ||
| | AttemptStatus::AuthorizationFailed => Ok(Self::Authorize), | ||
| | AttemptStatus::AuthorizationFailed => Ok(Self::Cancel), |
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.
check this status mapping
Description
Added CA certificate support for API calls in the Archipel connector, following the pattern from hyperswitch PR #8128. This enables one-way TLS
authentication with custom CA certificates for the Archipel connector.
Changes made:
ConnectorIntegrationV2 Trait (
backend/interfaces/src/connector_integration_v2.rs)get_ca_certificate()method to the trait interfacebuild_request_v2()to call.add_ca_certificate_pem()Archipel Connector (
backend/connector-integration/src/connectors/archipel.rs)get_ca_cert()helper function to extract CA certificate from authget_ca_certificate()method to return the CA certificate from auth detailsHTTP Client (
backend/external-services/src/service.rs)create_client()function to support three modes:Archipel Auth Type (already existed in
transformers.rs)ca_certificatefield inArchipelAuthTypeConnectorAuthType::HeaderKey { api_key }Motivation and Context
The Archipel connector requires custom CA certificate support for secure communication with their API endpoints. This allows the connector to authenticate the server using a custom CA certificate, which
is essential for environments with self-signed or internal CA certificates.
This implementation follows the established pattern from the hyperswitch repository to maintain consistency across the codebase.
Type of Change
Additional Changes
How did you test it?
cargo build --workspaceManual Testing Required:
To fully test this feature, the following steps should be performed:
HeaderKeyauth typeFiles Modified:
backend/interfaces/src/connector_integration_v2.rs:211-220- Addedget_ca_certificate()methodbackend/interfaces/src/connector_integration_v2.rs:108- Added.add_ca_certificate_pem()callbackend/connector-integration/src/connectors/archipel.rs:34- AddedSecretimportbackend/connector-integration/src/connectors/archipel.rs:168-177- Addedget_ca_cert()helperbackend/connector-integration/src/connectors/archipel.rs:779-784- Overrodeget_ca_certificate()backend/external-services/src/service.rs:741-788- Implemented CA cert support in HTTP client