Skip to content

Field naming inconsistency: last_4 in webhooks vs last4 in API responses #297

@shahzaibm10c

Description

@shahzaibm10c

Field naming inconsistency: last_4 in webhooks vs last4 in API responses

Environment

  • Checkout SDK version: N/A (API inconsistency)
  • Platform and version: PHP 8.x
  • Operating System and version: All platforms

Description

Checkout.com uses inconsistent field names for card's last four digits:

  • Webhook events use last_4 (with underscore)
  • REST API responses use last4 (no underscore)

Expected behavior

Field name should be consistent across all endpoints - either last4 or last_4 everywhere.

Current behavior

Webhook event (card_verified):

"source" => [
  "last_4" => "0018"  // With underscore
]

API response (GET /payments/{id}):

"source" => [
  "last4" => "0018"  // No underscore
]

Steps to reproduce

  1. Receive a card_verified webhook - observe last_4 field
  2. Call GET /payments/{id} - observe last4 field
  3. Note the inconsistency

Possible solution

Standarize on one naming convention (preferably last_4 with underscore) across all endpoints. Provide deprecation period for the old field name.

Current workaround required:

$lastFour = $data['last_4'] ?? $data['last4'] ?? null;

Additional information

This affects all integrations using both webhooks and REST API. All other card fields (expiry_month, fingerprint, etc.) are consistent - only last4/last_4 has this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions