1
1
use api_models:: admin as admin_types;
2
- use common_utils:: ext_traits:: AsyncExt ;
3
2
use error_stack:: { IntoReport , ResultExt } ;
3
+ use masking:: PeekInterface ;
4
4
5
5
use super :: errors:: { self , RouterResult , StorageErrorExt } ;
6
6
use crate :: {
@@ -43,6 +43,11 @@ pub async fn intiate_payment_link_flow(
43
43
. await
44
44
. to_not_found_response ( errors:: ApiErrorResponse :: PaymentNotFound ) ?;
45
45
46
+ let payment_link_id = payment_intent
47
+ . payment_link_id
48
+ . get_required_value ( "payment_link_id" )
49
+ . change_context ( errors:: ApiErrorResponse :: PaymentLinkNotFound ) ?;
50
+
46
51
helpers:: validate_payment_status_against_not_allowed_statuses (
47
52
& payment_intent. status ,
48
53
& [
@@ -55,20 +60,10 @@ pub async fn intiate_payment_link_flow(
55
60
"create payment link" ,
56
61
) ?;
57
62
58
- let fulfillment_time = payment_intent
59
- . payment_link_id
60
- . as_ref ( )
61
- . async_and_then ( |pli| async move {
62
- db. find_payment_link_by_payment_link_id ( pli)
63
- . await
64
- . ok ( ) ?
65
- . fulfilment_time
66
- . ok_or ( errors:: ApiErrorResponse :: PaymentNotFound )
67
- . ok ( )
68
- } )
63
+ let payment_link = db
64
+ . find_payment_link_by_payment_link_id ( & payment_link_id)
69
65
. await
70
- . get_required_value ( "fulfillment_time" )
71
- . change_context ( errors:: ApiErrorResponse :: PaymentNotFound ) ?;
66
+ . to_not_found_response ( errors:: ApiErrorResponse :: PaymentLinkNotFound ) ?;
72
67
73
68
let payment_link_config = merchant_account
74
69
. payment_link_config
@@ -108,10 +103,15 @@ pub async fn intiate_payment_link_flow(
108
103
amount : payment_intent. amount ,
109
104
currency,
110
105
payment_id : payment_intent. payment_id ,
111
- merchant_name : merchant_account. merchant_name ,
106
+ merchant_name : payment_link. custom_merchant_name . unwrap_or (
107
+ merchant_account
108
+ . merchant_name
109
+ . map ( |merchant_name| merchant_name. into_inner ( ) . peek ( ) . to_owned ( ) )
110
+ . unwrap_or_default ( ) ,
111
+ ) ,
112
112
order_details,
113
113
return_url,
114
- expiry : fulfillment_time ,
114
+ expiry : payment_link . fulfilment_time ,
115
115
pub_key,
116
116
client_secret,
117
117
merchant_logo : payment_link_config
0 commit comments