Skip to content

Commit

Permalink
add frm_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
AkshayaFoiger committed Oct 17, 2023
1 parent e0b0ea4 commit f760733
Show file tree
Hide file tree
Showing 24 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ paypal.base_url = "https://api-m.sandbox.paypal.com/"
payu.base_url = "https://secure.snd.payu.com/"
powertranz.base_url = "https://staging.ptranz.com/api/"
rapyd.base_url = "https://sandboxapi.rapyd.net"
riskified.base_url = "https://sandbox.riskified.com/api"
shift4.base_url = "https://api.shift4.com/"
square.base_url = "https://connect.squareupsandbox.com/"
square.secondary_base_url = "https://pci-connect.squareupsandbox.com/"
Expand Down
1 change: 1 addition & 0 deletions config/development.toml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ paypal.base_url = "https://api-m.sandbox.paypal.com/"
payu.base_url = "https://secure.snd.payu.com/"
powertranz.base_url = "https://staging.ptranz.com/api/"
rapyd.base_url = "https://sandboxapi.rapyd.net"
riskified.base_url = "https://sandbox.riskified.com/api"
shift4.base_url = "https://api.shift4.com/"
square.base_url = "https://connect.squareupsandbox.com/"
square.secondary_base_url = "https://pci-connect.squareupsandbox.com/"
Expand Down
1 change: 1 addition & 0 deletions config/docker_compose.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ paypal.base_url = "https://api-m.sandbox.paypal.com/"
payu.base_url = "https://secure.snd.payu.com/"
powertranz.base_url = "https://staging.ptranz.com/api/"
rapyd.base_url = "https://sandboxapi.rapyd.net"
riskified.base_url = "https://sandbox.riskified.com/api"
shift4.base_url = "https://api.shift4.com/"
square.base_url = "https://connect.squareupsandbox.com/"
square.secondary_base_url = "https://pci-connect.squareupsandbox.com/"
Expand Down
9 changes: 9 additions & 0 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ pub struct PaymentsRequest {
/// The type of the payment that differentiates between normal and various types of mandate payments
#[schema(value_type = Option<PaymentType>)]
pub payment_type: Option<api_enums::PaymentType>,

/// additional data related to some frm connectors
pub frm_metadata: Option<serde_json::Value>,

}

#[derive(Default, Debug, Clone, Copy)]
Expand Down Expand Up @@ -2243,6 +2247,8 @@ pub struct OrderDetailsWithAmount {
pub quantity: u16,
/// the amount per quantity of product
pub amount: i64,
// Does the order includes shipping
pub requires_shipping: bool,
}

#[derive(Debug, Default, Eq, PartialEq, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
Expand All @@ -2253,6 +2259,9 @@ pub struct OrderDetails {
/// The quantity of the product to be purchased
#[schema(example = 1)]
pub quantity: u16,
// Does the order include shipping
pub requires_shipping: bool,

}

#[derive(Default, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/core/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,7 @@ where
pub ephemeral_key: Option<ephemeral_key::EphemeralKey>,
pub redirect_response: Option<api_models::payments::RedirectResponse>,
pub frm_message: Option<FraudCheck>,
pub frm_metadata: Option<serde_json::Value>,
}

