Skip to content

Commit afb2463

Browse files
SamraatBansalhyperswitch-bot[bot]
authored andcommitted
feat(core): add merchant order reference id (#5197)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
1 parent ba24d8b commit afb2463

File tree

22 files changed

+135
-1
lines changed

22 files changed

+135
-1
lines changed

api-reference/openapi_spec.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15052,6 +15052,13 @@
1505215052
}
1505315053
],
1505415054
"nullable": true
15055+
},
15056+
"merchant_order_reference_id": {
15057+
"type": "string",
15058+
"description": "Merchant's identifier for the payment/invoice. This will be sent to the connector\nif the connector provides support to accept multiple reference ids.\nIn case the connector supports only one reference id, Hyperswitch's Payment ID will be sent as reference.",
15059+
"example": "Custom_Order_id_123",
15060+
"nullable": true,
15061+
"maxLength": 255
1505515062
}
1505615063
}
1505715064
},
@@ -15403,6 +15410,13 @@
1540315410
}
1540415411
],
1540515412
"nullable": true
15413+
},
15414+
"merchant_order_reference_id": {
15415+
"type": "string",
15416+
"description": "Merchant's identifier for the payment/invoice. This will be sent to the connector\nif the connector provides support to accept multiple reference ids.\nIn case the connector supports only one reference id, Hyperswitch's Payment ID will be sent as reference.",
15417+
"example": "Custom_Order_id_123",
15418+
"nullable": true,
15419+
"maxLength": 255
1540615420
}
1540715421
}
1540815422
},
@@ -15922,6 +15936,13 @@
1592215936
"type": "object",
1592315937
"description": "You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. FRM Metadata is useful for storing additional, structured information on an object related to FRM.",
1592415938
"nullable": true
15939+
},
15940+
"merchant_order_reference_id": {
15941+
"type": "string",
15942+
"description": "Merchant's identifier for the payment/invoice. This will be sent to the connector\nif the connector provides support to accept multiple reference ids.\nIn case the connector supports only one reference id, Hyperswitch's Payment ID will be sent as reference.",
15943+
"example": "Custom_Order_id_123",
15944+
"nullable": true,
15945+
"maxLength": 255
1592515946
}
1592615947
}
1592715948
},
@@ -16448,6 +16469,13 @@
1644816469
}
1644916470
],
1645016471
"nullable": true
16472+
},
16473+
"merchant_order_reference_id": {
16474+
"type": "string",
16475+
"description": "Merchant's identifier for the payment/invoice. This will be sent to the connector\nif the connector provides support to accept multiple reference ids.\nIn case the connector supports only one reference id, Hyperswitch's Payment ID will be sent as reference.",
16476+
"example": "Custom_Order_id_123",
16477+
"nullable": true,
16478+
"maxLength": 255
1645116479
}
1645216480
},
1645316481
"additionalProperties": false
@@ -16986,6 +17014,13 @@
1698617014
"type": "object",
1698717015
"description": "You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. FRM Metadata is useful for storing additional, structured information on an object related to FRM.",
1698817016
"nullable": true
17017+
},
17018+
"merchant_order_reference_id": {
17019+
"type": "string",
17020+
"description": "Merchant's identifier for the payment/invoice. This will be sent to the connector\nif the connector provides support to accept multiple reference ids.\nIn case the connector supports only one reference id, Hyperswitch's Payment ID will be sent as reference.",
17021+
"example": "Custom_Order_id_123",
17022+
"nullable": true,
17023+
"maxLength": 255
1698917024
}
1699017025
}
1699117026
},
@@ -17456,6 +17491,13 @@
1745617491
}
1745717492
],
1745817493
"nullable": true
17494+
},
17495+
"merchant_order_reference_id": {
17496+
"type": "string",
17497+
"description": "Merchant's identifier for the payment/invoice. This will be sent to the connector\nif the connector provides support to accept multiple reference ids.\nIn case the connector supports only one reference id, Hyperswitch's Payment ID will be sent as reference.",
17498+
"example": "Custom_Order_id_123",
17499+
"nullable": true,
17500+
"maxLength": 255
1745917501
}
1746017502
}
1746117503
},

