mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 01:27:31 +08:00
refactor(connector): [Stripebilling] change Billing Connector Payment Sync url from charges to payment intents api (#7893)
Co-authored-by: Nishanth Challa <nishanth.challa@Nishanth-Challa-C0WGKCFHLF.local>
This commit is contained in:
committed by
GitHub
parent
bbec7a41f7
commit
af5e56ef9d
@ -599,7 +599,7 @@ impl
|
|||||||
connectors: &Connectors,
|
connectors: &Connectors,
|
||||||
) -> CustomResult<String, errors::ConnectorError> {
|
) -> CustomResult<String, errors::ConnectorError> {
|
||||||
Ok(format!(
|
Ok(format!(
|
||||||
"{}v1/charges/{}",
|
"{}v1/payment_intents/{}?expand[0]=latest_charge",
|
||||||
self.base_url(connectors),
|
self.base_url(connectors),
|
||||||
req.request.billing_connector_psync_id
|
req.request.billing_connector_psync_id
|
||||||
))
|
))
|
||||||
@ -632,10 +632,10 @@ impl
|
|||||||
recovery_router_data_types::BillingConnectorPaymentsSyncRouterData,
|
recovery_router_data_types::BillingConnectorPaymentsSyncRouterData,
|
||||||
errors::ConnectorError,
|
errors::ConnectorError,
|
||||||
> {
|
> {
|
||||||
let response: stripebilling::StripebillingRecoveryDetailsData = res
|
let response: stripebilling::StripebillingBillingConnectorPaymentSyncResponseData = res
|
||||||
.response
|
.response
|
||||||
.parse_struct::<stripebilling::StripebillingRecoveryDetailsData>(
|
.parse_struct::<stripebilling::StripebillingBillingConnectorPaymentSyncResponseData>(
|
||||||
"StripebillingRecoveryDetailsData",
|
"StripebillingBillingConnectorPaymentSyncResponseData",
|
||||||
)
|
)
|
||||||
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
|
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
|
||||||
|
|
||||||
@ -807,7 +807,9 @@ impl webhooks::IncomingWebhook for Stripebilling {
|
|||||||
stripebilling::StripebillingWebhookBody::get_webhook_object_from_body(request.body)
|
stripebilling::StripebillingWebhookBody::get_webhook_object_from_body(request.body)
|
||||||
.change_context(errors::ConnectorError::WebhookReferenceIdNotFound)?;
|
.change_context(errors::ConnectorError::WebhookReferenceIdNotFound)?;
|
||||||
Ok(api_models::webhooks::ObjectReferenceId::PaymentId(
|
Ok(api_models::webhooks::ObjectReferenceId::PaymentId(
|
||||||
api_models::payments::PaymentIdType::ConnectorTransactionId(webhook.data.object.charge),
|
api_models::payments::PaymentIdType::ConnectorTransactionId(
|
||||||
|
webhook.data.object.payment_intent,
|
||||||
|
),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -296,6 +296,7 @@ pub struct StripebillingWebhookObject {
|
|||||||
#[serde(rename = "amount_remaining")]
|
#[serde(rename = "amount_remaining")]
|
||||||
pub amount: common_utils::types::MinorUnit,
|
pub amount: common_utils::types::MinorUnit,
|
||||||
pub charge: String,
|
pub charge: String,
|
||||||
|
pub payment_intent: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
@ -346,7 +347,12 @@ impl TryFrom<StripebillingInvoiceBody> for revenue_recovery::RevenueRecoveryInvo
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
pub struct StripebillingRecoveryDetailsData {
|
pub struct StripebillingBillingConnectorPaymentSyncResponseData {
|
||||||
|
pub latest_charge: StripebillingLatestChargeData,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
|
pub struct StripebillingLatestChargeData {
|
||||||
#[serde(rename = "id")]
|
#[serde(rename = "id")]
|
||||||
pub charge_id: String,
|
pub charge_id: String,
|
||||||
pub status: StripebillingChargeStatus,
|
pub status: StripebillingChargeStatus,
|
||||||
@ -410,7 +416,7 @@ impl
|
|||||||
TryFrom<
|
TryFrom<
|
||||||
ResponseRouterData<
|
ResponseRouterData<
|
||||||
recovery_router_flows::BillingConnectorPaymentsSync,
|
recovery_router_flows::BillingConnectorPaymentsSync,
|
||||||
StripebillingRecoveryDetailsData,
|
StripebillingBillingConnectorPaymentSyncResponseData,
|
||||||
recovery_request_types::BillingConnectorPaymentsSyncRequest,
|
recovery_request_types::BillingConnectorPaymentsSyncRequest,
|
||||||
recovery_response_types::BillingConnectorPaymentsSyncResponse,
|
recovery_response_types::BillingConnectorPaymentsSyncResponse,
|
||||||
>,
|
>,
|
||||||
@ -420,45 +426,45 @@ impl
|
|||||||
fn try_from(
|
fn try_from(
|
||||||
item: ResponseRouterData<
|
item: ResponseRouterData<
|
||||||
recovery_router_flows::BillingConnectorPaymentsSync,
|
recovery_router_flows::BillingConnectorPaymentsSync,
|
||||||
StripebillingRecoveryDetailsData,
|
StripebillingBillingConnectorPaymentSyncResponseData,
|
||||||
recovery_request_types::BillingConnectorPaymentsSyncRequest,
|
recovery_request_types::BillingConnectorPaymentsSyncRequest,
|
||||||
recovery_response_types::BillingConnectorPaymentsSyncResponse,
|
recovery_response_types::BillingConnectorPaymentsSyncResponse,
|
||||||
>,
|
>,
|
||||||
) -> Result<Self, Self::Error> {
|
) -> Result<Self, Self::Error> {
|
||||||
let merchant_reference_id = id_type::PaymentReferenceId::from_str(
|
let charge_details = item.response.latest_charge;
|
||||||
&item.response.invoice_id,
|
let merchant_reference_id =
|
||||||
)
|
id_type::PaymentReferenceId::from_str(charge_details.invoice_id.as_str())
|
||||||
.change_context(errors::ConnectorError::MissingRequiredField {
|
.change_context(errors::ConnectorError::MissingRequiredField {
|
||||||
field_name: "invoice_id",
|
field_name: "invoice_id",
|
||||||
})?;
|
})?;
|
||||||
let connector_transaction_id = Some(common_utils::types::ConnectorTransactionId::from(
|
let connector_transaction_id = Some(common_utils::types::ConnectorTransactionId::from(
|
||||||
item.response.charge_id,
|
charge_details.charge_id,
|
||||||
));
|
));
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
response: Ok(
|
response: Ok(
|
||||||
recovery_response_types::BillingConnectorPaymentsSyncResponse {
|
recovery_response_types::BillingConnectorPaymentsSyncResponse {
|
||||||
status: item.response.status.into(),
|
status: charge_details.status.into(),
|
||||||
amount: item.response.amount,
|
amount: charge_details.amount,
|
||||||
currency: item.response.currency,
|
currency: charge_details.currency,
|
||||||
merchant_reference_id,
|
merchant_reference_id,
|
||||||
connector_account_reference_id:
|
connector_account_reference_id:
|
||||||
MCA_ID_IDENTIFIER_FOR_STRIPE_IN_STRIPEBILLING_MCA_FEAATURE_METADATA
|
MCA_ID_IDENTIFIER_FOR_STRIPE_IN_STRIPEBILLING_MCA_FEAATURE_METADATA
|
||||||
.to_string(),
|
.to_string(),
|
||||||
connector_transaction_id,
|
connector_transaction_id,
|
||||||
error_code: item.response.failure_code,
|
error_code: charge_details.failure_code,
|
||||||
error_message: item.response.failure_message,
|
error_message: charge_details.failure_message,
|
||||||
processor_payment_method_token: item.response.payment_method,
|
processor_payment_method_token: charge_details.payment_method,
|
||||||
connector_customer_id: item.response.customer,
|
connector_customer_id: charge_details.customer,
|
||||||
transaction_created_at: Some(item.response.created),
|
transaction_created_at: Some(charge_details.created),
|
||||||
payment_method_sub_type: common_enums::PaymentMethodType::from(
|
payment_method_sub_type: common_enums::PaymentMethodType::from(
|
||||||
item.response
|
charge_details
|
||||||
.payment_method_details
|
.payment_method_details
|
||||||
.card_funding_type
|
.card_funding_type
|
||||||
.funding,
|
.funding,
|
||||||
),
|
),
|
||||||
payment_method_type: common_enums::PaymentMethod::from(
|
payment_method_type: common_enums::PaymentMethod::from(
|
||||||
item.response.payment_method_details.type_of_payment_method,
|
charge_details.payment_method_details.type_of_payment_method,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user