refactor: make NextAction as enum (#1234)

This commit is contained in:
Sangamesh Kulkarni
2023-05-24 10:46:00 +05:30
committed by GitHub
parent 48e537568d
commit a359b76d09
8 changed files with 81 additions and 53 deletions

View File

@ -1067,21 +1067,20 @@ pub enum NextActionType {
TriggerApi,
DisplayBankTransferInformation,
}
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, ToSchema)]
pub struct NextAction {
/// Specifying the action type to be performed next
#[serde(rename = "type")]
pub next_action_type: NextActionType,
//TODO: Make an enum having redirect_to_url and bank_transfer_steps_and_charges_details and use here
#[serde(tag = "type", rename_all = "snake_case")]
pub enum NextActionData {
/// Contains the url for redirection flow
#[schema(example = "https://router.juspay.io/redirect/fakushdfjlksdfasklhdfj")]
pub redirect_to_url: Option<String>,
RedirectToUrl { redirect_to_url: String },
/// Informs the next steps for bank transfer and also contains the charges details (ex: amount received, amount charged etc)
pub bank_transfer_steps_and_charges_details: Option<NextStepsRequirements>,
DisplayBankTransferInformation {
bank_transfer_steps_and_charges_details: BankTransferNextStepsData,
},
}
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct NextStepsRequirements {
pub struct BankTransferNextStepsData {
#[serde(flatten)]
pub bank_transfer_instructions: BankTransferInstructions,
pub receiver: ReceiverDetails,
@ -1268,7 +1267,7 @@ pub struct PaymentsResponse {
pub statement_descriptor_suffix: Option<String>,
/// Additional information required for redirection
pub next_action: Option<NextAction>,
pub next_action: Option<NextActionData>,
/// If the payment was cancelled the reason provided here
pub cancellation_reason: Option<String>,