Skip to content

Commit

Permalink
Merge branch 'main' into nexixpay-card-mandates
Browse files Browse the repository at this point in the history
  • Loading branch information
deepanshu-iiitu authored Nov 19, 2024
2 parents 765e934 + 65bf75a commit 0394a63
Show file tree
Hide file tree
Showing 28 changed files with 274 additions and 188 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,32 @@ All notable changes to HyperSwitch will be documented here.

- - -

## 2024.11.19.0

### Features

- **connector:** [Novalnet] Add support for disputes ([#6560](https://github.com/juspay/hyperswitch/pull/6560)) ([`6881ce2`](https://github.com/juspay/hyperswitch/commit/6881ce2ed3d11006c33fef9863107f0d823ebddb))
- **payments:** [Payment links] add hide card nickname field config for secure payment links ([#6554](https://github.com/juspay/hyperswitch/pull/6554)) ([`0e026b7`](https://github.com/juspay/hyperswitch/commit/0e026b70b6502c4e82f3e8cccc5441deb472119e))

### Refactors

- **core:** Add profile_id for default_fallback api ([#6546](https://github.com/juspay/hyperswitch/pull/6546)) ([`053f810`](https://github.com/juspay/hyperswitch/commit/053f8109302a98e6b6d30d957b2af618ea73055f))
- **users:** Make `profile_id` in the JWT non-optional ([#6537](https://github.com/juspay/hyperswitch/pull/6537)) ([`d32397f`](https://github.com/juspay/hyperswitch/commit/d32397f060731f51a15634e221117a554b8b3721))

**Full Changelog:** [`2024.11.18.0...2024.11.19.0`](https://github.com/juspay/hyperswitch/compare/2024.11.18.0...2024.11.19.0)

- - -

## 2024.11.18.0

### Features

- **payments_v2:** Add finish redirection endpoint ([#6549](https://github.com/juspay/hyperswitch/pull/6549)) ([`0805a93`](https://github.com/juspay/hyperswitch/commit/0805a937b1bc12ac1dfb23922036733ed971a87a))

**Full Changelog:** [`2024.11.15.0...2024.11.18.0`](https://github.com/juspay/hyperswitch/compare/2024.11.15.0...2024.11.18.0)

- - -

## 2024.11.15.0

### Features
Expand Down
14 changes: 13 additions & 1 deletion api-reference-v2/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -11948,7 +11948,8 @@
"seller_name",
"sdk_layout",
"display_sdk_only",
"enabled_saved_payment_method"
"enabled_saved_payment_method",
"hide_card_nickname_field"
],
"properties": {
"theme": {
Expand All @@ -11975,6 +11976,10 @@
"type": "boolean",
"description": "Enable saved payment method option for payment link"
},
"hide_card_nickname_field": {
"type": "boolean",
"description": "Hide card nickname field option for payment link"
},
"allowed_domains": {
"type": "array",
"items": {
Expand Down Expand Up @@ -12039,6 +12044,13 @@
"example": true,
"nullable": true
},
"hide_card_nickname_field": {
"type": "boolean",
"description": "Hide card nickname field option for payment link",
"default": false,
"example": true,
"nullable": true
},
"transaction_details": {
"type": "array",
"items": {
Expand Down
14 changes: 13 additions & 1 deletion api-reference/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -15074,7 +15074,8 @@
"seller_name",
"sdk_layout",
"display_sdk_only",
"enabled_saved_payment_method"
"enabled_saved_payment_method",
"hide_card_nickname_field"
],
"properties": {
"theme": {
Expand All @@ -15101,6 +15102,10 @@
"type": "boolean",
"description": "Enable saved payment method option for payment link"
},
"hide_card_nickname_field": {
"type": "boolean",
"description": "Hide card nickname field option for payment link"
},
"allowed_domains": {
"type": "array",
"items": {
Expand Down Expand Up @@ -15165,6 +15170,13 @@
"example": true,
"nullable": true
},
"hide_card_nickname_field": {
"type": "boolean",
"description": "Hide card nickname field option for payment link",
"default": false,
"example": true,
"nullable": true
},
"transaction_details": {
"type": "array",
"items": {
Expand Down
5 changes: 5 additions & 0 deletions crates/api_models/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2692,6 +2692,9 @@ pub struct PaymentLinkConfigRequest {
/// Enable saved payment method option for payment link
#[schema(default = false, example = true)]
pub enabled_saved_payment_method: Option<bool>,
/// Hide card nickname field option for payment link
#[schema(default = false, example = true)]
pub hide_card_nickname_field: Option<bool>,
/// Dynamic details related to merchant to be rendered in payment link
pub transaction_details: Option<Vec<PaymentLinkTransactionDetails>>,
}
Expand Down Expand Up @@ -2735,6 +2738,8 @@ pub struct PaymentLinkConfig {
pub display_sdk_only: bool,
/// Enable saved payment method option for payment link
pub enabled_saved_payment_method: bool,
/// Hide card nickname field option for payment link
pub hide_card_nickname_field: bool,
/// A list of allowed domains (glob patterns) where this link can be embedded / opened from
pub allowed_domains: Option<HashSet<String>>,
/// Dynamic details related to merchant to be rendered in payment link
Expand Down
2 changes: 2 additions & 0 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6556,13 +6556,15 @@ pub struct PaymentLinkDetails {
pub merchant_description: Option<String>,
pub sdk_layout: String,
pub display_sdk_only: bool,
pub hide_card_nickname_field: bool,
pub locale: Option<String>,
pub transaction_details: Option<Vec<admin::PaymentLinkTransactionDetails>>,
}

#[derive(Debug, serde::Serialize, Clone)]
pub struct SecurePaymentLinkDetails {
pub enabled_saved_payment_method: bool,
pub hide_card_nickname_field: bool,
#[serde(flatten)]
pub payment_link_details: PaymentLinkDetails,
}
Expand Down
25 changes: 0 additions & 25 deletions crates/common_utils/src/consts.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Commonly used constants

use std::collections::HashSet;

/// Number of characters in a generated ID
pub const ID_LENGTH: usize = 20;

Expand Down Expand Up @@ -51,26 +49,12 @@ pub const SURCHARGE_PERCENTAGE_PRECISION_LENGTH: u8 = 2;
/// Header Key for application overhead of a request
pub const X_HS_LATENCY: &str = "x-hs-latency";

/// Default Payment Link Background color
pub const DEFAULT_BACKGROUND_COLOR: &str = "#212E46";

/// Default product Img Link
pub const DEFAULT_PRODUCT_IMG: &str =
"https://live.hyperswitch.io/payment-link-assets/cart_placeholder.png";

/// Default Merchant Logo Link
pub const DEFAULT_MERCHANT_LOGO: &str =
"https://live.hyperswitch.io/payment-link-assets/Merchant_placeholder.png";

/// Redirect url for Prophetpay
pub const PROPHETPAY_REDIRECT_URL: &str = "https://ccm-thirdparty.cps.golf/hp/tokenize/";

/// Variable which store the card token for Prophetpay
pub const PROPHETPAY_TOKEN: &str = "cctoken";

/// Default SDK Layout
pub const DEFAULT_SDK_LAYOUT: &str = "tabs";

/// Payment intent default client secret expiry (in seconds)
pub const DEFAULT_SESSION_EXPIRY: i64 = 15 * 60;

Expand All @@ -80,15 +64,6 @@ pub const DEFAULT_INTENT_FULFILLMENT_TIME: i64 = 15 * 60;
/// Payment order fulfillment time (in seconds)
pub const DEFAULT_ORDER_FULFILLMENT_TIME: i64 = 15 * 60;

/// Default bool for Display sdk only
pub const DEFAULT_DISPLAY_SDK_ONLY: bool = false;

/// Default bool to enable saved payment method
pub const DEFAULT_ENABLE_SAVED_PAYMENT_METHOD: bool = false;

/// Default allowed domains for payment links
pub const DEFAULT_ALLOWED_DOMAINS: Option<HashSet<String>> = None;

/// Default ttl for Extended card info in redis (in seconds)
pub const DEFAULT_TTL_FOR_EXTENDED_CARD_INFO: u16 = 15 * 60;

Expand Down
1 change: 1 addition & 0 deletions crates/diesel_models/src/business_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ pub struct PaymentLinkConfigRequest {
pub sdk_layout: Option<String>,
pub display_sdk_only: Option<bool>,
pub enabled_saved_payment_method: Option<bool>,
pub hide_card_nickname_field: Option<bool>,
}

common_utils::impl_to_sql_from_sql_json!(BusinessPaymentLinkConfig);
Expand Down
2 changes: 2 additions & 0 deletions crates/diesel_models/src/payment_intent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ pub struct PaymentLinkConfigRequestForPayments {
pub display_sdk_only: Option<bool>,
/// Enable saved payment method option for payment link
pub enabled_saved_payment_method: Option<bool>,
/// Hide card nickname field option for payment link
pub hide_card_nickname_field: Option<bool>,
/// Dynamic details related to merchant to be rendered in payment link
pub transaction_details: Option<Vec<PaymentLinkTransactionDetails>>,
}
Expand Down
7 changes: 2 additions & 5 deletions crates/diesel_models/src/query/user_role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl UserRole {
user_id: String,
org_id: id_type::OrganizationId,
merchant_id: id_type::MerchantId,
profile_id: Option<id_type::ProfileId>,
profile_id: id_type::ProfileId,
version: UserRoleVersion,
) -> StorageResult<Self> {
// Checking in user roles, for a user in token hierarchy, only one of the relation will be true, either org level, merchant level or profile level
Expand All @@ -103,7 +103,6 @@ impl UserRole {
.or(dsl::org_id.eq(org_id).and(
dsl::merchant_id
.eq(merchant_id)
//TODO: In case of None, profile_id = NULL its unexpected behaviour, after V1 profile id will not be option
.and(dsl::profile_id.eq(profile_id)),
));

Expand Down Expand Up @@ -137,7 +136,6 @@ impl UserRole {
.or(dsl::org_id.eq(org_id).and(
dsl::merchant_id
.eq(merchant_id)
//TODO: In case of None, profile_id = NULL its unexpected behaviour, after V1 profile id will not be option
.and(dsl::profile_id.eq(profile_id)),
));

Expand All @@ -160,7 +158,7 @@ impl UserRole {
user_id: String,
org_id: id_type::OrganizationId,
merchant_id: id_type::MerchantId,
profile_id: Option<id_type::ProfileId>,
profile_id: id_type::ProfileId,
version: UserRoleVersion,
) -> StorageResult<Self> {
// Checking in user roles, for a user in token hierarchy, only one of the relation will be true, either org level, merchant level or profile level
Expand All @@ -176,7 +174,6 @@ impl UserRole {
.or(dsl::org_id.eq(org_id).and(
dsl::merchant_id
.eq(merchant_id)
//TODO: In case of None, profile_id = NULL its unexpected behaviour, after V1 profile id will not be option
.and(dsl::profile_id.eq(profile_id)),
));

Expand Down
42 changes: 41 additions & 1 deletion crates/hyperswitch_connectors/src/connectors/novalnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use hyperswitch_interfaces::{
ConnectorValidation,
},
configs::Connectors,
errors,
disputes, errors,
events::connector_api_logs::ConnectorEvent,
types::{self, Response},
webhooks,
Expand Down Expand Up @@ -877,4 +877,44 @@ impl webhooks::IncomingWebhook for Novalnet {
.change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?;
Ok(Box::new(notif))
}

fn get_dispute_details(
&self,
request: &webhooks::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<disputes::DisputePayload, errors::ConnectorError> {
let notif: transformers::NovalnetWebhookNotificationResponse =
get_webhook_object_from_body(request.body)
.change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?;
let (amount, currency, reason, reason_code) = match notif.transaction {
novalnet::NovalnetWebhookTransactionData::CaptureTransactionData(data) => {
(data.amount, data.currency, None, None)
}
novalnet::NovalnetWebhookTransactionData::CancelTransactionData(data) => {
(data.amount, data.currency, None, None)
}

novalnet::NovalnetWebhookTransactionData::RefundsTransactionData(data) => {
(data.amount, data.currency, None, None)
}

novalnet::NovalnetWebhookTransactionData::SyncTransactionData(data) => {
(data.amount, data.currency, data.reason, data.reason_code)
}
};

let dispute_status =
novalnet::get_novalnet_dispute_status(notif.event.event_type).to_string();
Ok(disputes::DisputePayload {
amount: novalnet::option_to_result(amount)?.to_string(),
currency: novalnet::option_to_result(currency)?.to_string(),
dispute_stage: api_models::enums::DisputeStage::Dispute,
connector_dispute_id: notif.event.tid.to_string(),
connector_reason: reason,
connector_reason_code: reason_code,
challenge_required_by: None,
connector_status: dispute_status,
created_at: None,
updated_at: None,
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,8 @@ pub enum WebhookEventType {
TransactionCapture,
TransactionCancel,
TransactionRefund,
Chargeback,
Credit,
}

#[derive(Serialize, Deserialize, Debug)]
Expand Down Expand Up @@ -1356,9 +1358,30 @@ pub fn get_incoming_webhook_event(
}
_ => IncomingWebhookEvent::RefundFailure,
},
WebhookEventType::Chargeback => IncomingWebhookEvent::DisputeOpened,
WebhookEventType::Credit => IncomingWebhookEvent::DisputeWon,
}
}

pub fn reverse_string(s: &str) -> String {
s.chars().rev().collect()
}

#[derive(Display, Debug, Serialize, Deserialize)]
pub enum WebhookDisputeStatus {
DisputeOpened,
DisputeWon,
Unknown,
}

pub fn get_novalnet_dispute_status(status: WebhookEventType) -> WebhookDisputeStatus {
match status {
WebhookEventType::Chargeback => WebhookDisputeStatus::DisputeOpened,
WebhookEventType::Credit => WebhookDisputeStatus::DisputeWon,
_ => WebhookDisputeStatus::Unknown,
}
}

pub fn option_to_result<T>(opt: Option<T>) -> Result<T, errors::ConnectorError> {
opt.ok_or(errors::ConnectorError::WebhookBodyDecodingFailed)
}
3 changes: 3 additions & 0 deletions crates/hyperswitch_domain_models/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>
sdk_layout: item.sdk_layout,
display_sdk_only: item.display_sdk_only,
enabled_saved_payment_method: item.enabled_saved_payment_method,
hide_card_nickname_field: item.hide_card_nickname_field,
transaction_details: item.transaction_details.map(|transaction_details| {
transaction_details
.into_iter()
Expand All @@ -210,6 +211,7 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>
sdk_layout,
display_sdk_only,
enabled_saved_payment_method,
hide_card_nickname_field,
transaction_details,
} = self;
api_models::admin::PaymentLinkConfigRequest {
Expand All @@ -219,6 +221,7 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>
sdk_layout,
display_sdk_only,
enabled_saved_payment_method,
hide_card_nickname_field,
transaction_details: transaction_details.map(|transaction_details| {
transaction_details
.into_iter()
Expand Down
Loading

0 comments on commit 0394a63

Please sign in to comment.