Payment Methods#

Payment Methods represent your tenant's payment instruments. CasaPay supports cards, open banking, direct debit, and bank transfers.

The Payment Method object#

AttributeTypeDescription
idstringUnique identifier with pm_ prefix
objectstringAlways "payment_method"
typeenumcard, open_banking, direct_debit, bank_transfer
customerstringAttached Customer ID
billing_detailsobjectBilling information
cardobjectCard details (when type is card)
card.brandstringCard brand: visa, mastercard, amex
card.last4stringLast four digits
card.exp_monthintegerExpiration month
card.exp_yearintegerExpiration year
direct_debitobjectDirect debit details
direct_debit.schemestringbacs, sepa, ach
direct_debit.last4stringLast 4 of account number
open_bankingobjectOpen banking details
open_banking.institutionstringInstitution identifier
metadatahashKey-value pairs
createdtimestampTime at which the object was created
{
  "id": "pm_card_visa",
  "object": "payment_method",
  "type": "card",
  "customer": "cus_123456789",
  "billing_details": {
    "name": "Jane Doe",
    "email": "jane@example.com"
  },
  "card": {
    "brand": "visa",
    "last4": "4242",
    "exp_month": 12,
    "exp_year": 2027,
    "funding": "credit"
  },
  "created": 1706140800
}

Create a Payment Method#

POST /v1/payment_methods

ParameterTypeRequiredDescription
typestringYesPayment method type
cardobjectConditionalCard details (for card type)
direct_debitobjectConditionalDirect debit details
billing_detailsobjectNoBilling information
curl https://api.casapay.com/v1/payment_methods \
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "card",
    "card": {
      "number": "4242424242424242",
      "exp_month": 12,
      "exp_year": 2027,
      "cvc": "123"
    },
    "billing_details": { "name": "Jane Doe" }
  }'

Retrieve, Update, List#

GET /v1/payment_methods/:id

POST /v1/payment_methods/:id

GET /v1/payment_methods?customer=cus_123456789&type=card


Attach a Payment Method#

Attaches a Payment Method to a Customer.

POST /v1/payment_methods/:id/attach

ParameterTypeRequiredDescription
customerstringYesCustomer ID
curl -X POST https://api.casapay.com/v1/payment_methods/pm_card_visa/attach \
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc" \
  -H "Content-Type: application/json" \
  -d '{"customer": "cus_123456789"}'

Detach a Payment Method#

Detaches a Payment Method from a Customer.

POST /v1/payment_methods/:id/detach

curl -X POST https://api.casapay.com/v1/payment_methods/pm_card_visa/detach \
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc"