From 04c60d73cb34a3432fcb9fa24af95022b16048b2 Mon Sep 17 00:00:00 2001 From: Shankar Singh C <83439957+ShankarSinghC@users.noreply.github.com> Date: Tue, 4 Jul 2023 18:48:30 +0530 Subject: [PATCH] fix(payment_methods): return an empty array when the merchant does not have any payment methods (#1601) --- .../router/src/core/payment_methods/cards.rs | 23 ++++----- openapi/openapi_spec.json | 51 ++++++++++++++++--- 2 files changed, 53 insertions(+), 21 deletions(-) diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs index c790f6bb2d..93a71fb357 100644 --- a/crates/router/src/core/payment_methods/cards.rs +++ b/crates/router/src/core/payment_methods/cards.rs @@ -1106,19 +1106,16 @@ pub async fn list_payment_methods( }); } - response - .is_empty() - .then(|| Err(report!(errors::ApiErrorResponse::PaymentMethodNotFound))) - .unwrap_or(Ok(services::ApplicationResponse::Json( - api::PaymentMethodListResponse { - redirect_url: merchant_account.return_url, - merchant_name: merchant_account.merchant_name, - payment_methods: payment_method_responses, - mandate_payment: payment_attempt - .and_then(|inner| inner.mandate_details) - .map(ForeignInto::foreign_into), - }, - ))) + Ok(services::ApplicationResponse::Json( + api::PaymentMethodListResponse { + redirect_url: merchant_account.return_url, + merchant_name: merchant_account.merchant_name, + payment_methods: payment_method_responses, + mandate_payment: payment_attempt + .and_then(|inner| inner.mandate_details) + .map(ForeignInto::foreign_into), + }, + )) } #[allow(clippy::too_many_arguments)] diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json index 72ebee8100..582caf8977 100644 --- a/openapi/openapi_spec.json +++ b/openapi/openapi_spec.json @@ -2740,6 +2740,12 @@ } ], "nullable": true + }, + "nick_name": { + "type": "string", + "description": "The card holder's nick name", + "example": "John Test", + "nullable": true } } }, @@ -2771,6 +2777,12 @@ "type": "string", "description": "Card Holder Name", "example": "John Doe" + }, + "nick_name": { + "type": "string", + "description": "Card Holder's Nick Name", + "example": "John Doe", + "nullable": true } } }, @@ -2808,6 +2820,10 @@ "card_fingerprint": { "type": "string", "nullable": true + }, + "nick_name": { + "type": "string", + "nullable": true } } }, @@ -6340,8 +6356,7 @@ "type": "object", "required": [ "amount", - "currency", - "manual_retry" + "currency" ], "properties": { "payment_id": { @@ -6652,9 +6667,13 @@ "description": "Business sub label for the payment", "nullable": true }, - "manual_retry": { - "type": "boolean", - "description": "If enabled payment can be retried from the client side until the payment is successful or payment expires or the attempts(configured by the merchant) for payment are exhausted." + "retry_action": { + "allOf": [ + { + "$ref": "#/components/schemas/RetryAction" + } + ], + "nullable": true }, "udf": { "type": "object", @@ -6974,9 +6993,13 @@ "description": "Business sub label for the payment", "nullable": true }, - "manual_retry": { - "type": "boolean", - "description": "If enabled payment can be retried from the client side until the payment is successful or payment expires or the attempts(configured by the merchant) for payment are exhausted." + "retry_action": { + "allOf": [ + { + "$ref": "#/components/schemas/RetryAction" + } + ], + "nullable": true }, "udf": { "type": "object", @@ -7302,6 +7325,11 @@ ], "nullable": true }, + "manual_retry_allowed": { + "type": "boolean", + "description": "If true the payment can be retried with same or different payment method which means the confirm call can be made again.", + "nullable": true + }, "udf": { "type": "object", "description": "Any user defined fields can be passed here.", @@ -7818,6 +7846,13 @@ } } }, + "RetryAction": { + "type": "string", + "enum": [ + "manual_retry", + "requeue" + ] + }, "RevokeApiKeyResponse": { "type": "object", "description": "The response body for revoking an API Key.",