#[derive(Debug, Default, Clone)]
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/core/payments/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2659,6 +2659,7 @@ pub fn router_data_type_conversion<F1, F2, Req1, Req2, Res1, Res2>(
connector_http_status_code: router_data.connector_http_status_code,
external_latency: router_data.external_latency,
apple_pay_flow: router_data.apple_pay_flow,
frm_metadata: router_data.frm_metadata,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>
multiple_capture_data: None,
redirect_response,
frm_message: frm_response.ok(),
frm_metadata: request.frm_metadata.clone(),
},
Some(CustomerDetails {
customer_id: request.customer_id.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>
multiple_capture_data: None,
redirect_response: None,
frm_message: None,
frm_metadata: None,
},
None,
))
Expand Down
2 changes: 2 additions & 0 deletions crates/router/src/core/payments/operations/payment_capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>
multiple_capture_data,
redirect_response: None,
frm_message: None,
frm_metadata: None,

},
None,
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>
multiple_capture_data: None,
redirect_response,
frm_message: None,
frm_metadata: request.frm_metadata.clone(),
},
Some(CustomerDetails {
customer_id: request.customer_id.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>
multiple_capture_data: None,
redirect_response: None,
frm_message: None,
frm_metadata: request.frm_metadata.clone(),
},
Some(customer_details),
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>
multiple_capture_data: None,
redirect_response: None,
frm_message: None,
frm_metadata: request.frm_metadata.clone(),
},
Some(customer_details),
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>
multiple_capture_data: None,
redirect_response: None,
frm_message: None,
frm_metadata: None,
},
Some(payments::CustomerDetails {
customer_id: request.customer_id.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>
multiple_capture_data: None,
redirect_response: None,
frm_message: frm_response.ok(),
frm_metadata: None
},
None,
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>
multiple_capture_data: None,
redirect_response: None,
frm_message: None,
frm_metadata: None,
},
Some(customer_details),
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>
multiple_capture_data: None,
redirect_response: None,
frm_message: None,
frm_metadata: None,
},
Some(customer_details),
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ async fn get_tracker_for_sync<
multiple_capture_data,
redirect_response: None,
frm_message: frm_response.ok(),
frm_metadata: None,
},
None,
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>
multiple_capture_data: None,
redirect_response: None,
frm_message: None,
frm_metadata: request.frm_metadata.clone(),
},
Some(customer_details),
))
Expand Down
2 changes: 2 additions & 0 deletions crates/router/src/core/payments/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ where
connector_http_status_code: None,
external_latency: None,
apple_pay_flow,
frm_metadata: None,
};

Ok(router_data)
Expand Down Expand Up @@ -912,6 +913,7 @@ pub fn change_order_details_to_new_type(
product_name: order_details.product_name,
quantity: order_details.quantity,
amount: order_amount,
requires_shipping: order_details.requires_shipping,
}])
}

Expand Down
7 changes: 7 additions & 0 deletions crates/router/src/core/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ pub async fn construct_payout_router_data<'a, F>(
connector_http_status_code: None,
external_latency: None,
apple_pay_flow: None,
frm_metadata: None,
};

Ok(router_data)
Expand Down Expand Up @@ -329,6 +330,7 @@ pub async fn construct_refund_router_data<'a, F>(
connector_http_status_code: None,
external_latency: None,
apple_pay_flow: None,
frm_metadata: None
};

Ok(router_data)
Expand Down Expand Up @@ -557,6 +559,7 @@ pub async fn construct_accept_dispute_router_data<'a>(
connector_http_status_code: None,
external_latency: None,
apple_pay_flow: None,
frm_metadata: None,
};
Ok(router_data)
}
Expand Down Expand Up @@ -643,6 +646,7 @@ pub async fn construct_submit_evidence_router_data<'a>(
connector_http_status_code: None,
external_latency: None,
apple_pay_flow: None,
frm_metadata: None,
};
Ok(router_data)
}
Expand Down Expand Up @@ -734,6 +738,7 @@ pub async fn construct_upload_file_router_data<'a>(
connector_http_status_code: None,
external_latency: None,
apple_pay_flow: None,
frm_metadata: None
};
Ok(router_data)
}
Expand Down Expand Up @@ -823,6 +828,7 @@ pub async fn construct_defend_dispute_router_data<'a>(
connector_http_status_code: None,
external_latency: None,
apple_pay_flow: None,
frm_metadata: None
};
Ok(router_data)
}
Expand Down Expand Up @@ -905,6 +911,7 @@ pub async fn construct_retrieve_file_router_data<'a>(
connector_http_status_code: None,
external_latency: None,
apple_pay_flow: None,
frm_metadata: None
};
Ok(router_data)
}
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/core/webhooks/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ pub async fn construct_webhook_router_data<'a>(
connector_http_status_code: None,
external_latency: None,
apple_pay_flow: None,
frm_metadata: None,
};
Ok(router_data)
}
4 changes: 4 additions & 0 deletions crates/router/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ pub struct RouterData<Flow, Request, Response> {
pub external_latency: Option<u128>,
/// Contains apple pay flow type simplified or manual
pub apple_pay_flow: Option<storage_enums::ApplePayFlow>,

pub frm_metadata: Option<serde_json::Value>,
}

