Skip to main content

Overview

This endpoint retrieves all payment methods associated with the authenticated user’s account. Payment methods can include bank transfers, mobile payments, and other payment options configured by the user.

Authentication

This endpoint requires authentication via the verifyToken middleware. Include a valid JWT token in the Authorization header.

Endpoint

GET
endpoint
/api/payments-methods

Request

Headers

Authorization
string
required
Bearer token for authentication
Authorization: Bearer YOUR_JWT_TOKEN

Example Request

curl -X GET http://localhost:3001/api/payments-methods \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json"

Response

Success Response (200 OK)

Returns an array of payment method objects associated with the authenticated user.
id
integer
Unique identifier for the payment method
user_id
integer
ID of the user who owns this payment method
type
string
Type of payment method (e.g., “bank_transfer”, “mobile_payment”, “email_payment”)
ci
string
National identification number (CI - Cédula de Identidad) associated with the payment method
bank
string
Bank name for bank transfer payment methods
phone
string
Phone number for mobile payment methods
owner_name
string
Name of the payment method owner
mail_pay
string
Email address for email-based payment methods

Example Response

[
  {
    "id": 1,
    "user_id": 42,
    "type": "bank_transfer",
    "ci": "12345678",
    "bank": "Banco Nacional",
    "phone": null,
    "owner_name": "Juan Pérez",
    "mail_pay": null
  },
  {
    "id": 2,
    "user_id": 42,
    "type": "mobile_payment",
    "ci": "12345678",
    "bank": null,
    "phone": "+58 412-1234567",
    "owner_name": "Juan Pérez",
    "mail_pay": null
  },
  {
    "id": 3,
    "user_id": 42,
    "type": "email_payment",
    "ci": "12345678",
    "bank": null,
    "phone": null,
    "owner_name": "Juan Pérez",
    "mail_pay": "[email protected]"
  }
]

Error Responses

Implementation Details

  • Controller: paymentsController.allPaymentMethods
  • Middleware: verifyToken (authentication required)
  • Database Query: Retrieves all records from payment_methods table filtered by authenticated user’s ID
  • User Context: The user ID is extracted from the JWT token via req.user.id

Use Cases

  • Display all payment methods in user profile settings
  • Allow users to select a payment method for currency exchange transactions
  • Manage and review configured payment options
  • Validate available payment methods before initiating a transaction

Build docs developers (and LLMs) love