crates/api_models/src/payments.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,16 @@ pub struct PaymentsRequest {
506506

507507
/// Fee information to be charged on the payment being collected
508508
pub charges: Option<PaymentChargeRequest>,
509+
510+
/// Merchant's identifier for the payment/invoice. This will be sent to the connector
511+
/// if the connector provides support to accept multiple reference ids.
512+
/// In case the connector supports only one reference id, Hyperswitch's Payment ID will be sent as reference.
513+
#[schema(
514+
value_type = Option<String>,
515+
max_length = 255,
516+
example = "Custom_Order_id_123"
517+
)]
518+
pub merchant_order_reference_id: Option<String>,
509519
}
510520

511521
/// Fee information to be charged on the payment being collected
@@ -3623,6 +3633,16 @@ pub struct PaymentsResponse {
36233633
/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. FRM Metadata is useful for storing additional, structured information on an object related to FRM.
36243634
#[schema(value_type = Option<Object>, example = r#"{ "fulfillment_method" : "deliver", "coverage_request" : "fraud" }"#)]
36253635
pub frm_metadata: Option<pii::SecretSerdeValue>,
3636+
3637+
/// Merchant's identifier for the payment/invoice. This will be sent to the connector
3638+
/// if the connector provides support to accept multiple reference ids.
3639+
/// In case the connector supports only one reference id, Hyperswitch's Payment ID will be sent as reference.
3640+
#[schema(
3641+
value_type = Option<String>,
3642+
max_length = 255,
3643+
example = "Custom_Order_id_123"
3644+
)]
3645+
pub merchant_order_reference_id: Option<String>,
36263646
}
36273647

36283648
/// Fee information to be charged on the payment being collected

crates/diesel_models/src/payment_intent.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pub struct PaymentIntent {
6060
pub charges: Option<pii::SecretSerdeValue>,
6161
pub frm_metadata: Option<pii::SecretSerdeValue>,
6262
pub customer_details: Option<Encryption>,
63+
pub merchant_order_reference_id: Option<String>,
6364
}
6465

6566
#[derive(
@@ -116,6 +117,7 @@ pub struct PaymentIntentNew {
116117
pub charges: Option<pii::SecretSerdeValue>,
117118
pub frm_metadata: Option<pii::SecretSerdeValue>,
118119
pub customer_details: Option<Encryption>,
120+
pub merchant_order_reference_id: Option<String>,
119121
}
120122

121123
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -175,6 +177,7 @@ pub enum PaymentIntentUpdate {
175177
request_external_three_ds_authentication: Option<bool>,
176178
frm_metadata: Option<pii::SecretSerdeValue>,
177179
customer_details: Option<Encryption>,
180+
merchant_order_reference_id: Option<String>,
178181
},
179182
PaymentAttemptAndAttemptCountUpdate {
180183
active_attempt_id: String,
@@ -251,6 +254,7 @@ pub struct PaymentIntentUpdateInternal {
251254
pub request_external_three_ds_authentication: Option<bool>,
252255
pub frm_metadata: Option<pii::SecretSerdeValue>,
253256
pub customer_details: Option<Encryption>,
257+
pub merchant_order_reference_id: Option<String>,
254258
}
255259

256260
impl PaymentIntentUpdate {
@@ -287,6 +291,7 @@ impl PaymentIntentUpdate {
287291
request_external_three_ds_authentication,
288292
frm_metadata,
289293
customer_details,
294+
merchant_order_reference_id,
290295
} = self.into();
291296
PaymentIntent {
292297
amount: amount.unwrap_or(source.amount),
@@ -325,6 +330,8 @@ impl PaymentIntentUpdate {
325330
.or(source.request_external_three_ds_authentication),
326331
frm_metadata: frm_metadata.or(source.frm_metadata),
327332
customer_details: customer_details.or(source.customer_details),
333+
merchant_order_reference_id: merchant_order_reference_id
334+
.or(source.merchant_order_reference_id),
328335
..source
329336
}
330337
}
@@ -356,6 +363,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
356363
request_external_three_ds_authentication,
357364
frm_metadata,
358365
customer_details,
366+
merchant_order_reference_id,
359367
} => Self {
360368
amount: Some(amount),
361369
currency: Some(currency),
@@ -380,6 +388,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
380388
request_external_three_ds_authentication,
381389
frm_metadata,
382390
customer_details,
391+
merchant_order_reference_id,
383392
..Default::default()
384393
},
385394
PaymentIntentUpdate::MetadataUpdate {

crates/diesel_models/src/schema.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,8 @@ diesel::table! {
890890
charges -> Nullable<Jsonb>,
891891
frm_metadata -> Nullable<Jsonb>,
892892
customer_details -> Nullable<Bytea>,
893+
#[max_length = 255]
894+
merchant_order_reference_id -> Nullable<Varchar>,
893895
}
894896
}
895897

crates/hyperswitch_domain_models/src/payments.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,5 @@ pub struct PaymentIntent {
6363
pub charges: Option<pii::SecretSerdeValue>,
6464
pub frm_metadata: Option<pii::SecretSerdeValue>,
6565
pub customer_details: Option<Encryptable<Secret<serde_json::Value>>>,
66+
pub merchant_order_reference_id: Option<String>,
6667
}

crates/hyperswitch_domain_models/src/payments/payment_attempt.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ impl behaviour::Conversion for PaymentIntent {
530530
charges: self.charges,
531531
frm_metadata: self.frm_metadata,
532532
customer_details: self.customer_details.map(Encryption::from),
533+
merchant_order_reference_id: self.merchant_order_reference_id,
533534
})
534535
}
535536

