mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 04:04:43 +08:00
refactor(connector): added amount framework to paypal, payouts and routing (#4865)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: Hrithikesh <61539176+hrithikesh026@users.noreply.github.com> Co-authored-by: Narayan Bhat <narayan.bhat@juspay.in>
This commit is contained in:
@ -19,7 +19,7 @@ pub struct PaymentMethodInput {
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct PaymentInput {
|
||||
pub amount: i64,
|
||||
pub amount: common_utils::types::MinorUnit,
|
||||
pub currency: enums::Currency,
|
||||
pub authentication_type: Option<enums::AuthenticationType>,
|
||||
pub card_bin: Option<String>,
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
pub mod types;
|
||||
|
||||
use common_utils::types::MinorUnit;
|
||||
|
||||
use crate::{
|
||||
backend::{self, inputs, EuclidBackend},
|
||||
frontend::ast,
|
||||
@ -14,7 +16,7 @@ where
|
||||
O: Clone,
|
||||
{
|
||||
fn eval_number_comparison_array(
|
||||
num: i64,
|
||||
num: MinorUnit,
|
||||
array: &[ast::NumberComparison],
|
||||
) -> Result<bool, types::InterpreterError> {
|
||||
for comparison in array {
|
||||
|
||||
@ -105,6 +105,7 @@ where
|
||||
#[cfg(all(test, feature = "ast_parser"))]
|
||||
mod test {
|
||||
#![allow(clippy::expect_used)]
|
||||
use common_utils::types::MinorUnit;
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use super::*;
|
||||
@ -130,7 +131,7 @@ mod test {
|
||||
let inp = inputs::BackendInput {
|
||||
metadata: None,
|
||||
payment: inputs::PaymentInput {
|
||||
amount: 32,
|
||||
amount: MinorUnit::new(32),
|
||||
card_bin: None,
|
||||
currency: enums::Currency::USD,
|
||||
authentication_type: Some(enums::AuthenticationType::NoThreeDs),
|
||||
@ -170,7 +171,7 @@ mod test {
|
||||
let inp = inputs::BackendInput {
|
||||
metadata: None,
|
||||
payment: inputs::PaymentInput {
|
||||
amount: 32,
|
||||
amount: MinorUnit::new(32),
|
||||
currency: enums::Currency::USD,
|
||||
card_bin: Some("123456".to_string()),
|
||||
authentication_type: Some(enums::AuthenticationType::NoThreeDs),
|
||||
@ -211,7 +212,7 @@ mod test {
|
||||
let inp = inputs::BackendInput {
|
||||
metadata: None,
|
||||
payment: inputs::PaymentInput {
|
||||
amount: 32,
|
||||
amount: MinorUnit::new(32),
|
||||
currency: enums::Currency::USD,
|
||||
card_bin: Some("123456".to_string()),
|
||||
authentication_type: Some(enums::AuthenticationType::NoThreeDs),
|
||||
@ -252,7 +253,7 @@ mod test {
|
||||
let inp = inputs::BackendInput {
|
||||
metadata: None,
|
||||
payment: inputs::PaymentInput {
|
||||
amount: 32,
|
||||
amount: MinorUnit::new(32),
|
||||
currency: enums::Currency::USD,
|
||||
card_bin: Some("123456".to_string()),
|
||||
authentication_type: Some(enums::AuthenticationType::NoThreeDs),
|
||||
@ -293,7 +294,7 @@ mod test {
|
||||
let inp = inputs::BackendInput {
|
||||
metadata: None,
|
||||
payment: inputs::PaymentInput {
|
||||
amount: 32,
|
||||
amount: MinorUnit::new(32),
|
||||
currency: enums::Currency::USD,
|
||||
card_bin: Some("123456".to_string()),
|
||||
authentication_type: Some(enums::AuthenticationType::NoThreeDs),
|
||||
@ -334,7 +335,7 @@ mod test {
|
||||
let inp = inputs::BackendInput {
|
||||
metadata: None,
|
||||
payment: inputs::PaymentInput {
|
||||
amount: 32,
|
||||
amount: MinorUnit::new(32),
|
||||
currency: enums::Currency::USD,
|
||||
card_bin: None,
|
||||
authentication_type: Some(enums::AuthenticationType::NoThreeDs),
|
||||
@ -375,7 +376,7 @@ mod test {
|
||||
let inp = inputs::BackendInput {
|
||||
metadata: None,
|
||||
payment: inputs::PaymentInput {
|
||||
amount: 32,
|
||||
amount: MinorUnit::new(32),
|
||||
currency: enums::Currency::USD,
|
||||
card_bin: None,
|
||||
authentication_type: Some(enums::AuthenticationType::NoThreeDs),
|
||||
@ -416,7 +417,7 @@ mod test {
|
||||
let inp = inputs::BackendInput {
|
||||
metadata: None,
|
||||
payment: inputs::PaymentInput {
|
||||
amount: 32,
|
||||
amount: MinorUnit::new(32),
|
||||
currency: enums::Currency::USD,
|
||||
card_bin: None,
|
||||
authentication_type: Some(enums::AuthenticationType::NoThreeDs),
|
||||
@ -459,7 +460,7 @@ mod test {
|
||||
let inp = inputs::BackendInput {
|
||||
metadata: Some(meta_map),
|
||||
payment: inputs::PaymentInput {
|
||||
amount: 32,
|
||||
amount: MinorUnit::new(32),
|
||||
card_bin: None,
|
||||
currency: enums::Currency::USD,
|
||||
authentication_type: Some(enums::AuthenticationType::NoThreeDs),
|
||||
@ -500,7 +501,7 @@ mod test {
|
||||
let inp_greater = inputs::BackendInput {
|
||||
metadata: None,
|
||||
payment: inputs::PaymentInput {
|
||||
amount: 150,
|
||||
amount: MinorUnit::new(150),
|
||||
card_bin: None,
|
||||
currency: enums::Currency::USD,
|
||||
authentication_type: Some(enums::AuthenticationType::NoThreeDs),
|
||||
@ -522,7 +523,7 @@ mod test {
|
||||
},
|
||||
};
|
||||
let mut inp_equal = inp_greater.clone();
|
||||
inp_equal.payment.amount = 123;
|
||||
inp_equal.payment.amount = MinorUnit::new(123);
|
||||
let backend = VirInterpreterBackend::<DummyOutput>::with_program(program).expect("Program");
|
||||
let result_greater = backend.execute(inp_greater).expect("Execution");
|
||||
let result_equal = backend.execute(inp_equal).expect("Execution");
|
||||
@ -550,7 +551,7 @@ mod test {
|
||||
let inp_lower = inputs::BackendInput {
|
||||
metadata: None,
|
||||
payment: inputs::PaymentInput {
|
||||
amount: 120,
|
||||
amount: MinorUnit::new(120),
|
||||
card_bin: None,
|
||||
currency: enums::Currency::USD,
|
||||
authentication_type: Some(enums::AuthenticationType::NoThreeDs),
|
||||
@ -572,7 +573,7 @@ mod test {
|
||||
},
|
||||
};
|
||||
let mut inp_equal = inp_lower.clone();
|
||||
inp_equal.payment.amount = 123;
|
||||
inp_equal.payment.amount = MinorUnit::new(123);
|
||||
let backend = VirInterpreterBackend::<DummyOutput>::with_program(program).expect("Program");
|
||||
let result_equal = backend.execute(inp_equal).expect("Execution");
|
||||
let result_lower = backend.execute(inp_lower).expect("Execution");
|
||||
|
||||
Reference in New Issue
Block a user