Skip to content

The Payment Object

A Payment represents a single payment transaction. It tracks the lifecycle from creation through completion or failure.

Attributes

id string

Unique identifier for the payment. Always starts with pay_.

object string

Always "payment".

amount integer

Amount in smallest currency unit (cents for MYR). For example, RM 100.00 is represented as 10000.

currency string

Three-letter ISO currency code (e.g., myr, usd).

status string

Current payment status. See status values below.

payment_method string

ID of the PaymentMethod used for this payment.

customer string | null

ID of the Customer this payment belongs to, if any.

description string | null

An arbitrary string describing the payment.

metadata object

Custom key-value pairs (up to 50 pairs).

captured boolean

Whether the payment has been captured. Only applicable when capture_method=manual.

refunded boolean

Whether the payment has been fully or partially refunded.

refunded_amount integer

Total amount that has been refunded (in cents).

receipt_email string | null

Email address to send the receipt to.

receipt_url string | null

URL to view the receipt.

client_secret string

Client secret for confirming the payment on the client side.

next_action object | null

If the payment requires additional action (e.g., 3D Secure), this object contains details.

last_payment_error object | null

Details about the most recent failed payment attempt.

created integer

Unix timestamp of when the payment was created.

livemode boolean

Whether this is a live mode payment (true) or test mode (false).

Status Values

StatusDescription
requires_payment_methodPayment needs a payment method to be attached
requires_confirmationPayment needs to be confirmed
requires_actionCustomer action needed (e.g., 3D Secure authentication)
processingPayment is being processed
succeededPayment completed successfully
failedPayment failed
canceledPayment was canceled

Status Flow

requires_payment_method

requires_confirmation

    processing  ←------ requires_action
         ↓                    ↓
    succeeded            (customer action)
         or
      failed

Example Object

json
{
  "id": "pay_1234567890abcdef",
  "object": "payment",
  "amount": 10000,
  "currency": "myr",
  "status": "succeeded",
  "payment_method": "pm_1234567890abcdef",
  "customer": "cus_1234567890abcdef",
  "description": "Order #12345",
  "metadata": {
    "order_id": "12345",
    "customer_name": "John Doe"
  },
  "captured": true,
  "refunded": false,
  "refunded_amount": 0,
  "receipt_email": "customer@example.com",
  "receipt_url": "https://pay.salam.com/receipts/pay_xxxxx",
  "client_secret": "pay_xxxxx_secret_xxxxx",
  "next_action": null,
  "last_payment_error": null,
  "created": 1704067200,
  "livemode": false
}

Released under the MIT License.