Skip to content

Commit

Permalink
feat: add openapi endpoints for payment methods list
Browse files Browse the repository at this point in the history
  • Loading branch information
Narayanbhat166 committed Dec 25, 2024
1 parent 89f90c6 commit 289b0e5
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 105 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
openapi: get /v2/payment-methods/{id}/list-payment-methods
---
10 changes: 5 additions & 5 deletions api-reference-v2/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@
"group": "Payment Methods",
"pages": [
"api-reference/payment-methods/payment-method--create",
"api-reference/payment-methods/payment-method--retrieve",
"api-reference/payment-methods/payment-method--update",
"api-reference/payment-methods/payment-method--delete",
"api-reference/payment-methods/payment-method--create-intent",
"api-reference/payment-methods/payment-method--payment-methods-list",
"api-reference/payment-methods/payment-method--confirm-intent",
"api-reference/payment-methods/list-customer-saved-payment-methods-for-a-payment",
"api-reference/payment-methods/list-payment-methods-for-a-customer"
"api-reference/payment-methods/payment-method--update",
"api-reference/payment-methods/payment-method--retrieve",
"api-reference/payment-methods/payment-method--delete",
"api-reference/payment-methods/list-saved-payment-methods-for-a-customer"
]
},
{
Expand Down
167 changes: 89 additions & 78 deletions api-reference-v2/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -2190,83 +2190,37 @@
]
}
},
"/v2/payments/{id}/saved-payment-methods": {
"get": {
"tags": [
"Payment Methods"
],
"summary": "List customer saved payment methods for a payment",
"description": "To filter and list the applicable payment methods for a particular Customer ID, is to be associated with a payment",
"operationId": "List all Payment Methods for a Customer",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PaymentMethodListRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Payment Methods retrieved for customer tied to its respective client-secret passed in the param",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CustomerPaymentMethodsListResponse"
}
}
}
},
"400": {
"description": "Invalid Data"
},
"404": {
"description": "Payment Methods does not exist in records"
}
},
"security": [
{
"publishable_key": []
}
]
}
},
"/v2/customers/{id}/saved-payment-methods": {
"get": {
"/v2/payment-methods": {
"post": {
"tags": [
"Payment Methods"
],
"summary": "List saved payment methods for a Customer",
"description": "To filter and list the applicable payment methods for a particular Customer ID, to be used in a non-payments context",
"operationId": "List all Payment Methods for a Customer",
"summary": "Payment Method - Create",
"description": "Creates and stores a payment method against a customer. In case of cards, this API should be used only by PCI compliant merchants.",
"operationId": "Create Payment Method",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PaymentMethodListRequest"
"$ref": "#/components/schemas/PaymentMethodCreate"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Payment Methods retrieved",
"description": "Payment Method Created",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CustomerPaymentMethodsListResponse"
"$ref": "#/components/schemas/PaymentMethodResponse"
}
}
}
},
"400": {
"description": "Invalid Data"
},
"404": {
"description": "Payment Methods does not exist in records"
}
},
"security": [
Expand All @@ -2276,27 +2230,27 @@
]
}
},
"/v2/payment-methods": {
"/v2/payment-methods/create-intent": {
"post": {
"tags": [
"Payment Methods"
],
"summary": "Payment Method - Create",
"description": "Creates and stores a payment method against a customer. In case of cards, this API should be used only by PCI compliant merchants.",
"operationId": "Create Payment Method",
"summary": "Payment Method - Create Intent",
"description": "Creates a payment method for customer with billing information and other metadata.",
"operationId": "Create Payment Method Intent",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PaymentMethodCreate"
"$ref": "#/components/schemas/PaymentMethodIntentCreate"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Payment Method Created",
"description": "Payment Method Intent Created",
"content": {
"application/json": {
"schema": {
Expand All @@ -2316,42 +2270,56 @@
]
}
},
"/v2/payment-methods/create-intent": {
"post": {
"/v2/payment-methods/{id}/list-payment-methods": {
"get": {
"tags": [
"Payment Methods"
],
"summary": "Payment Method - Create Intent",
"description": "Creates a payment method for customer with billing information and other metadata.",
"operationId": "Create Payment Method Intent",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PaymentMethodIntentCreate"
}
"summary": "Payment Methods - Payment Methods List",
"description": "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",
"operationId": "Retrieve Payment methods for a Payment Method Intent",
"parameters": [
{
"name": "id",
"in": "path",
"description": "The global payment method id",
"required": true,
"schema": {
"type": "string"
}
},
"required": true
},
{
"name": "X-Profile-Id",
"in": "header",
"description": "Profile ID associated to the payment method intent",
"required": true,
"schema": {
"type": "string"
},
"example": {
"X-Profile-Id": "pro_abcdefghijklmnop"
}
}
],
"responses": {
"200": {
"description": "Payment Method Intent Created",
"description": "Get the payment methods",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PaymentMethodResponse"
"$ref": "#/components/schemas/PaymentMethodListResponseForPayments"
}
}
}
},
"400": {
"description": "Invalid Data"
"404": {
"description": "No payment method found with the given id"
}
},
"security": [
{
"api_key": []
"api_key": [],
"ephemeral_key": []
}
]
}
Expand Down Expand Up @@ -2516,6 +2484,49 @@
]
}
},
"/v2/customers/{id}/saved-payment-methods": {
"get": {
"tags": [
"Payment Methods"
],
"summary": "List saved payment methods for a Customer",
"description": "To filter and list the applicable payment methods for a particular Customer ID, to be used in a non-payments context",
"operationId": "List all Payment Methods for a Customer",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PaymentMethodListRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Payment Methods retrieved",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CustomerPaymentMethodsListResponse"
}
}
}
},
"400": {
"description": "Invalid Data"
},
"404": {
"description": "Payment Methods does not exist in records"
}
},
"security": [
{
"api_key": []
}
]
}
},
"/v2/refunds": {
"post": {
"tags": [
Expand Down
5 changes: 2 additions & 3 deletions crates/openapi/src/openapi_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,14 @@ Never share your secret api keys. Keep them guarded and secure.
routes::payments::list_payment_methods,
//Routes for payment methods
routes::payment_method::list_customer_payment_method_for_payment,
routes::payment_method::list_customer_payment_method_api,
routes::payment_method::create_payment_method_api,
routes::payment_method::create_payment_method_intent_api,
routes::payment_method::list_payment_methods,
routes::payment_method::confirm_payment_method_intent_api,
routes::payment_method::payment_method_update_api,
routes::payment_method::payment_method_retrieve_api,
routes::payment_method::payment_method_delete_api,
routes::payment_method::list_customer_payment_method_api,
//Routes for refunds
routes::refunds::refunds_create,
Expand Down
41 changes: 22 additions & 19 deletions crates/openapi/src/routes/payment_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,46 +322,49 @@ pub async fn payment_method_update_api() {}
#[cfg(feature = "v2")]
pub async fn payment_method_delete_api() {}

/// List customer saved payment methods for a payment
/// List saved payment methods for a Customer
///
/// To filter and list the applicable payment methods for a particular Customer ID, is to be associated with a payment
/// To filter and list the applicable payment methods for a particular Customer ID, to be used in a non-payments context
#[utoipa::path(
get,
path = "/v2/payments/{id}/saved-payment-methods",
path = "/v2/customers/{id}/saved-payment-methods",
request_body(
content = PaymentMethodListRequest,
// TODO: Add examples and add param for customer_id
),
responses(
(status = 200, description = "Payment Methods retrieved for customer tied to its respective client-secret passed in the param", body = CustomerPaymentMethodsListResponse),
(status = 200, description = "Payment Methods retrieved", body = CustomerPaymentMethodsListResponse),
(status = 400, description = "Invalid Data"),
(status = 404, description = "Payment Methods does not exist in records")
),
tag = "Payment Methods",
operation_id = "List all Payment Methods for a Customer",
security(("publishable_key" = []))
security(("api_key" = []))
)]
#[cfg(feature = "v2")]
pub async fn list_customer_payment_method_for_payment() {}
pub async fn list_customer_payment_method_api() {}

/// List saved payment methods for a Customer
/// Payment Methods - Payment Methods List
///
/// To filter and list the applicable payment methods for a particular Customer ID, to be used in a non-payments context
/// 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/customers/{id}/saved-payment-methods",
request_body(
content = PaymentMethodListRequest,
// TODO: Add examples and add param for customer_id
path = "/v2/payment-methods/{id}/list-payment-methods",
params(
("id" = String, Path, description = "The global payment method id"),
(
"X-Profile-Id" = String, Header,
description = "Profile ID associated to the payment method intent",
example = json!({"X-Profile-Id": "pro_abcdefghijklmnop"})
),
),
responses(
(status = 200, description = "Payment Methods retrieved", body = CustomerPaymentMethodsListResponse),
(status = 400, description = "Invalid Data"),
(status = 404, description = "Payment Methods does not exist in records")
(status = 200, description = "Get the payment methods", body = PaymentMethodListResponseForPayments),
(status = 404, description = "No payment method found with the given id")
),
tag = "Payment Methods",
operation_id = "List all Payment Methods for a Customer",
security(("api_key" = []))
operation_id = "Retrieve Payment methods for a Payment Method Intent",
security(("api_key" = [], "ephemeral_key" = []))
)]
#[cfg(feature = "v2")]
pub async fn list_customer_payment_method_api() {}
pub fn list_payment_methods() {}

0 comments on commit 289b0e5

Please sign in to comment.