Skip to content

Conversation

@vuckro
Copy link
Contributor

@vuckro vuckro commented Aug 5, 2025

Problem

The gateway_customer_id field in inc/api/schemas/membership-update.php was defined as integer type, causing API validation errors when updating memberships with Stripe customer IDs.

Symptoms

  • Membership update API requests failing with type validation errors
  • Stripe customer IDs are strings (e.g., cus_1234567890abcdef) but schema expected integers
  • Payment gateway integrations broken due to type mismatch

Root Cause

File: inc/api/schemas/membership-update.php (line ~47)

'gateway_customer_id' => array(
    'description' => __('Gateway Customer ID.', 'wp-ultimo'),
    'type'        => 'integer', // ❌ Incorrect - causes validation failures
),

Most payment gateways (Stripe, PayPal, etc.) use alphanumeric string IDs, not integers.

Solution

Changed the field type from integer to string:

'gateway_customer_id' => array(
    'description' => __('Gateway Customer ID.', 'wp-ultimo'),
-   'type'        => 'integer',
+   'type'        => 'string',
),

Benefits

  • Stripe compatibility: Accepts customer IDs like cus_1234567890abcdef
  • Gateway flexibility: Works with PayPal, Square, and other processors
  • Backward compatibility: PHP auto-converts existing integer IDs to strings
  • API standards: Aligns with REST API best practices

Testing

  • Verified with real Stripe customer IDs
  • Tested membership update endpoints
  • Confirmed backward compatibility with existing data
  • No breaking changes detected

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

…ate schema

The API returns "Bad request - Invalid parameter(s): gateway_customer_id" because
the schema defines gateway_customer_id as integer type instead of string.

Gateway customer IDs are typically strings rather than integers in most payment
gateways, so this change fixes API validation errors when passing gateway customer IDs.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Collaborator

@superdav42 superdav42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit: !

@superdav42 superdav42 merged commit 7191156 into Multisite-Ultimate:main Aug 7, 2025
0 of 18 checks passed
@vuckro vuckro deleted the fix/api/stripe-gateway-customer-id-type branch August 7, 2025 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants