Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(connector): [Iatapay] refactor authorize flow and fix payment status mapping #2409

Merged
merged 16 commits into from
Jan 25, 2024
Merged
1 change: 1 addition & 0 deletions crates/router/src/connector/iatapay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ impl api::IncomingWebhook for Iatapay {
| iatapay::IatapayPaymentStatus::Tobeinvestigated
| iatapay::IatapayPaymentStatus::Blocked
| iatapay::IatapayPaymentStatus::Locked
| iatapay::IatapayPaymentStatus::Cancel
| iatapay::IatapayPaymentStatus::UnexpectedSettled => {
Ok(api::IncomingWebhookEvent::EventNotSupported)
}
Expand Down
22 changes: 12 additions & 10 deletions crates/router/src/connector/iatapay/transformers.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::collections::HashMap;

use api_models::enums::PaymentMethod;
use masking::{Secret, SwitchStrategy};
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -83,11 +82,7 @@ pub struct IatapayPaymentsRequest {
impl TryFrom<&types::PaymentsAuthorizeRouterData> for IatapayPaymentsRequest {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result<Self, Self::Error> {
let payment_method = item.payment_method;
let country = match payment_method {
PaymentMethod::Upi => "IN".to_string(),
_ => item.get_billing_country()?.to_string(),
};
let country = item.get_billing_country()?.to_string();
let return_url = item.get_return_url()?;
let payer_info = match item.request.payment_method_data.clone() {
api::PaymentMethodData::Upi(upi_data) => upi_data.vpa_id.map(|id| PayerInfo {
Expand Down Expand Up @@ -157,6 +152,7 @@ pub enum IatapayPaymentStatus {
Cleared,
Failed,
Locked,
Cancel,
#[serde(rename = "UNEXPECTED SETTLED")]
UnexpectedSettled,
#[serde(other)]
Expand All @@ -166,11 +162,17 @@ pub enum IatapayPaymentStatus {
impl From<IatapayPaymentStatus> for enums::AttemptStatus {
fn from(item: IatapayPaymentStatus) -> Self {
match item {
IatapayPaymentStatus::Authorized | IatapayPaymentStatus::Settled => Self::Charged,
IatapayPaymentStatus::Failed | IatapayPaymentStatus::UnexpectedSettled => Self::Failure,
IatapayPaymentStatus::Authorized => Self::Authorized,
IatapayPaymentStatus::Settled
| IatapayPaymentStatus::Cleared
| IatapayPaymentStatus::Tobeinvestigated
| IatapayPaymentStatus::Blocked => Self::Charged,
IatapayPaymentStatus::Failed
| IatapayPaymentStatus::UnexpectedSettled
| IatapayPaymentStatus::Unknown => Self::Failure,
prasunna09 marked this conversation as resolved.
Show resolved Hide resolved
IatapayPaymentStatus::Created => Self::AuthenticationPending,
IatapayPaymentStatus::Initiated => Self::Pending,
_ => Self::Voided,
IatapayPaymentStatus::Initiated | IatapayPaymentStatus::Locked => Self::Pending,
prasunna09 marked this conversation as resolved.
Show resolved Hide resolved
IatapayPaymentStatus::Cancel => Self::Voided,
prasunna09 marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down
Loading