Payment Methods#
Payment Methods represent your tenant's payment instruments. CasaPay supports cards, open banking, direct debit, and bank transfers.
The Payment Method object#
| Attribute | Type | Description |
|---|---|---|
id | string | Unique identifier with pm_ prefix |
object | string | Always "payment_method" |
type | enum | card, open_banking, direct_debit, bank_transfer |
customer | string | Attached Customer ID |
billing_details | object | Billing information |
card | object | Card details (when type is card) |
card.brand | string | Card brand: visa, mastercard, amex |
card.last4 | string | Last four digits |
card.exp_month | integer | Expiration month |
card.exp_year | integer | Expiration year |
direct_debit | object | Direct debit details |
direct_debit.scheme | string | bacs, sepa, ach |
direct_debit.last4 | string | Last 4 of account number |
open_banking | object | Open banking details |
open_banking.institution | string | Institution identifier |
metadata | hash | Key-value pairs |
created | timestamp | Time 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
| Parameter | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Payment method type |
card | object | Conditional | Card details (for card type) |
direct_debit | object | Conditional | Direct debit details |
billing_details | object | No | Billing 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
| Parameter | Type | Required | Description |
|---|---|---|---|
customer | string | Yes | Customer 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"