mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-03 21:37:41 +08:00
feat(connector): add mandate integration at the connector side (#101)
This commit is contained in:
@ -152,12 +152,23 @@ impl PaymentsAuthorizeRouterData {
|
||||
.payment_method_id;
|
||||
|
||||
resp.payment_method_id = Some(payment_method_id.clone());
|
||||
|
||||
resp.payment_method_id = Some(payment_method_id.clone());
|
||||
let mandate_reference = match resp.response.as_ref().ok() {
|
||||
Some(types::PaymentsResponseData::TransactionResponse {
|
||||
mandate_reference,
|
||||
..
|
||||
}) => mandate_reference.clone(),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
if let Some(new_mandate_data) = helpers::generate_mandate(
|
||||
self.merchant_id.clone(),
|
||||
self.connector.clone(),
|
||||
None,
|
||||
maybe_customer,
|
||||
payment_method_id,
|
||||
mandate_reference,
|
||||
) {
|
||||
resp.request.mandate_id = Some(new_mandate_data.mandate_id.clone());
|
||||
state.store.insert_mandate(new_mandate_data).await.map_err(
|
||||
|
||||
@ -105,12 +105,21 @@ impl types::VerifyRouterData {
|
||||
.payment_method_id;
|
||||
|
||||
resp.payment_method_id = Some(payment_method_id.clone());
|
||||
let mandate_reference = match resp.response.as_ref().ok() {
|
||||
Some(types::PaymentsResponseData::TransactionResponse {
|
||||
mandate_reference,
|
||||
..
|
||||
}) => mandate_reference.clone(),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
if let Some(new_mandate_data) = helpers::generate_mandate(
|
||||
self.merchant_id.clone(),
|
||||
self.connector.clone(),
|
||||
self.request.setup_mandate_details.clone(),
|
||||
maybe_customer,
|
||||
payment_method_id,
|
||||
mandate_reference,
|
||||
) {
|
||||
resp.request.mandate_id = Some(new_mandate_data.mandate_id.clone());
|
||||
state.store.insert_mandate(new_mandate_data).await.map_err(
|
||||
|
||||
@ -1132,6 +1132,7 @@ pub fn generate_mandate(
|
||||
setup_mandate_details: Option<api::MandateData>,
|
||||
customer: &Option<storage::Customer>,
|
||||
payment_method_id: String,
|
||||
connector_mandate_id: Option<String>,
|
||||
) -> Option<storage::MandateNew> {
|
||||
match (setup_mandate_details, customer) {
|
||||
(Some(data), Some(cus)) => {
|
||||
@ -1147,6 +1148,7 @@ pub fn generate_mandate(
|
||||
.set_payment_method_id(payment_method_id)
|
||||
.set_connector(connector)
|
||||
.set_mandate_status(storage_enums::MandateStatus::Active)
|
||||
.set_connector_mandate_id(connector_mandate_id)
|
||||
.set_customer_ip_address(
|
||||
data.customer_acceptance
|
||||
.get_ip_address()
|
||||
|
||||
@ -183,6 +183,7 @@ async fn payment_response_update_tracker<F: Clone, T>(
|
||||
resource_id,
|
||||
redirection_data,
|
||||
redirect,
|
||||
..
|
||||
} => {
|
||||
let connector_transaction_id = match resource_id {
|
||||
types::ResponseId::NoResponseId => None,
|
||||
|
||||
@ -68,6 +68,7 @@ where
|
||||
resource_id: types::ResponseId::ConnectorTransactionId(id.to_string()),
|
||||
redirection_data: None,
|
||||
redirect: false,
|
||||
mandate_reference: None,
|
||||
});
|
||||
|
||||
let orca_return_url = Some(helpers::create_redirect_url(
|
||||
|
||||
Reference in New Issue
Block a user