#[derive(Debug, Clone, serde::Deserialize)]
Expand Down Expand Up @@ -1119,6 +1121,7 @@ impl<F1, F2, T1, T2> From<(&RouterData<F1, T1, PaymentsResponseData>, T2)>
connector_http_status_code: data.connector_http_status_code,
external_latency: data.external_latency,
apple_pay_flow: data.apple_pay_flow.clone(),
frm_metadata: data.frm_metadata.clone(),
}
}
}
Expand Down Expand Up @@ -1174,6 +1177,7 @@ impl<F1, F2>
connector_http_status_code: data.connector_http_status_code,
external_latency: data.external_latency,
apple_pay_flow: None,
frm_metadata: None,
}
}
}
4 changes: 4 additions & 0 deletions crates/router/tests/connectors/payme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
product_name: "iphone 13".to_string(),
quantity: 1,
amount: 1000,
requires_shipping: false,
}]),
router_return_url: Some("https://hyperswitch.io".to_string()),
webhook_url: Some("https://hyperswitch.io".to_string()),
Expand Down Expand Up @@ -370,6 +371,7 @@ async fn should_fail_payment_for_incorrect_cvc() {
product_name: "iphone 13".to_string(),
quantity: 1,
amount: 100,
requires_shipping: false,
}]),
router_return_url: Some("https://hyperswitch.io".to_string()),
webhook_url: Some("https://hyperswitch.io".to_string()),
Expand Down Expand Up @@ -402,6 +404,7 @@ async fn should_fail_payment_for_invalid_exp_month() {
product_name: "iphone 13".to_string(),
quantity: 1,
amount: 100,
requires_shipping: false
}]),
router_return_url: Some("https://hyperswitch.io".to_string()),
webhook_url: Some("https://hyperswitch.io".to_string()),
Expand Down Expand Up @@ -434,6 +437,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() {
product_name: "iphone 13".to_string(),
quantity: 1,
amount: 100,
requires_shipping: false,
}]),
router_return_url: Some("https://hyperswitch.io".to_string()),
webhook_url: Some("https://hyperswitch.io".to_string()),
Expand Down
4 changes: 4 additions & 0 deletions crates/router/tests/connectors/zen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ async fn should_fail_payment_for_incorrect_card_number() {
product_name: "test".to_string(),
quantity: 1,
amount: 1000,
requires_shipping: false,
}]),
email: Some(Email::from_str("[email protected]").unwrap()),
webhook_url: Some("https://1635-116-74-253-164.ngrok-free.app".to_string()),
Expand Down Expand Up @@ -348,6 +349,7 @@ async fn should_fail_payment_for_incorrect_cvc() {
product_name: "test".to_string(),
quantity: 1,
amount: 1000,
requires_shipping: false,
}]),
email: Some(Email::from_str("[email protected]").unwrap()),
webhook_url: Some("https://1635-116-74-253-164.ngrok-free.app".to_string()),
Expand Down Expand Up @@ -383,6 +385,7 @@ async fn should_fail_payment_for_invalid_exp_month() {
product_name: "test".to_string(),
quantity: 1,
amount: 1000,
requires_shipping: false
}]),
email: Some(Email::from_str("[email protected]").unwrap()),
webhook_url: Some("https://1635-116-74-253-164.ngrok-free.app".to_string()),
Expand Down Expand Up @@ -418,6 +421,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() {
product_name: "test".to_string(),
quantity: 1,
amount: 1000,
requires_shipping: false,
}]),
email: Some(Email::from_str("[email protected]").unwrap()),
webhook_url: Some("https://1635-116-74-253-164.ngrok-free.app".to_string()),
Expand Down

0 comments on commit f760733

Please sign in to comment.