Domain specific language
The Prism DSL
DSL for Connector Development
Method
Purpose
When Called
impl ConnectorIntegration<Authorize, AuthorizeRequest, AuthorizeResponse> for Stripe {
fn get_headers(
&self,
req: &AuthorizeRequest,
connectors: &Connectors,
) -> CustomResult<Vec<(String, SecretString)>, errors::ConnectorError> {
// Build authentication headers
vec![
("Authorization".to_string(), format!("Bearer {}", self.api_key).into()),
("Content-Type".to_string(), "application/json".to_string().into()),
]
}
fn get_url(
&self,
_req: &AuthorizeRequest,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(format!("{}/v1/payment_intents", self.base_url))
}
fn get_request_body(
&self,
req: &AuthorizeRequest,
) -> CustomResult<RequestContent, errors::ConnectorError> {
// Transform unified request to Stripe-specific payload
let stripe_payload = StripeAuthorizeRequest::try_from(req)?;
Ok(RequestContent::Json(Box::new(stripe_payload)))
}
fn handle_response(
&self,
data: &AuthorizeRequest,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsResponseData, errors::ConnectorError> {
// Parse Stripe response into unified format
let response: StripeAuthorizeResponse = res.response?.parse_struct("StripeAuthorizeResponse")?;
Ok(PaymentsResponseData {
status: response.status.into(),
connector_transaction_id: response.id,
// ... other fields
})
}
fn build_error_response(
&self,
res: Response,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
// Transform Stripe error into unified error format
let error: StripeErrorResponse = res.response?.parse_struct("StripeErrorResponse")?;
Ok(ErrorResponse {
code: error.code,
message: error.message,
unified_code: map_stripe_error_to_unified(&error),
})
}
}Protocol Buffers
Last updated
Was this helpful?

