feat(payments_v2): add payment method list endpoint (#6805)

Co-authored-by: Sanchith Hegde <sanchith.hegde@juspay.in>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Narayan Bhat
2024-12-23 15:37:16 +05:30
committed by GitHub
parent 1fc941056f
commit d4b3dbc155
45 changed files with 1307 additions and 721 deletions

View File

@ -87,9 +87,6 @@ Never share your secret api keys. Keep them guarded and secure.
routes::merchant_account::merchant_account_update,
routes::merchant_account::profiles_list,
// Routes for payments
routes::payments::payments_connector_session,
// Routes for profile
routes::profile::profile_create,
routes::profile::profile_retrieve,
@ -127,6 +124,8 @@ Never share your secret api keys. Keep them guarded and secure.
routes::payments::payments_update_intent,
routes::payments::payments_confirm_intent,
routes::payments::payment_status,
routes::payments::payments_connector_session,
routes::payments::list_payment_methods,
//Routes for payment methods
routes::payment_method::list_customer_payment_method_for_payment,
@ -162,6 +161,7 @@ Never share your secret api keys. Keep them guarded and secure.
common_types::payments::StripeSplitPaymentRequest,
common_types::refunds::StripeSplitRefundRequest,
common_utils::types::ChargeRefunds,
common_types::payment_methods::PaymentMethodsEnabled,
common_types::refunds::SplitRefund,
api_models::payments::SplitPaymentsResponse,
api_models::payments::StripeSplitPaymentsResponse,
@ -198,6 +198,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::payment_methods::PaymentMethodListRequest,
api_models::payment_methods::PaymentMethodListResponse,
api_models::payment_methods::ResponsePaymentMethodsEnabled,
api_models::payment_methods::PaymentMethodSubtypeSpecificData,
api_models::payment_methods::ResponsePaymentMethodTypes,
api_models::payment_methods::PaymentExperienceTypes,
api_models::payment_methods::CardNetworkTypes,
@ -272,7 +273,6 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::admin::FrmConfigs,
api_models::admin::FrmPaymentMethod,
api_models::admin::FrmPaymentMethodType,
api_models::admin::PaymentMethodsEnabled,
api_models::admin::MerchantConnectorDetailsWrap,
api_models::admin::MerchantConnectorDetails,
api_models::admin::MerchantConnectorWebhookDetails,
@ -474,6 +474,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::payments::PaymentsConfirmIntentResponse,
api_models::payments::AmountDetailsResponse,
api_models::payments::BankCodeResponse,
api_models::payments::PaymentMethodListResponseForPayments,
api_models::payment_methods::RequiredFieldInfo,
api_models::payment_methods::DefaultPaymentMethod,
api_models::payment_methods::MaskedBankDetails,

View File

@ -691,6 +691,18 @@ pub fn payments_update_intent() {}
#[utoipa::path(
post,
path = "/v2/payments/{id}/confirm-intent",
params (("id" = String, Path, description = "The unique identifier for the Payment Intent"),
(
"X-Profile-Id" = String, Header,
description = "Profile ID associated to the payment intent",
example = json!({"X-Profile-Id": "pro_abcdefghijklmnop"})
),
(
"X-Client-Secret" = String, Header,
description = "Client Secret Associated with the payment intent",
example = json!({"X-Client-Secret": "12345_pay_0193e41106e07e518940f8b51b9c8121_secret_0193e41107027a928d61d292e6a5dba9"})
),
),
request_body(
content = PaymentsConfirmIntentRequest,
examples(
@ -718,7 +730,7 @@ pub fn payments_update_intent() {}
),
tag = "Payments",
operation_id = "Confirm Payment Intent",
security(("publisable_key" = [])),
security(("publishable_key" = [])),
)]
#[cfg(feature = "v2")]
pub fn payments_confirm_intent() {}
@ -752,3 +764,33 @@ pub(crate) enum ForceSync {
/// Do not force sync with the connector / processor. Get the status which is available in the database
False,
}
/// Payments - Payment Methods List
///
/// List the payment methods eligible for a payment. This endpoint also returns the saved payment methods for the customer when the customer_id is passed when creating the payment
#[cfg(feature = "v2")]
#[utoipa::path(
get,
path = "/v2/payments/{id}/payment-methods",
params(
("id" = String, Path, description = "The global payment id"),
(
"X-Profile-Id" = String, Header,
description = "Profile ID associated to the payment intent",
example = json!({"X-Profile-Id": "pro_abcdefghijklmnop"})
),
(
"X-Client-Secret" = String, Header,
description = "Client Secret Associated with the payment intent",
example = json!({"X-Client-Secret": "12345_pay_0193e41106e07e518940f8b51b9c8121_secret_0193e41107027a928d61d292e6a5dba9"})
),
),
responses(
(status = 200, description = "Get the payment methods", body = PaymentMethodListResponseForPayments),
(status = 404, description = "No payment found with the given id")
),
tag = "Payments",
operation_id = "Retrieve Payment methods for a Payment",
security(("publishable_key" = []))
)]
pub fn list_payment_methods() {}