feat: add merchant_name field in the response body (#1280)

Co-authored-by: Prajjwal Kumar <prajjwal.kumar@juspay.in>
Co-authored-by: Sanchith Hegde <sanchith.hegde@juspay.in>
This commit is contained in:
Amisha Prabhat
2023-07-01 16:40:46 +05:30
committed by GitHub
parent 2136326166
commit dd4ba63cc4
3 changed files with 296 additions and 321 deletions

View File

@ -1,5 +1,5 @@
use cards::CardNumber;
use common_utils::pii;
use common_utils::{crypto::OptionalEncryptableName, pii};
use serde::de;
use utoipa::ToSchema;
@ -441,6 +441,9 @@ pub struct PaymentMethodListResponse {
/// Value indicating if the current payment is a mandate payment
#[schema(value_type = MandateType)]
pub mandate_payment: Option<payments::MandateType>,
#[schema(value_type = Option<String>)]
pub merchant_name: OptionalEncryptableName,
}
#[derive(Eq, PartialEq, Hash, Debug, serde::Deserialize, ToSchema)]

View File

@ -1110,6 +1110,7 @@ pub async fn list_payment_methods(
.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)

View File

@ -1339,84 +1339,23 @@
}
},
"/refunds/list": {
"get": {
"post": {
"tags": [
"Refunds"
],
"summary": "Refunds - List",
"description": "Refunds - List\n\nTo list the refunds associated with a payment_id or with the merchant, if payment_id is not provided",
"operationId": "List all Refunds",
"parameters": [
{
"name": "payment_id",
"in": "query",
"description": "The identifier for the payment",
"required": true,
"schema": {
"type": "string"
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/RefundListRequest"
}
}
},
{
"name": "limit",
"in": "query",
"description": "Limit on the number of objects to return",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
}
},
{
"name": "created",
"in": "query",
"description": "The time at which refund is created",
"required": true,
"schema": {
"type": "string",
"format": "date-time"
}
},
{
"name": "created_lt",
"in": "query",
"description": "Time less than the refund created time",
"required": true,
"schema": {
"type": "string",
"format": "date-time"
}
},
{
"name": "created_gt",
"in": "query",
"description": "Time greater than the refund created time",
"required": true,
"schema": {
"type": "string",
"format": "date-time"
}
},
{
"name": "created_lte",
"in": "query",
"description": "Time less than or equals to the refund created time",
"required": true,
"schema": {
"type": "string",
"format": "date-time"
}
},
{
"name": "created_gte",
"in": "query",
"description": "Time greater than or equals to the refund created time",
"required": true,
"schema": {
"type": "string",
"format": "date-time"
}
}
],
"required": true
},
"responses": {
"200": {
"description": "List of refunds",
@ -1790,10 +1729,10 @@
}
}
},
"AliPayRedirection": {
"AliPayHkRedirection": {
"type": "object"
},
"AliPayHkRedirection": {
"AliPayRedirection": {
"type": "object"
},
"AmountInfo": {
@ -6093,6 +6032,10 @@
},
"mandate_payment": {
"$ref": "#/components/schemas/MandateType"
},
"merchant_name": {
"type": "string",
"nullable": true
}
}
},
@ -6183,6 +6126,7 @@
"affirm",
"afterpay_clearpay",
"ali_pay",
"ali_pay_hk",
"apple_pay",
"bacs",
"bancontact_card",
@ -6345,150 +6289,17 @@
"PaymentsCreateRequest": {
"type": "object",
"required": [
"amount",
"manual_retry",
"amount",
"currency"
],
"properties": {
"browser_info": {
"type": "object",
"description": "Additional details required by 3DS 2.0",
"nullable": true
},
"billing": {
"allOf": [
{
"$ref": "#/components/schemas/Address"
}
],
"nullable": true
},
"merchant_connector_details": {
"allOf": [
{
"$ref": "#/components/schemas/MerchantConnectorDetailsWrap"
}
],
"nullable": true
},
"capture_method": {
"allOf": [
{
"$ref": "#/components/schemas/CaptureMethod"
}
],
"nullable": true
},
"shipping": {
"allOf": [
{
"$ref": "#/components/schemas/Address"
}
],
"nullable": true
},
"routing": {
"allOf": [
{
"$ref": "#/components/schemas/RoutingAlgorithm"
}
],
"nullable": true
},
"off_session": {
"type": "boolean",
"description": "Set to true to indicate that the customer is not in your checkout flow during this payment, and therefore is unable to authenticate. This parameter is intended for scenarios where you collect card details and charge them later. This parameter can only be used with `confirm: true`.",
"example": true,
"nullable": true
},
"return_url": {
"type": "string",
"description": "The URL to redirect after the completion of the operation",
"example": "https://hyperswitch.io",
"nullable": true
},
"statement_descriptor_name": {
"type": "string",
"description": "For non-card charges, you can use this value as the complete description that appears on your customers statements. Must contain at least one letter, maximum 22 characters.",
"example": "Hyperswitch Router",
"nullable": true,
"maxLength": 255
},
"setup_future_usage": {
"allOf": [
{
"$ref": "#/components/schemas/FutureUsage"
}
],
"nullable": true
},
"amount": {
"type": "integer",
"format": "int64",
"description": "The payment amount. Amount for the payment in lowest denomination of the currency. (i.e) in cents for USD denomination, in paisa for INR denomination etc.,",
"example": 6540,
"nullable": true,
"minimum": 0.0
},
"merchant_id": {
"type": "string",
"description": "This is an identifier for the merchant account. This is inferred from the API key\nprovided during the request",
"example": "merchant_1668273825",
"nullable": true,
"maxLength": 255
},
"amount_to_capture": {
"type": "integer",
"format": "int64",
"description": "The Amount to be captured/ debited from the users payment method. It shall be in lowest denomination of the currency. (i.e) in cents for USD denomination, in paisa for INR denomination etc.,\nIf not provided, the default amount_to_capture will be the payment amount.",
"example": 6540,
"nullable": true
},
"customer": {
"allOf": [
{
"$ref": "#/components/schemas/CustomerDetails"
}
],
"nullable": true
},
"payment_id": {
"type": "string",
"description": "Unique identifier for the payment. This ensures idempotency for multiple payments\nthat have been done by a single merchant. This field is auto generated and is returned in the API response.",
"example": "pay_mbabizu24mvu3mela5njyhpit4",
"nullable": true,
"maxLength": 30,
"minLength": 30
},
"confirm": {
"type": "boolean",
"description": "Whether to confirm the payment (if applicable)",
"default": false,
"example": true,
"nullable": true
},
"authentication_type": {
"allOf": [
{
"$ref": "#/components/schemas/AuthenticationType"
}
],
"nullable": true
},
"metadata": {
"allOf": [
{
"$ref": "#/components/schemas/Metadata"
}
],
"nullable": true
},
"mandate_data": {
"allOf": [
{
"$ref": "#/components/schemas/MandateData"
}
],
"allowed_payment_method_types": {
"type": "array",
"items": {
"$ref": "#/components/schemas/PaymentMethodType"
},
"description": "Allowed Payment Method Types for a given PaymentIntent",
"nullable": true
},
"payment_experience": {
@ -6499,43 +6310,10 @@
],
"nullable": true
},
"payment_token": {
"type": "string",
"description": "Provide a reference to a stored payment method",
"example": "187282ab-40ef-47a9-9206-5099ba31e432",
"nullable": true
},
"phone": {
"type": "string",
"description": "The customer's phone number\nThis field will be deprecated soon, use the customer object instead",
"example": "3141592653",
"nullable": true,
"maxLength": 255
},
"business_country": {
"allOf": [
{
"$ref": "#/components/schemas/CountryAlpha2"
}
],
"nullable": true
},
"phone_country_code": {
"type": "string",
"description": "The country code for the customer phone number\nThis field will be deprecated soon, use the customer object instead",
"example": "+1",
"nullable": true,
"maxLength": 255
},
"client_secret": {
"type": "string",
"description": "It's a token used for client side verification.",
"example": "pay_U42c409qyHwOkWo3vK60_secret_el9ksDkiB8hi6j9N78yo",
"nullable": true
},
"udf": {
"type": "object",
"description": "Any user defined fields can be passed here.",
"off_session": {
"type": "boolean",
"description": "Set to true to indicate that the customer is not in your checkout flow during this payment, and therefore is unable to authenticate. This parameter is intended for scenarios where you collect card details and charge them later. This parameter can only be used with `confirm: true`.",
"example": true,
"nullable": true
},
"customer_id": {
@ -6545,47 +6323,33 @@
"nullable": true,
"maxLength": 255
},
"card_cvc": {
"phone_country_code": {
"type": "string",
"description": "This is used when payment is to be confirmed and the card is not saved",
"nullable": true
},
"name": {
"type": "string",
"description": "description: The customer's name\nThis field will be deprecated soon, use the customer object instead",
"example": "John Test",
"description": "The country code for the customer phone number\nThis field will be deprecated soon, use the customer object instead",
"example": "+1",
"nullable": true,
"maxLength": 255
},
"allowed_payment_method_types": {
"type": "array",
"items": {
"$ref": "#/components/schemas/PaymentMethodType"
},
"description": "Allowed Payment Method Types for a given PaymentIntent",
"amount_to_capture": {
"type": "integer",
"format": "int64",
"description": "The Amount to be captured/ debited from the users payment method. It shall be in lowest denomination of the currency. (i.e) in cents for USD denomination, in paisa for INR denomination etc.,\nIf not provided, the default amount_to_capture will be the payment amount.",
"example": 6540,
"nullable": true
},
"payment_method_data": {
"udf": {
"type": "object",
"description": "Any user defined fields can be passed here.",
"nullable": true
},
"setup_future_usage": {
"allOf": [
{
"$ref": "#/components/schemas/PaymentMethodData"
"$ref": "#/components/schemas/FutureUsage"
}
],
"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."
},
"order_details": {
"type": "array",
"items": {
"$ref": "#/components/schemas/OrderDetailsWithAmount"
},
"description": "Information about the product , quantity and amount for connectors. (e.g. Klarna)",
"example": "[{\n \"product_name\": \"gillete creme\",\n \"quantity\": 15,\n \"amount\" : 900\n }]",
"nullable": true
},
"connector": {
"type": "array",
"items": {
@ -6598,24 +6362,47 @@
],
"nullable": true
},
"capture_on": {
"type": "string",
"format": "date-time",
"description": "A timestamp (ISO 8601 code) that determines when the payment should be captured.\nProviding this field will automatically set `capture` to true",
"example": "2022-09-10T10:11:12Z",
"shipping": {
"allOf": [
{
"$ref": "#/components/schemas/Address"
}
],
"nullable": true
},
"mandate_id": {
"phone": {
"type": "string",
"description": "A unique identifier to link the payment to a mandate, can be use instead of payment_method_data",
"example": "mandate_iwer89rnjef349dni3",
"description": "The customer's phone number\nThis field will be deprecated soon, use the customer object instead",
"example": "3141592653",
"nullable": true,
"maxLength": 255
},
"payment_method_type": {
"confirm": {
"type": "boolean",
"description": "Whether to confirm the payment (if applicable)",
"default": false,
"example": true,
"nullable": true
},
"mandate_data": {
"allOf": [
{
"$ref": "#/components/schemas/PaymentMethodType"
"$ref": "#/components/schemas/MandateData"
}
],
"nullable": true
},
"statement_descriptor_name": {
"type": "string",
"description": "For non-card charges, you can use this value as the complete description that appears on your customers statements. Must contain at least one letter, maximum 22 characters.",
"example": "Hyperswitch Router",
"nullable": true,
"maxLength": 255
},
"business_country": {
"allOf": [
{
"$ref": "#/components/schemas/CountryAlpha2"
}
],
"nullable": true
@ -6626,18 +6413,115 @@
"example": "food",
"nullable": true
},
"statement_descriptor_suffix": {
"description": {
"type": "string",
"description": "Provides information about a card payment that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor thats set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor.",
"example": "Payment for shoes purchase",
"description": "A description of the payment",
"example": "It's my first payment request",
"nullable": true
},
"client_secret": {
"type": "string",
"description": "It's a token used for client side verification.",
"example": "pay_U42c409qyHwOkWo3vK60_secret_el9ksDkiB8hi6j9N78yo",
"nullable": true
},
"payment_method_type": {
"allOf": [
{
"$ref": "#/components/schemas/PaymentMethodType"
}
],
"nullable": true
},
"customer": {
"allOf": [
{
"$ref": "#/components/schemas/CustomerDetails"
}
],
"nullable": true
},
"browser_info": {
"type": "object",
"description": "Additional details required by 3DS 2.0",
"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."
},
"return_url": {
"type": "string",
"description": "The URL to redirect after the completion of the operation",
"example": "https://hyperswitch.io",
"nullable": true
},
"mandate_id": {
"type": "string",
"description": "A unique identifier to link the payment to a mandate, can be use instead of payment_method_data",
"example": "mandate_iwer89rnjef349dni3",
"nullable": true,
"maxLength": 255
},
"business_sub_label": {
"payment_id": {
"type": "string",
"description": "Business sub label for the payment",
"description": "Unique identifier for the payment. This ensures idempotency for multiple payments\nthat have been done by a single merchant. This field is auto generated and is returned in the API response.",
"example": "pay_mbabizu24mvu3mela5njyhpit4",
"nullable": true,
"maxLength": 30,
"minLength": 30
},
"metadata": {
"allOf": [
{
"$ref": "#/components/schemas/Metadata"
}
],
"nullable": true
},
"capture_method": {
"allOf": [
{
"$ref": "#/components/schemas/CaptureMethod"
}
],
"nullable": true
},
"name": {
"type": "string",
"description": "description: The customer's name\nThis field will be deprecated soon, use the customer object instead",
"example": "John Test",
"nullable": true,
"maxLength": 255
},
"amount": {
"type": "integer",
"format": "int64",
"description": "The payment amount. Amount for the payment in lowest denomination of the currency. (i.e) in cents for USD denomination, in paisa for INR denomination etc.,",
"example": 6540,
"nullable": true,
"minimum": 0.0
},
"card_cvc": {
"type": "string",
"description": "This is used when payment is to be confirmed and the card is not saved",
"nullable": true
},
"merchant_connector_details": {
"allOf": [
{
"$ref": "#/components/schemas/MerchantConnectorDetailsWrap"
}
],
"nullable": true
},
"merchant_id": {
"type": "string",
"description": "This is an identifier for the merchant account. This is inferred from the API key\nprovided during the request",
"example": "merchant_1668273825",
"nullable": true,
"maxLength": 255
},
"currency": {
"allOf": [
{
@ -6646,18 +6530,46 @@
],
"nullable": true
},
"payment_method": {
"payment_token": {
"type": "string",
"description": "Provide a reference to a stored payment method",
"example": "187282ab-40ef-47a9-9206-5099ba31e432",
"nullable": true
},
"capture_on": {
"type": "string",
"format": "date-time",
"description": "A timestamp (ISO 8601 code) that determines when the payment should be captured.\nProviding this field will automatically set `capture` to true",
"example": "2022-09-10T10:11:12Z",
"nullable": true
},
"authentication_type": {
"allOf": [
{
"$ref": "#/components/schemas/PaymentMethod"
"$ref": "#/components/schemas/AuthenticationType"
}
],
"nullable": true
},
"description": {
"statement_descriptor_suffix": {
"type": "string",
"description": "A description of the payment",
"example": "It's my first payment request",
"description": "Provides information about a card payment that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor thats set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor.",
"example": "Payment for shoes purchase",
"nullable": true,
"maxLength": 255
},
"order_details": {
"type": "array",
"items": {
"$ref": "#/components/schemas/OrderDetailsWithAmount"
},
"description": "Information about the product , quantity and amount for connectors. (e.g. Klarna)",
"example": "[{\n \"product_name\": \"gillete creme\",\n \"quantity\": 15,\n \"amount\" : 900\n }]",
"nullable": true
},
"business_sub_label": {
"type": "string",
"description": "Business sub label for the payment",
"nullable": true
},
"email": {
@ -6666,6 +6578,38 @@
"example": "johntest@test.com",
"nullable": true,
"maxLength": 255
},
"payment_method": {
"allOf": [
{
"$ref": "#/components/schemas/PaymentMethod"
}
],
"nullable": true
},
"routing": {
"allOf": [
{
"$ref": "#/components/schemas/RoutingAlgorithm"
}
],
"nullable": true
},
"billing": {
"allOf": [
{
"$ref": "#/components/schemas/Address"
}
],
"nullable": true
},
"payment_method_data": {
"allOf": [
{
"$ref": "#/components/schemas/PaymentMethodData"
}
],
"nullable": true
}
}
},
@ -7540,34 +7484,42 @@
"description": "Limit on the number of objects to return",
"nullable": true
},
"created": {
"type": "string",
"format": "date-time",
"description": "The time at which refund is created",
"offset": {
"type": "integer",
"format": "int64",
"description": "The starting point within a list of objects",
"nullable": true
},
"created.lt": {
"type": "string",
"format": "date-time",
"description": "Time less than the refund created time",
"time_range": {
"allOf": [
{
"$ref": "#/components/schemas/TimeRange"
}
],
"nullable": true
},
"created.gt": {
"type": "string",
"format": "date-time",
"description": "Time greater than the refund created time",
"connector": {
"type": "array",
"items": {
"type": "string"
},
"description": "The list of connectors to filter refunds list",
"nullable": true
},
"created.lte": {
"type": "string",
"format": "date-time",
"description": "Time less than or equals to the refund created time",
"currency": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Currency"
},
"description": "The list of currencies to filter refunds list",
"nullable": true
},
"created.gte": {
"type": "string",
"format": "date-time",
"description": "Time greater than or equals to the refund created time",
"refund_status": {
"type": "array",
"items": {
"$ref": "#/components/schemas/RefundStatus"
},
"description": "The list of refund statuses to filter refunds list",
"nullable": true
}
}
@ -8066,6 +8018,25 @@
}
}
},
"TimeRange": {
"type": "object",
"required": [
"start_time"
],
"properties": {
"start_time": {
"type": "string",
"format": "date-time",
"description": "The start time to filter refunds list or to get list of filters. To get list of filters start time is needed to be passed"
},
"end_time": {
"type": "string",
"format": "date-time",
"description": "The end time to filter refunds list or to get list of filters. If not passed the default time is now",
"nullable": true
}
}
},
"UpdateApiKeyRequest": {
"type": "object",
"description": "The request body for updating an API Key.",
@ -8120,10 +8091,10 @@
{
"type": "object",
"required": [
"ali_pay_hk"
"ali_pay_hk_redirect"
],
"properties": {
"ali_pay_hk": {
"ali_pay_hk_redirect": {
"$ref": "#/components/schemas/AliPayHkRedirection"
}
}