mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 18:17:13 +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:
		| @ -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) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Sahkal Poddar
					Sahkal Poddar