mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
feat(router): added merchant custom name support for payment link (#2685)
Co-authored-by: Sahkal Poddar <sahkal.poddar@juspay.in> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@ -3100,6 +3100,8 @@ pub struct PaymentLinkObject {
|
||||
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
|
||||
pub link_expiry: Option<PrimitiveDateTime>,
|
||||
pub merchant_custom_domain_name: Option<String>,
|
||||
/// Custom merchant name for payment link
|
||||
pub custom_merchant_name: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, serde::Deserialize, Clone, ToSchema, serde::Serialize)]
|
||||
@ -3143,11 +3145,11 @@ pub struct PaymentLinkDetails {
|
||||
pub pub_key: String,
|
||||
pub client_secret: String,
|
||||
pub payment_id: String,
|
||||
#[serde(with = "common_utils::custom_serde::iso8601")]
|
||||
pub expiry: PrimitiveDateTime,
|
||||
#[serde(with = "common_utils::custom_serde::iso8601::option")]
|
||||
pub expiry: Option<PrimitiveDateTime>,
|
||||
pub merchant_logo: String,
|
||||
pub return_url: String,
|
||||
pub merchant_name: crypto::OptionalEncryptableName,
|
||||
pub merchant_name: String,
|
||||
pub order_details: Vec<pii::SecretSerdeValue>,
|
||||
pub max_items_visible_after_collapse: i8,
|
||||
}
|
||||
|
||||
@ -20,8 +20,8 @@ pub struct PaymentLink {
|
||||
pub last_modified_at: PrimitiveDateTime,
|
||||
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
|
||||
pub fulfilment_time: Option<PrimitiveDateTime>,
|
||||
pub custom_merchant_name: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
@ -47,4 +47,5 @@ pub struct PaymentLinkNew {
|
||||
pub last_modified_at: Option<PrimitiveDateTime>,
|
||||
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
|
||||
pub fulfilment_time: Option<PrimitiveDateTime>,
|
||||
pub custom_merchant_name: Option<String>,
|
||||
}
|
||||
|
||||
@ -691,6 +691,8 @@ diesel::table! {
|
||||
created_at -> Timestamp,
|
||||
last_modified_at -> Timestamp,
|
||||
fulfilment_time -> Nullable<Timestamp>,
|
||||
#[max_length = 64]
|
||||
custom_merchant_name -> Nullable<Varchar>,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use api_models::admin as admin_types;
|
||||
use common_utils::ext_traits::AsyncExt;
|
||||
use error_stack::{IntoReport, ResultExt};
|
||||
use masking::PeekInterface;
|
||||
|
||||
use super::errors::{self, RouterResult, StorageErrorExt};
|
||||
use crate::{
|
||||
@ -43,6 +43,11 @@ pub async fn intiate_payment_link_flow(
|
||||
.await
|
||||
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
|
||||
|
||||
let payment_link_id = payment_intent
|
||||
.payment_link_id
|
||||
.get_required_value("payment_link_id")
|
||||
.change_context(errors::ApiErrorResponse::PaymentLinkNotFound)?;
|
||||
|
||||
helpers::validate_payment_status_against_not_allowed_statuses(
|
||||
&payment_intent.status,
|
||||
&[
|
||||
@ -55,20 +60,10 @@ pub async fn intiate_payment_link_flow(
|
||||
"create payment link",
|
||||
)?;
|
||||
|
||||
let fulfillment_time = payment_intent
|
||||
.payment_link_id
|
||||
.as_ref()
|
||||
.async_and_then(|pli| async move {
|
||||
db.find_payment_link_by_payment_link_id(pli)
|
||||
.await
|
||||
.ok()?
|
||||
.fulfilment_time
|
||||
.ok_or(errors::ApiErrorResponse::PaymentNotFound)
|
||||
.ok()
|
||||
})
|
||||
let payment_link = db
|
||||
.find_payment_link_by_payment_link_id(&payment_link_id)
|
||||
.await
|
||||
.get_required_value("fulfillment_time")
|
||||
.change_context(errors::ApiErrorResponse::PaymentNotFound)?;
|
||||
.to_not_found_response(errors::ApiErrorResponse::PaymentLinkNotFound)?;
|
||||
|
||||
let payment_link_config = merchant_account
|
||||
.payment_link_config
|
||||
@ -108,10 +103,15 @@ pub async fn intiate_payment_link_flow(
|
||||
amount: payment_intent.amount,
|
||||
currency,
|
||||
payment_id: payment_intent.payment_id,
|
||||
merchant_name: merchant_account.merchant_name,
|
||||
merchant_name: payment_link.custom_merchant_name.unwrap_or(
|
||||
merchant_account
|
||||
.merchant_name
|
||||
.map(|merchant_name| merchant_name.into_inner().peek().to_owned())
|
||||
.unwrap_or_default(),
|
||||
),
|
||||
order_details,
|
||||
return_url,
|
||||
expiry: fulfillment_time,
|
||||
expiry: payment_link.fulfilment_time,
|
||||
pub_key,
|
||||
client_secret,
|
||||
merchant_logo: payment_link_config
|
||||
|
||||
@ -813,6 +813,7 @@ async fn create_payment_link(
|
||||
created_at,
|
||||
last_modified_at,
|
||||
fulfilment_time: payment_link_object.link_expiry,
|
||||
custom_merchant_name: payment_link_object.custom_merchant_name,
|
||||
};
|
||||
let payment_link_db = db
|
||||
.insert_payment_link(payment_link_req)
|
||||
|
||||
@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE payment_link DROP COLUMN custom_merchant_name;
|
||||
@ -0,0 +1,2 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE payment_link ADD COLUMN custom_merchant_name VARCHAR(64);
|
||||
@ -7866,6 +7866,11 @@
|
||||
"merchant_custom_domain_name": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"custom_merchant_name": {
|
||||
"type": "string",
|
||||
"description": "Custom merchant name for payment link",
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user