From bb86cc2d04665ccd68eebea68a3d5b58f481c63d Mon Sep 17 00:00:00 2001 From: Pa1NarK <69745008+pixincreate@users.noreply.github.com> Date: Wed, 25 Oct 2023 13:25:54 +0530 Subject: [PATCH] fix(refunds): Add `profile_id` in refunds response (#2652) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- crates/api_models/src/refunds.rs | 1 + crates/router/src/core/refunds.rs | 2 ++ openapi/openapi_spec.json | 4 ++++ .../stripe/QuickStart/Refunds - Create/event.test.js | 10 ++++++++++ 4 files changed, 17 insertions(+) diff --git a/crates/api_models/src/refunds.rs b/crates/api_models/src/refunds.rs index 489c5dd1c436..ceb476fff362 100644 --- a/crates/api_models/src/refunds.rs +++ b/crates/api_models/src/refunds.rs @@ -124,6 +124,7 @@ pub struct RefundResponse { /// The connector used for the refund and the corresponding payment #[schema(example = "stripe")] pub connector: String, + pub profile_id: Option, } #[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize, ToSchema)] diff --git a/crates/router/src/core/refunds.rs b/crates/router/src/core/refunds.rs index 44e2b84dbd75..b064c8a730fc 100644 --- a/crates/router/src/core/refunds.rs +++ b/crates/router/src/core/refunds.rs @@ -602,6 +602,7 @@ pub async fn validate_and_create_refund( .set_description(req.reason.clone()) .set_attempt_id(payment_attempt.attempt_id.clone()) .set_refund_reason(req.reason) + .set_profile_id(payment_intent.profile_id.clone()) .to_owned(); refund = db @@ -704,6 +705,7 @@ impl ForeignFrom for api::RefundResponse { currency: refund.currency.to_string(), reason: refund.refund_reason, status: refund.refund_status.foreign_into(), + profile_id: refund.profile_id, metadata: refund.metadata, error_message: refund.refund_error_message, error_code: refund.refund_error_code, diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json index b873be756407..7649a4e98211 100644 --- a/openapi/openapi_spec.json +++ b/openapi/openapi_spec.json @@ -10680,6 +10680,10 @@ "type": "string", "description": "The connector used for the refund and the corresponding payment", "example": "stripe" + }, + "profile_id": { + "type": "string", + "nullable": true } } }, diff --git a/postman/collection-dir/stripe/QuickStart/Refunds - Create/event.test.js b/postman/collection-dir/stripe/QuickStart/Refunds - Create/event.test.js index dbc930608cb3..f88e7ae9d6af 100644 --- a/postman/collection-dir/stripe/QuickStart/Refunds - Create/event.test.js +++ b/postman/collection-dir/stripe/QuickStart/Refunds - Create/event.test.js @@ -28,3 +28,13 @@ if (jsonData?.refund_id) { "INFO - Unable to assign variable {{refund_id}}, as jsonData.refund_id is undefined.", ); } + + +// Response body should have "profile_id" and not "null" +pm.test( + "[POST]::/payments - Content check if 'profile_id' exists and is not 'null'", + function () { + pm.expect(typeof jsonData.profile_id !== "undefined").to.be.true; + pm.expect(jsonData.profile_id).is.not.null; + }, +);