@@ -591,6 +592,7 @@ impl behaviour::Conversion for PaymentIntent {
591592
.customer_details
592593
.async_lift(inner_decrypt)
593594
.await?,
595+
merchant_order_reference_id: storage_model.merchant_order_reference_id,
594596
})
595597
}
596598
.await
@@ -645,6 +647,7 @@ impl behaviour::Conversion for PaymentIntent {
645647
charges: self.charges,
646648
frm_metadata: self.frm_metadata,
647649
customer_details: self.customer_details.map(Encryption::from),
650+
merchant_order_reference_id: self.merchant_order_reference_id,
648651
})
649652
}
650653
}

crates/hyperswitch_domain_models/src/payments/payment_intent.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ pub enum PaymentIntentUpdate {
193193
session_expiry: Option<PrimitiveDateTime>,
194194
request_external_three_ds_authentication: Option<bool>,
195195
customer_details: Option<Encryptable<Secret<serde_json::Value>>>,
196+
merchant_order_reference_id: Option<String>,
196197
},
197198
PaymentAttemptAndAttemptCountUpdate {
198199
active_attempt_id: String,
@@ -270,6 +271,7 @@ pub struct PaymentIntentUpdateInternal {
270271
pub request_external_three_ds_authentication: Option<bool>,
271272
pub frm_metadata: Option<pii::SecretSerdeValue>,
272273
pub customer_details: Option<Encryptable<Secret<serde_json::Value>>>,
274+
pub merchant_order_reference_id: Option<String>,
273275
}
274276

275277
impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
@@ -298,6 +300,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
298300
request_external_three_ds_authentication,
299301
frm_metadata,
300302
customer_details,
303+
merchant_order_reference_id,
301304
} => Self {
302305
amount: Some(amount),
303306
currency: Some(currency),
@@ -322,6 +325,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
322325
request_external_three_ds_authentication,
323326
frm_metadata,
324327
customer_details,
328+
merchant_order_reference_id,
325329
..Default::default()
326330
},
327331
PaymentIntentUpdate::MetadataUpdate {
@@ -562,6 +566,7 @@ impl From<PaymentIntentUpdate> for DieselPaymentIntentUpdate {
562566
request_external_three_ds_authentication,
563567
frm_metadata,
564568
customer_details,
569+
merchant_order_reference_id,
565570
} => Self::Update {
566571
amount,
567572
currency,
@@ -585,6 +590,7 @@ impl From<PaymentIntentUpdate> for DieselPaymentIntentUpdate {
585590
request_external_three_ds_authentication,
586591
frm_metadata,
587592
customer_details: customer_details.map(Encryption::from),
593+
merchant_order_reference_id,
588594
},
589595
PaymentIntentUpdate::PaymentAttemptAndAttemptCountUpdate {
590596
active_attempt_id,
@@ -687,6 +693,7 @@ impl From<PaymentIntentUpdateInternal> for diesel_models::PaymentIntentUpdateInt
687693
request_external_three_ds_authentication,
688694
frm_metadata,
689695
customer_details,
696+
merchant_order_reference_id,
690697
} = value;
691698

692699
Self {
@@ -721,6 +728,7 @@ impl From<PaymentIntentUpdateInternal> for diesel_models::PaymentIntentUpdateInt
721728
request_external_three_ds_authentication,
722729
frm_metadata,
723730
customer_details: customer_details.map(Encryption::from),
731+
merchant_order_reference_id,
724732
}
725733
}
726734
}

crates/hyperswitch_domain_models/src/router_request_types.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ pub struct PaymentsAuthorizeData {
6262

6363
// New amount for amount frame work
6464
pub minor_amount: MinorUnit,
65+
66+
/// Merchant's identifier for the payment/invoice. This will be sent to the connector
67+
/// if the connector provides support to accept multiple reference ids.
68+
/// In case the connector supports only one reference id, Hyperswitch's Payment ID will be sent as reference.
69+
pub merchant_order_reference_id: Option<String>,
6570
pub integrity_object: Option<AuthoriseIntegrityObject>,
6671
}
6772

crates/router/src/connector/adyen/transformers.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ pub struct AdyenPaymentRequest<'a> {
179179
line_items: Option<Vec<LineItem>>,
180180
channel: Option<Channel>,
181181
metadata: Option<pii::SecretSerdeValue>,
182+
merchant_order_reference: Option<String>,
182183
}
183184

184185
#[derive(Debug, Serialize)]
@@ -2610,6 +2611,7 @@ impl<'a>
26102611
shopper_statement: item.router_data.request.statement_descriptor.clone(),
26112612
shopper_ip: item.router_data.request.get_ip_address_as_optional(),
26122613
metadata: item.router_data.request.metadata.clone(),
2614+
merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(),
26132615
})
26142616
}
26152617
}
@@ -2672,6 +2674,7 @@ impl<'a>
26722674
shopper_statement: item.router_data.request.statement_descriptor.clone(),
26732675
shopper_ip: item.router_data.request.get_ip_address_as_optional(),
26742676
metadata: item.router_data.request.metadata.clone(),
2677+
merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(),
26752678
})
26762679
}
26772680
}
@@ -2725,6 +2728,7 @@ impl<'a>
27252728
shopper_statement: item.router_data.request.statement_descriptor.clone(),
27262729
shopper_ip: item.router_data.request.get_ip_address_as_optional(),
27272730
metadata: item.router_data.request.metadata.clone(),
2731+
merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(),
27282732
};
27292733
Ok(request)
27302734
}
@@ -2779,6 +2783,7 @@ impl<'a>
27792783
shopper_statement: item.router_data.request.statement_descriptor.clone(),
27802784
shopper_ip: item.router_data.request.get_ip_address_as_optional(),
27812785
metadata: item.router_data.request.metadata.clone(),
2786+
merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(),
27822787
};
27832788
Ok(request)
27842789
}
@@ -2829,6 +2834,7 @@ impl<'a>
28292834
shopper_statement: item.router_data.request.statement_descriptor.clone(),
28302835
shopper_ip: item.router_data.request.get_ip_address_as_optional(),
28312836
metadata: item.router_data.request.metadata.clone(),
2837+
merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(),
28322838
};
28332839
Ok(request)
28342840
}
@@ -2879,6 +2885,7 @@ impl<'a>
28792885
shopper_statement: item.router_data.request.statement_descriptor.clone(),
28802886
shopper_ip: item.router_data.request.get_ip_address_as_optional(),
28812887
metadata: item.router_data.request.metadata.clone(),
2888+
merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(),
28822889
};
28832890
Ok(request)
28842891
}
@@ -2939,6 +2946,7 @@ impl<'a>
29392946
shopper_statement: item.router_data.request.statement_descriptor.clone(),
29402947
shopper_ip: item.router_data.request.get_ip_address_as_optional(),
29412948
metadata: item.router_data.request.metadata.clone(),
2949+
merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(),
29422950
})
29432951
}
29442952
}
@@ -3034,6 +3042,7 @@ impl<'a>
30343042
shopper_statement: item.router_data.request.statement_descriptor.clone(),
30353043
shopper_ip: item.router_data.request.get_ip_address_as_optional(),
30363044
metadata: item.router_data.request.metadata.clone(),
3045+
merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(),
30373046
})
30383047
}
30393048
}
@@ -3109,6 +3118,7 @@ impl<'a>
31093118
shopper_statement: item.router_data.request.statement_descriptor.clone(),
31103119
shopper_ip: item.router_data.request.get_ip_address_as_optional(),
31113120
metadata: item.router_data.request.metadata.clone(),
3121+
merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(),
31123122
})
31133123
}
31143124
}
@@ -3167,6 +3177,7 @@ impl<'a>
31673177
shopper_statement: item.router_data.request.statement_descriptor.clone(),
31683178
shopper_ip: item.router_data.request.get_ip_address_as_optional(),
31693179
metadata: item.router_data.request.metadata.clone(),
3180+
merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(),
31703181
})
31713182
}
31723183
}

0 commit comments

Comments
 (0)