PaymentIntents#

A PaymentIntent guides you through the process of collecting a payment from your tenant. It tracks a payment from creation through checkout, and triggers additional authentication steps when required.

The PaymentIntent object#

AttributeTypeDescription
idstringUnique identifier with pi_ prefix
objectstringAlways "payment_intent"
amountintegerAmount in smallest currency unit
currencystringThree-letter ISO 4217 currency code
statusenumSee status flow below
customerstringCustomer ID
payment_methodstringPayment Method ID
payment_method_typesarrayAllowed payment method types
descriptionstringDescription of the payment
client_secretstringSecret for client-side confirmation
capture_methodenumautomatic or manual
confirmation_methodenumautomatic or manual
amount_receivedintegerAmount actually received
chargeslistList of Charge objects
last_payment_errorobjectLast payment error, if any
next_actionobjectNext action required (redirect, etc.)
metadatahashKey-value pairs
createdtimestampTime at which the object was created
livemodebooleanWhether this is a live mode object

Status Flow#

requires_payment_method → requires_confirmation → requires_action → processing → requires_capture → succeeded
                                                                                                   ↘ canceled
{
  "id": "pi_1a2b3c4d",
  "object": "payment_intent",
  "amount": 120000,
  "currency": "eur",
  "status": "requires_payment_method",
  "customer": "cus_123456789",
  "payment_method": null,
  "payment_method_types": ["card", "open_banking", "direct_debit"],
  "description": "Rent payment — February 2025",
  "client_secret": "pi_1a2b3c4d_secret_xyz789",
  "capture_method": "automatic",
  "amount_received": 0,
  "metadata": {
    "property_id": "prop_456",
    "period": "2025-02"
  },
  "created": 1706140800,
  "livemode": false
}

Create a PaymentIntent#

POST /v1/payment_intents

ParameterTypeRequiredDescription
amountintegerYesAmount in smallest currency unit
currencystringYesISO 4217 currency code
customerstringNoCustomer ID
payment_methodstringNoPayment Method ID to use
payment_method_typesarrayNoAllowed types (default: ["card"])
descriptionstringNoPayment description
capture_methodstringNoautomatic (default) or manual
confirmbooleanNoImmediately confirm (default: false)
return_urlstringNoURL for redirect-based payment methods
metadatahashNoKey-value pairs
curl https://api.casapay.com/v1/payment_intents \
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 120000,
    "currency": "eur",
    "customer": "cus_123456789",
    "payment_method_types": ["card", "open_banking", "direct_debit"],
    "description": "Rent payment — February 2025"
  }'
{
  "id": "pi_1a2b3c4d",
  "object": "payment_intent",
  "amount": 120000,
  "currency": "eur",
  "status": "requires_payment_method",
  "client_secret": "pi_1a2b3c4d_secret_xyz789",
  "created": 1706140800
}

Retrieve a PaymentIntent#

GET /v1/payment_intents/:id

curl https://api.casapay.com/v1/payment_intents/pi_1a2b3c4d \
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc"

Update a PaymentIntent#

POST /v1/payment_intents/:id

ParameterTypeDescription
amountintegerUpdated amount
currencystringUpdated currency
descriptionstringUpdated description
payment_methodstringAttach a payment method
metadatahashUpdated metadata
curl https://api.casapay.com/v1/payment_intents/pi_1a2b3c4d \
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc" \
  -H "Content-Type: application/json" \
  -d '{"amount": 125000, "description": "Rent + parking — February 2025"}'

List PaymentIntents#

GET /v1/payment_intents

ParameterTypeDescription
customerstringFilter by customer
statusstringFilter by status
created[gte]timestampCreated on or after
created[lte]timestampCreated on or before
limitintegerNumber of objects (1–100)
starting_afterstringCursor for pagination
curl "https://api.casapay.com/v1/payment_intents?customer=cus_123456789&limit=10" \
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc"

Confirm a PaymentIntent#

Confirms a PaymentIntent with a payment method, triggering the payment flow.

POST /v1/payment_intents/:id/confirm

ParameterTypeDescription
payment_methodstringPayment Method ID
return_urlstringURL for redirect-based methods
curl -X POST https://api.casapay.com/v1/payment_intents/pi_1a2b3c4d/confirm \
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc" \
  -H "Content-Type: application/json" \
  -d '{
    "payment_method": "pm_card_visa",
    "return_url": "https://your-app.com/payment/complete"
  }'

Cancel a PaymentIntent#

POST /v1/payment_intents/:id/cancel

ParameterTypeDescription
cancellation_reasonstringduplicate, fraudulent, requested_by_customer, abandoned
curl -X POST https://api.casapay.com/v1/payment_intents/pi_1a2b3c4d/cancel \
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc" \
  -H "Content-Type: application/json" \
  -d '{"cancellation_reason": "requested_by_customer"}'

Capture a PaymentIntent#

Captures a PaymentIntent that was created with capture_method: manual.

POST /v1/payment_intents/:id/capture

ParameterTypeDescription
amount_to_captureintegerAmount to capture (partial capture)
curl -X POST https://api.casapay.com/v1/payment_intents/pi_1a2b3c4d/capture \
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc"