Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.monei.cc/llms.txt

Use this file to discover all available pages before exploring further.

Overview

monei.payment_method provides methods to save and manage cards or bank accounts for fast repeat deposits.
Note: All methods return response objects with attributes accessible via dot notation (e.g., pm.id, pm.last4).

List Payment Methods

payment_methods_response = monei.payment_method.get_all("sub-wallet-id")
payment_methods = payment_methods_response.payment_methods

print(payment_methods)

Add a Payment Method

pm = monei.payment_method.create(
    type="card",
    card_number="4111111111111111",
    expiry_month="12",
    expiry_year="2027",
    cvv="123",
    sub_wallet_id="sub-wallet-id"
)

print(pm)

Get Payment Method Details

pm = monei.payment_method.get("pm-id")

print(pm)

Set Default Payment Method

monei.payment_method.set_default("pm-id")

Delete a Payment Method

monei.payment_method.delete("pm-id")

Working with Response Objects

All methods return objects with attribute access:
# List payment methods response
payment_methods_response = monei.payment_method.get_all("sub-wallet-id")
for pm in payment_methods_response.payment_methods:
    print(pm.id)              # Payment method ID
    print(pm.type)            # 'card' | 'bank_account'
    print(pm.last4)           # Last 4 digits
    print(pm.expiry_month)    # Expiry month (for cards)
    print(pm.expiry_year)     # Expiry year (for cards)
    print(pm.bank_name)       # Bank name (for bank accounts)
    print(pm.account_name)    # Account name (for bank accounts)
    print(pm.is_default)      # Whether it's the default method
    print(pm.created_at)      # Creation date

# Create payment method response
pm = monei.payment_method.create(
    type="card",
    card_number="4111111111111111",
    expiry_month="12",
    expiry_year="2027",
    cvv="123",
    sub_wallet_id="sub-wallet-id"
)
print(pm.id)              # Payment method ID
print(pm.type)            # Payment method type
print(pm.last4)           # Last 4 digits of card
print(pm.expiry_month)    # Expiry month
print(pm.expiry_year)     # Expiry year
print(pm.is_default)      # Default status

# Get payment method details response
pm = monei.payment_method.get("pm-id")
print(pm.id)              # Payment method ID
print(pm.type)            # Payment method type
print(pm.last4)           # Last 4 digits
print(pm.expiry_month)    # Expiry month (for cards)
print(pm.expiry_year)     # Expiry year (for cards)
print(pm.bank_name)       # Bank name (for bank accounts)
print(pm.account_name)    # Account name (for bank accounts)
print(pm.is_default)      # Default status
print(pm.created_at)      # Creation date

# Set default response (no data returned, just success)
monei.payment_method.set_default("pm-id")
print("Default payment method updated successfully")

# Delete response (no data returned, just success)
monei.payment_method.delete("pm-id")
print("Payment method deleted successfully")

Response Types

PaymentMethodDto

{
    "id": str,
    "type": "card" | "bank_account",
    "last4": str,
    "expiry_month": str | None,    # For cards
    "expiry_year": str | None,     # For cards
    "bank_name": str | None,       # For bank accounts
    "account_name": str | None,    # For bank accounts
    "is_default": bool,
    "created_at": str
}

PaymentMethodsListDto

{
    "payment_methods": [PaymentMethodDto]
}

Error Handling

All payment method calls may raise an exception if the request fails.
from monei import MoneiError

try:
    payment_methods_response = monei.payment_method.get_all("sub-wallet-id")
    for pm in payment_methods_response.payment_methods:
        print(pm.id)
except MoneiError as err:
    print(err.status_code)  # HTTP status code
    print(err.message)      # Error message
    print(err.code)         # Error code

Service Overview

MethodDescription
get_all(sub_wallet_id)List all payment methods for a wallet
create(type, card_number, expiry_month, expiry_year, cvv, sub_wallet_id)Add a new payment method
get(payment_method_id)Get payment method details
set_default(payment_method_id)Set a payment method as default
delete(payment_method_id)Delete a payment method

Notes

  • All methods require a properly configured MoneiClient instance with authentication
  • sub_wallet_id is required for listing payment methods
  • Card details are tokenized and securely stored
  • Only the last 4 digits of card numbers are returned for security
  • Setting a default payment method automatically updates the previous default
  • Deleted payment methods cannot be recovered
  • All responses are strongly typed objects with attribute access