Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat(connector): [Cryptopay]Add reference id for cryptopay (#2107)

Prasunna Soppa576648b5a5d7
diff --git a/crates/router/src/connector/cryptopay.rs b/crates/router/src/connector/cryptopay.rs
index deaa79711a..2feb5089ab 100644
--- a/crates/router/src/connector/cryptopay.rs
+++ b/crates/router/src/connector/cryptopay.rs
@@ -398,9 +398,14 @@ impl api::IncomingWebhook for Cryptopay {
.body
.parse_struct("CryptopayWebhookDetails")
.change_context(errors::ConnectorError::WebhookReferenceIdNotFound)?;
- Ok(api_models::webhooks::ObjectReferenceId::PaymentId(
- api_models::payments::PaymentIdType::ConnectorTransactionId(notif.data.id),
- ))
+ match notif.data.custom_id {
+ Some(custom_id) => Ok(api_models::webhooks::ObjectReferenceId::PaymentId(
+ api_models::payments::PaymentIdType::PaymentAttemptId(custom_id),
+ )),
+ None => Ok(api_models::webhooks::ObjectReferenceId::PaymentId(
+ api_models::payments::PaymentIdType::ConnectorTransactionId(notif.data.id),
+ )),
+ }
}
fn get_webhook_event_type(
diff --git a/crates/router/src/connector/cryptopay/transformers.rs b/crates/router/src/connector/cryptopay/transformers.rs
index 37c8f3f07a..d360fbcca3 100644
--- a/crates/router/src/connector/cryptopay/transformers.rs
+++ b/crates/router/src/connector/cryptopay/transformers.rs
@@ -16,6 +16,7 @@ pub struct CryptopayPaymentsRequest {
pay_currency: String,
success_redirect_url: Option<String>,
unsuccess_redirect_url: Option<String>,
+ custom_id: String,
}
impl TryFrom<&types::PaymentsAuthorizeRouterData> for CryptopayPaymentsRequest {
@@ -33,6 +34,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for CryptopayPaymentsRequest {
pay_currency,
success_redirect_url: item.clone().request.router_return_url,
unsuccess_redirect_url: item.clone().request.router_return_url,
+ custom_id: item.connector_request_reference_id.clone(),
})
}
_ => Err(errors::ConnectorError::NotImplemented(
@@ -112,12 +114,18 @@ impl<F, T>
Ok(Self {
status: enums::AttemptStatus::from(item.response.data.status),
response: Ok(types::PaymentsResponseData::TransactionResponse {
- resource_id: types::ResponseId::ConnectorTransactionId(item.response.data.id),
+ resource_id: types::ResponseId::ConnectorTransactionId(
+ item.response.data.id.clone(),
+ ),
redirection_data,
mandate_reference: None,
connector_metadata: None,
network_txn_id: None,
- connector_response_reference_id: None,
+ connector_response_reference_id: item
+ .response
+ .data
+ .custom_id
+ .or(Some(item.response.data.id)),
}),
..item.data
})
@@ -139,6 +147,7 @@ pub struct CryptopayErrorResponse {
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct CryptopayPaymentResponseData {
pub id: String,
+ pub custom_id: Option<String>,
pub customer_id: Option<String>,
pub status: CryptopayPaymentStatus,
pub status_context: Option<String>,