|
1 | 1 | use cards::CardNumber;
|
2 | 2 | use common_utils::{
|
| 3 | + consts::default_payouts_list_limit, |
3 | 4 | crypto,
|
4 | 5 | pii::{self, Email},
|
5 | 6 | };
|
6 | 7 | use masking::Secret;
|
7 | 8 | use serde::{Deserialize, Serialize};
|
| 9 | +use time::PrimitiveDateTime; |
8 | 10 | use utoipa::ToSchema;
|
9 | 11 |
|
10 | 12 | use crate::{enums as api_enums, payments};
|
@@ -393,6 +395,54 @@ pub struct PayoutCreateResponse {
|
393 | 395 |
|
394 | 396 | /// The business profile that is associated with this payment
|
395 | 397 | pub profile_id: String,
|
| 398 | + |
| 399 | + /// Time when the payout was created |
| 400 | + #[schema(example = "2022-09-10T10:11:12Z")] |
| 401 | + #[serde(with = "common_utils::custom_serde::iso8601::option")] |
| 402 | + pub created: Option<PrimitiveDateTime>, |
| 403 | + |
| 404 | + /// List of attempts |
| 405 | + #[schema(value_type = Option<Vec<PayoutAttemptResponse>>)] |
| 406 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 407 | + pub attempts: Option<Vec<PayoutAttemptResponse>>, |
| 408 | +} |
| 409 | + |
| 410 | +#[derive( |
| 411 | + Default, Debug, serde::Serialize, Clone, PartialEq, ToSchema, router_derive::PolymorphicSchema, |
| 412 | +)] |
| 413 | +pub struct PayoutAttemptResponse { |
| 414 | + /// Unique identifier for the attempt |
| 415 | + pub attempt_id: String, |
| 416 | + /// The status of the attempt |
| 417 | + #[schema(value_type = PayoutStatus, example = "failed")] |
| 418 | + pub status: api_enums::PayoutStatus, |
| 419 | + /// The payout attempt amount. Amount for the payout in lowest denomination of the currency. (i.e) in cents for USD denomination, in paisa for INR denomination etc., |
| 420 | + pub amount: i64, |
| 421 | + /// The currency of the amount of the payout attempt |
| 422 | + #[schema(value_type = Option<Currency>, example = "USD")] |
| 423 | + pub currency: Option<api_enums::Currency>, |
| 424 | + /// The connector used for the payout |
| 425 | + pub connector: Option<String>, |
| 426 | + /// Connector's error code in case of failures |
| 427 | + pub error_code: Option<String>, |
| 428 | + /// Connector's error message in case of failures |
| 429 | + pub error_message: Option<String>, |
| 430 | + /// The payout method that was used |
| 431 | + #[schema(value_type = Option<PayoutType>, example = "bank")] |
| 432 | + pub payment_method: Option<api_enums::PayoutType>, |
| 433 | + /// Payment Method Type |
| 434 | + #[schema(value_type = Option<PaymentMethodType>, example = "bacs")] |
| 435 | + pub payout_method_type: Option<api_enums::PaymentMethodType>, |
| 436 | + /// A unique identifier for a payout provided by the connector |
| 437 | + pub connector_transaction_id: Option<String>, |
| 438 | + /// If the payout was cancelled the reason provided here |
| 439 | + pub cancellation_reason: Option<String>, |
| 440 | + /// Provide a reference to a stored payout method |
| 441 | + pub payout_token: Option<String>, |
| 442 | + /// error code unified across the connectors is received here if there was an error while calling connector |
| 443 | + pub unified_code: Option<String>, |
| 444 | + /// error message unified across the connectors is received here if there was an error while calling connector |
| 445 | + pub unified_message: Option<String>, |
396 | 446 | }
|
397 | 447 |
|
398 | 448 | #[derive(Default, Debug, Clone, Deserialize, ToSchema)]
|
@@ -430,3 +480,96 @@ pub struct PayoutActionRequest {
|
430 | 480 | )]
|
431 | 481 | pub payout_id: String,
|
432 | 482 | }
|
| 483 | + |
| 484 | +#[derive(Clone, Debug, serde::Deserialize, ToSchema, serde::Serialize)] |
| 485 | +#[serde(deny_unknown_fields)] |
| 486 | +pub struct PayoutListConstraints { |
| 487 | + /// The identifier for customer |
| 488 | + #[schema(example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")] |
| 489 | + pub customer_id: Option<String>, |
| 490 | + |
| 491 | + /// A cursor for use in pagination, fetch the next list after some object |
| 492 | + #[schema(example = "pay_fafa124123")] |
| 493 | + pub starting_after: Option<String>, |
| 494 | + |
| 495 | + /// A cursor for use in pagination, fetch the previous list before some object |
| 496 | + #[schema(example = "pay_fafa124123")] |
| 497 | + pub ending_before: Option<String>, |
| 498 | + |
| 499 | + /// limit on the number of objects to return |
| 500 | + #[schema(default = 10, maximum = 100)] |
| 501 | + #[serde(default = "default_payouts_list_limit")] |
| 502 | + pub limit: u32, |
| 503 | + |
| 504 | + /// The time at which payout is created |
| 505 | + #[schema(example = "2022-09-10T10:11:12Z")] |
| 506 | + #[serde(default, with = "common_utils::custom_serde::iso8601::option")] |
| 507 | + pub created: Option<PrimitiveDateTime>, |
| 508 | + |
| 509 | + /// The time range for which objects are needed. TimeRange has two fields start_time and end_time from which objects can be filtered as per required scenarios (created_at, time less than, greater than etc). |
| 510 | + #[serde(flatten)] |
| 511 | + #[schema(value_type = Option<TimeRange>)] |
| 512 | + pub time_range: Option<payments::TimeRange>, |
| 513 | +} |
| 514 | + |
| 515 | +#[derive(Clone, Debug, serde::Deserialize, ToSchema, serde::Serialize)] |
| 516 | +#[serde(deny_unknown_fields)] |
| 517 | +pub struct PayoutListFilterConstraints { |
| 518 | + /// The identifier for payout |
| 519 | + #[schema( |
| 520 | + value_type = Option<String>, |
| 521 | + min_length = 30, |
| 522 | + max_length = 30, |
| 523 | + example = "payout_mbabizu24mvu3mela5njyhpit4" |
| 524 | +)] |
| 525 | + pub payout_id: Option<String>, |
| 526 | + /// The identifier for business profile |
| 527 | + pub profile_id: Option<String>, |
| 528 | + /// The identifier for customer |
| 529 | + #[schema(example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")] |
| 530 | + pub customer_id: Option<String>, |
| 531 | + /// The limit on the number of objects. The default limit is 10 and max limit is 20 |
| 532 | + #[serde(default = "default_payouts_list_limit")] |
| 533 | + pub limit: u32, |
| 534 | + /// The starting point within a list of objects |
| 535 | + pub offset: Option<u32>, |
| 536 | + /// The time range for which objects are needed. TimeRange has two fields start_time and end_time from which objects can be filtered as per required scenarios (created_at, time less than, greater than etc). |
| 537 | + #[serde(flatten)] |
| 538 | + #[schema(value_type = Option<TimeRange>)] |
| 539 | + pub time_range: Option<payments::TimeRange>, |
| 540 | + /// The list of connectors to filter payouts list |
| 541 | + #[schema(value_type = Option<Vec<PayoutConnectors>>, max_length = 255, example = json!(["wise", "adyen"]))] |
| 542 | + pub connector: Option<Vec<api_enums::PayoutConnectors>>, |
| 543 | + /// The list of currencies to filter payouts list |
| 544 | + #[schema(value_type = Currency, example = "USD")] |
| 545 | + pub currency: Option<Vec<api_enums::Currency>>, |
| 546 | + /// The list of payout status to filter payouts list |
| 547 | + #[schema(value_type = Option<Vec<PayoutStatus>>, example = json!(["pending", "failed"]))] |
| 548 | + pub status: Option<Vec<api_enums::PayoutStatus>>, |
| 549 | + /// The list of payout methods to filter payouts list |
| 550 | + #[schema(value_type = Option<Vec<PayoutType>>, example = json!(["bank", "card"]))] |
| 551 | + pub payout_method: Option<Vec<common_enums::PayoutType>>, |
| 552 | + /// Type of recipient |
| 553 | + #[schema(value_type = PayoutEntityType, example = "Individual")] |
| 554 | + pub entity_type: Option<common_enums::PayoutEntityType>, |
| 555 | +} |
| 556 | + |
| 557 | +#[derive(Clone, Debug, serde::Serialize, ToSchema)] |
| 558 | +pub struct PayoutListResponse { |
| 559 | + /// The number of payouts included in the list |
| 560 | + pub size: usize, |
| 561 | + // The list of payouts response objects |
| 562 | + pub data: Vec<PayoutCreateResponse>, |
| 563 | +} |
| 564 | + |
| 565 | +#[derive(Clone, Debug, serde::Serialize)] |
| 566 | +pub struct PayoutListFilters { |
| 567 | + /// The list of available connector filters |
| 568 | + pub connector: Vec<api_enums::PayoutConnectors>, |
| 569 | + /// The list of available currency filters |
| 570 | + pub currency: Vec<common_enums::Currency>, |
| 571 | + /// The list of available payment status filters |
| 572 | + pub status: Vec<common_enums::PayoutStatus>, |
| 573 | + /// The list of available payment method filters |
| 574 | + pub payout_method: Vec<common_enums::PayoutType>, |
| 575 | +} |
0 commit comments