Skip to content

Conversation

@erawat
Copy link
Member

@erawat erawat commented Nov 21, 2025

Overview

This PR introduces the Payment Processing Core extension, a foundational infrastructure layer for CiviCRM payment processors. It provides reusable database
entities and patterns that eliminate code duplication across multiple payment processor extensions (Stripe, GoCardless, Deluxe, etc.).

Before

N/A

After

The extension provides:

  • PaymentAttempt entity: Generic payment attempt tracking for all processors via API4
  • PaymentWebhook entity: Generic webhook event logging with deduplication via API4
  • Docker-based development environment: Consistent testing across CiviCRM versions
  • Code quality enforcement: PHPStan Level 9, PHPCS linting, automated CI workflows

Payment processor extensions can now depend on this core infrastructure instead of reimplementing common functionality.

@erawat
Copy link
Member Author

erawat commented Nov 21, 2025

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…support

**Critical bug fix:**
- Change unique index from `event_id` alone to composite `(event_id, processor_type)`
- Prevents cross-processor event ID collisions (e.g., Stripe's evt_123 vs GoCardless's evt_123)
- Ensures proper webhook deduplication in multi-processor environments

**Files changed:**
- xml/schema/CRM/Paymentprocessingcore/PaymentWebhook.xml: Updated index definition
- CRM/Paymentprocessingcore/DAO/PaymentWebhook.php: Regenerated DAO
- sql/auto_install.sql: Regenerated SQL schema

**Impact:**
Without this fix, the second processor to emit an event with the same ID
would fail to insert, breaking webhook logging and idempotency.
**Issue:**
PHPStan workflow was failing with:
"Path .../\$GITHUB_WORKSPACE/... does not exist"

**Fix:**
- Remove backslash escaping from \$GITHUB_WORKSPACE in HERE document
- Allow shell variable substitution to work properly in phpstan-ci.neon

**Root cause:**
The escaped \$GITHUB_WORKSPACE was being written literally instead of
being substituted with the actual GitHub workspace path during CI execution.
- Generated CRM/Paymentprocessingcore/Upgrader.php using civix
- Updated info.xml to register upgrader class
- Added composer install step to CI workflow

This fixes the 'DB Error: no such table' failures by ensuring
sql/auto_install.sql executes when extension is enabled.
@erawat erawat force-pushed the CIVIMM-423-core-code branch from 3f4cfaf to e8d53be Compare November 21, 2025 14:23
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces the Payment Processing Core extension, a foundational infrastructure layer that centralizes common payment processing functionality for CiviCRM payment processor extensions (Stripe, GoCardless, Deluxe, etc.). The extension provides reusable database entities for tracking payment attempts and webhook events, along with a comprehensive Docker-based development environment for testing across CiviCRM versions.

Key Changes:

  • Added PaymentAttempt and PaymentWebhook entities with API4 support for generic payment tracking across all processors
  • Implemented Docker-based development environment with configurable CiviCRM versions and automated testing infrastructure
  • Established code quality enforcement with PHPStan Level 9, PHPCS linting, and comprehensive CI workflows

Reviewed changes

Copilot reviewed 43 out of 46 changed files in this pull request and generated no comments.

Show a summary per file
File Description
xml/schema/CRM/Paymentprocessingcore/PaymentWebhook.xml Database schema for webhook event logging with deduplication via unique event_id/processor_type constraint
xml/schema/CRM/Paymentprocessingcore/PaymentAttempt.xml Database schema for payment attempt tracking with foreign key relationships to contributions, contacts, and payment processors
CRM/Paymentprocessingcore/BAO/PaymentWebhook.php Business logic for webhook event deduplication and idempotency checks
CRM/Paymentprocessingcore/BAO/PaymentAttempt.php Business logic for payment attempt CRUD operations and lookup methods
Civi/Paymentprocessingcore/Utils/PaymentUrlBuilder.php Utility class for building payment processor redirect URLs (success/cancel/error)
tests/phpunit/*.php Comprehensive test coverage for PaymentAttempt and PaymentWebhook entities via API4 and BAO layers
scripts/*.sh Docker-based development scripts for setup, testing, linting, and static analysis
.github/workflows/*.yml CI workflows for automated testing, linting, and PHPStan analysis
docker-compose.*.yml Docker configurations for test, linting, and PHPStan environments
info.xml Extension metadata defining CiviCRM 6.4+ compatibility and PSR-4/PSR-0 autoloading
CLAUDE.md Comprehensive development guide for AI-assisted coding with project standards and workflows

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@erawat erawat merged commit 0fb8374 into master Nov 24, 2025
3 checks passed
@erawat erawat deleted the CIVIMM-423-core-code branch November 24, 2025 15:47
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.

3 participants