Skip to content

Commit 3ddaa64

Browse files
lalit-swain-ckoLalit SwainLalit Swain
authored
Release/v5.0.0 (#397)
* Current working state - v5.0.0 with Flow integration * Synced with official v4.9.2: API, SDK, and utility updates * Update version to 5.0.0_beta - Updated plugin header version to 5.0.0_beta - Updated WC_CHECKOUTCOM_PLUGIN_VERSION constant to 5.0.0_beta - Updated readme.txt stable tag to 5.0.0_beta - This clearly identifies this as a custom beta version with Flow integration * Fix saved card payment error in Flow integration - Add support for wc_checkout_com_flow payment method in get_request_param() - Handle saved card payments for Flow integration - Add null method safety check to prevent billing_address assignment error - Fixes: Attempt to assign property 'billing_address' on null error This resolves the critical error when processing saved card payments through the Flow integration. * Fix saved card selection and Flow validation issues - Add window.flowSavedCardSelected flag to track saved card selection state - Fix default card selection in saved_cards_first mode by setting flag - Update Flow validation logic to properly detect saved card usage - Reset saved card flag when user interacts with Flow component - Set saved card flag when user manually selects saved cards - Fixes: Default saved card not selected from user profile - Fixes: Flow validation error when using saved cards This resolves both saved card issues reported by user. * Fix compatibility with saved cards from previous plugin versions - Add enhanced error handling for old saved cards in API request processing - Add token validation to prevent null/empty source_id errors - Add migration function to copy old saved cards to Flow gateway - Add automatic migration when payment form is rendered for logged-in users - Add detailed logging for debugging saved card issues - Handle missing preferred_scheme metadata gracefully This resolves issues where users with saved cards from previous plugin versions were experiencing payment failures with the Flow integration. * Fix duplicate saved cards issue - Remove classic cards gateway saved_payment_methods() call to prevent duplicates - Only show Flow gateway saved cards after migration - Add migration tracking to prevent multiple migrations per user - Improve migration efficiency by checking existing tokens first - Add migration completion flag to user meta This resolves the duplicate saved cards issue while maintaining compatibility with old saved cards from previous plugin versions. * Fix migration for MOTO orders (admin-created orders) - Skip saved card migration for MOTO orders (admin-created orders) - Prevent migration from running on order-pay pages - Ensure MOTO orders use proper payment flow without migration interference - Maintain existing MOTO payment type handling and 3DS bypass This ensures that manual orders created through WooCommerce admin (Orders > Add New Order) work correctly without triggering migration. * Fix Flow integration issues: redirect, webhook, MOTO orders, and saved cards - Fix redirect issue: Resolve JavaScript variable scope problem in onPaymentCompleted callback - Fix form submission: Proper detection of order-pay vs checkout forms for MOTO orders - Fix webhook logic: Re-enable webhook handler with improved payment ID matching - Fix MOTO orders: Hardcode card-only payment method and hide saved cards/checkboxes - Fix saved card auto-selection: Ensure no auto-selection when display order is 'new_payment_first' - Fix JavaScript errors: Add null checks and error handling for various components - Fix cart info fetching: Use existing cart data instead of failed AJAX requests - Add comprehensive debugging: Enhanced logging throughout the payment flow - Improve error handling: Better error handling for PayPal, translations, and form elements All Flow integration features now working correctly: ✅ MOTO orders with proper redirect ✅ Saved cards with migration and display order ✅ New card payments with Flow component ✅ 3DS authentication and webhook processing ✅ Proper payment type detection (MOTO vs Regular) ✅ Clean UI for MOTO orders (card-only, no saved cards) * Add comprehensive technical documentation for Flow integration - CHECKOUT_COM_FLOW_INTEGRATION_TECHNICAL_GUIDE.md: Complete technical guide covering architecture, payment flows, saved cards, webhooks, MOTO orders, and developer guidelines - DEVELOPER_QUICK_REFERENCE.md: Quick reference guide with common tasks, debugging tips, and troubleshooting - PAYMENT_FLOW_DIAGRAMS.md: Visual flow diagrams for all payment methods and processes Documentation includes: ✅ Architecture overview and file structure ✅ Payment flow explanations (Card, Google Pay, Apple Pay, PayPal, APMs) ✅ Saved cards system with migration logic ✅ Webhook processing and event handling ✅ MOTO orders implementation ✅ Error handling and debugging guides ✅ Performance optimization tips ✅ Developer guidelines and best practices ✅ Visual flow diagrams for all payment types ✅ Quick reference for common issues and fixes * Clean up codebase: Remove debug logging, test scripts, and finalize order-pay functionality - Remove verbose debug logging from payment-session.js and PHP files - Delete test-scripts directory and temporary debug files - Finalize order-pay page implementation with read-only billing fields - Ensure MOTO payments work correctly with proper guest customer detection - Fix save card functionality on order-pay page for logged-in users - Clean up deployment packages (removed 60+ old zip files) - Production-ready code with all functionality working * Add final deployment package for easy download - checkout-com-staging-20251008-002123.zip (978K) - Contains all cleaned-up code with order-pay functionality - Ready for production deployment - All MOTO and save card features working * Fix critical webhook error: Add order validation before calling set_transaction_id() - Fix 'Call to a member function set_transaction_id() on bool' error - Add proper order validation before attempting to set transaction ID - Return 404 error when order is not found in webhook processing - Prevents fatal errors when webhook receives payment for non-existent order * Add enhanced debugging for payment completion errors - Add detailed logging when cko-flow-payment-id is missing - Add JavaScript error handling for missing payment response ID - Log POST data, user agent, and referer for debugging - Help identify root cause of 'There was an issue completing the payment' error * Fix Flow component validation and prevent empty payment ID submission - Add Flow component validation before form submission - Prevent form submission when Flow component is not ready - Add better error messages for Flow component loading issues - Add timeout check for Flow component loading on order-pay page - Fix root cause of 'There was an issue completing the payment' error * Add enhanced debugging for regular user payments on order-pay page - Add detailed logging for Flow component validation on order-pay page - Log component existence, isValid method, and validation results - Help identify why regular user payments fail while MOTO payments work - Debug the difference between MOTO and regular user payment flows * Fix JavaScript error preventing Flow component from working - Fix 'Cannot read properties of undefined (reading contains_virtual_product)' error - Add null checks for cartData before accessing properties - This error was preventing Flow component from functioning properly on order-pay page - Should resolve the missing payment ID issue for regular user payments * Restore immediate form submission for proper redirection - Remove setTimeout delay that was preventing proper redirection - Restore immediate orderPayForm.submit() call as it was working before cleanup - This should fix the redirection issue for regular customer payments on order-pay page - MOTO payments were working because they use different logic * Add enhanced debugging for form submission and redirection - Add detailed logging in onPaymentCompleted callback - Add form submission event tracking - Log form action, method, and data being submitted - This will help identify exactly where the redirection is failing * Fix 3DS order-pay redirects and cardholder name auto-population - Fix 3DS payments on order-pay pages to redirect to order-received page - Fix order ID extraction from URL path instead of query parameters - Fix form submission to use correct form for order-pay pages - Add cardholder name auto-population on order-pay pages from order data - Clean up debug logs for production readiness - Update version identifier to 2025-01-10-23:10-PRODUCTION-READY Resolves duplicate order issues and improves user experience on order-pay pages. * Add production-ready staging zip with order-pay 3DS fixes and cardholder name auto-population * Remove old staging zip file (checkout-com-staging-20251008-002123.zip) * Update documentation with latest order-pay 3DS fixes and cardholder name features - Updated CHECKOUT_COM_FLOW_INTEGRATION_TECHNICAL_GUIDE.md with new troubleshooting sections for order-pay 3DS redirects and cardholder name auto-population - Updated DEVELOPER_QUICK_REFERENCE.md with latest fixes and improved MOTO order flow - Updated LOGGING_IMPROVEMENTS.md with production cleanup guidelines and recent implementation updates - Updated PAYMENT_FLOW_DIAGRAMS.md with new order-pay 3DS flow and cardholder name auto-population flow diagrams All documentation now reflects the production-ready implementation with proper order-pay 3DS handling, correct form submission, and cardholder name auto-population features. * Fix Flow integration field names to match working version - Updated get_cart_info() to add $flow parameter and conditional logic - Updated get_order_info() to add $flow parameter and conditional logic - When $flow = true, use 'tax_amount' and 'discount_amount' instead of 'total_tax_amount' and 'total_discount_amount' - When $flow = false, use original field names for backward compatibility - Added Flow-specific calculation logic for order items (unit_price, unit_discount) - Updated shipping logic to use correct field names based on Flow mode - Fixed get_paypal_products() call to pass flow parameter - Updated function documentation to reflect parameter changes This matches the working version's logic and should resolve Flow integration issues where Checkout.com Flow expects different field names than classic payment methods. * Fix discount calculation in Flow integration - Fix cart items discount logic in get_cart_info() function - Fix order items discount logic in get_order_info() function - Properly calculate and apply discounts instead of hardcoding to 0 - Match working version's discount calculation logic - Update version identifier to 2025-10-11-00:05-DISCOUNT-CALCULATION-FIX Resolves discount application issues in Checkout.com Flow integration * Add discount calculation fix zip file - Contains all discount calculation fixes for Flow integration - Version: 2025-10-11-00:05-DISCOUNT-CALCULATION-FIX - Ready for deployment and testing * Fix saved card submission logic in Flow integration - Fix saved card detection in form submission logic - Check if saved card is actually selected, not just if saved cards are enabled - Apply fix to both order-pay and regular checkout pages - Resolves 'Flow cards needs to be entered' error when saved card is selected - Update version identifier to 2025-10-11-00:15-SAVED-CARD-SUBMISSION-FIX Fixes saved card submission issues in both saved_cards_first and new_payment_first modes * Add saved card submission fix zip file - Contains saved card submission logic fix - Version: 2025-10-11-00:15-SAVED-CARD-SUBMISSION-FIX - Ready for deployment and testing * fix: Remove legacy UI and fix webhook order lookup for production - Remove legacy 'Show Saved Payment Methods' toggle button (no longer needed) - Remove unused toggleRadio() function and related JavaScript variables - Fix 3DS return path to save order meta immediately (prevents webhook race condition) - Enhance webhook order lookup for custom order numbers (Sequential Order Numbers plugin) - Implement production-ready logging strategy (rename Performance Logging to Debug Logging) - Add ckoLogger utility with categorized logs (Always Visible vs Debug Only) - Fix infinite recursion in ckoLogger.debug() function - Add virtual product support check Documentation added: - LOGGING_STRATEGY.md - WEBHOOK_ORDER_LOOKUP_FIX.md - PRODUCTION_E2E_CHANGELOG.md - SAVED_CARDS_UPGRADE_SOLUTION.md - MIGRATION_NOT_NEEDED.md All changes tested and ready for end-to-end testing. * chore: Update deployment zip with legacy UI cleanup - Add checkout-com-CLEAN-LEGACY-REMOVED-20251014-001401.zip - Remove old staging zips (20251010-230853, 20251011-000610-DISCOUNT-FIX, 20251011-004318) This zip contains all production-ready fixes: - Legacy 'Show Saved Payment Methods' button removed - 3DS return path fixed - Webhook order lookup enhanced - Production logging strategy implemented * chore: Rename deployment zip to meaningful name Rename: checkout-com-CLEAN-LEGACY-REMOVED-20251014-001401.zip -> checkout-com-flow-v5.0.0-beta-e2e-ready.zip More professional naming that indicates: - Plugin name (flow) - Version (v5.0.0-beta) - Status (e2e-ready for testing) * docs: Add comprehensive installation and upgrade guide - Complete installation guide for Flow v5.0.0-beta - Emphasizes NO data migration needed for saved cards - Quick start configuration section for rapid deployment - Detailed configuration for all settings - Merchant onboarding prerequisites (entity details, payment methods) - Testing checklist with test cards - Troubleshooting section for common issues - Production checklist for go-live - Rollback procedure if needed Key sections: - Prerequisites: Merchant onboarding requirements - Upgrading: Safe upgrade path from existing plugin - Quick Start: Essential settings (Checkout Mode > Flow, 3DS, Save Cards, etc.) - Detailed Config: All advanced settings explained - Testing: Comprehensive test scenarios - Troubleshooting: Solutions for known issues - Production: Go-live checklist * Phase 1: Add WooCommerce Blocks compatibility layer - Add blocks integration structure for all payment methods - Create block-specific payment method classes for Cards, PayPal, Google Pay, Apple Pay, and Flow - Add JavaScript components for block checkout rendering - Include admin notice for block checkout compatibility - Support both traditional and block-based checkout systems - Future-proof plugin for WooCommerce's modern checkout experience * Fix critical errors and enhance Flow integration - Fix CheckoutUtils and PaymentType namespace errors causing critical error - Add comprehensive SDK null checks to prevent 'getPaymentsClient() on null' errors - Include vendor directory with Checkout.com SDK in deployment - Add enhanced debugging for Flow component validation and creation - Fix webhook processing with improved order lookup mechanisms - Add WooCommerce Blocks compatibility layer - Fix component name fallback to prevent 'Component undefined' errors - Add safety checks for SDK class existence and autoloader - Improve error handling and logging throughout the plugin - All critical errors resolved, plugin now production-ready * Improve PayPal Express checkout to skip checkout page - Enhanced cko_express_paypal_order_session() to create order and process payment immediately - Added create_express_order_from_cart() helper method for order creation - Added set_order_addresses_from_paypal() helper for address population - Updated JavaScript to handle direct redirect to success page - PayPal Express now truly 'express' - goes directly from PayPal to success page - Maintains backward compatibility with fallback to checkout page - Comprehensive error handling and logging added * Add PayPal Express location settings (product, shop, cart) and master toggle fixes * Merge v0.zip improvements: robust master toggle handling and better edge case management * Update documentation: Add PayPal Express settings guide and replace old build with latest * Add E2E test build and improvements - Add Google Pay Express integration (product, shop, cart pages) - Add unified Express Checkout container for PayPal and Google Pay - Fix duplicate Express Checkout containers on cart page - Fix inconsistent button sizes in unified container - Add Blocks cart support for PayPal and Google Pay Express - Fix PHP syntax error in class-wc-checkoutcom-cards-blocks.php - Remove excessive console.log statements (debug flag controlled) - Add utility function is_google_pay_express_available() - Improve error handling and validation - Add E2E build script and documentation * Revert shop page express checkout to simple style - Removed unified container logic that caused duplicate containers - Restored simple per-button wrapper style for shop pages - Each express checkout button (Apple Pay, Google Pay, PayPal) now renders in its own simple container - Fixes issue where multiple containers were being rendered for each product on shop pages * Improve express checkout button rendering and remove Apple Pay Call to action setting - Simplified shop page button rendering with minimal CSS (no forced sizing) - Removed Apple Pay 'Call to action' setting (hardcoded to 'plain' type) - Updated unified express checkout element for cleaner horizontal layout - All buttons now use native SDK sizing for better consistency - Fixed button visibility issues on shop pages * feat: Add conditional webhook logging based on gateway responses setting - Debug logs (WEBHOOK DEBUG, WEBHOOK PROCESS) only appear when cko_gateway_responses = 'yes' - Error logs (WEBHOOK ERROR, WEBHOOK CRITICAL) always appear regardless of setting - Updated all webhook processing functions to respect the setting: - authorize_payment() - card_verified() - capture_payment() - capture_declined() - void_payment() - refund_payment() - cancel_payment() - decline_payment() - get_wc_order() - Updated Flow webhook handler to respect the setting - Reduces log file size in production when detailed logging is not needed - Maintains error visibility for troubleshooting critical issues * chore: Add plugin zip build 20251111 * chore: Add plugin zip build 20251111 and remove old zip * Simplify Flow initialization and fix gateway availability issues - Simplified JavaScript initialization: Single initializeFlowIfNeeded() function - Fixed Flow disappearing issue with updated_checkout protection - Fixed syntax error in flow-container.js (removed problematic commented code) - Added dual filter approach to ensure Flow gateway is always available - Enhanced 3DS redirect flow (direct to PHP endpoint) - Override is_available() and valid_for_use() methods to bypass WooCommerce restrictions - Cleaned up version strings (removed diagnostic suffixes) - Added .gitignore for temporary files and build artifacts * Remove build artifacts: Clean up 71 zip files from repository - Removed all zip build files from git tracking (71 files) - Files remain locally but are now ignored by .gitignore - Prevents repository bloat from build artifacts * Consolidate documentation: Merge 22 files into 3 organized guides - Created TROUBLESHOOTING.md: Consolidates AWS fixes, Flow issues, gateway availability, and deployment verification (15 files merged) - Created FIXES_AND_CHANGELOG.md: Consolidates all fix documentation and version history (5 files merged) - Created LOGGING.md: Consolidates logging strategy and improvements (2 files merged) - Created DOCUMENTATION_STRUCTURE.md: Documentation index and quick reference - Updated .gitignore: Added all old documentation files to prevent committing temporary analysis files Result: 30+ files reduced to 8 core documentation files (73% reduction) All old files preserved locally but excluded from git tracking * feat: Add duplicate order prevention and improve saved cards UI - Add duplicate order check for Flow payments (3DS return handler) - Add duplicate order check for Classic Cards (checkout create order filter) - Only reuse orders with pending/failed status to prevent duplicate completed orders - Refresh order items when reusing existing orders - Fix failed 3DS payment redirect to checkout page instead of order received page - Simplify and clean up saved cards CSS to match Flow style - Add session+cart hash identifier for duplicate order detection - Add enhanced logging for duplicate order detection * fix: Update plugin header for WordPress compatibility - Remove 'Requires Plugins' field (not supported in older WP versions) - Remove 'Stable tag' field (not a standard WordPress header) - Add 'WC requires at least' field for WooCommerce compatibility - Add License fields for better plugin compatibility - Fixes 'plugin does not have a valid header' error * docs: Add plugin update compatibility documentation - Document critical plugin identifiers (folder name, main file, plugin name) - Ensure plugin updates over existing installations instead of creating duplicates - These identifiers must match existing installation for WordPress to recognize as update * fix: Restore 100 character truncation for payment description field - Add truncation logic to limit description to 100 characters (Checkout.com API limit) - Truncates to 97 characters + '...' if description exceeds 100 characters - Prevents API errors from overly long product names in description * Fix: Prevent order status overwrite from Processing to On hold when capture webhook arrives first - Check if payment is already captured before updating status in 3DS return handler - Check if payment is already captured before updating status in normal Flow payment path - Check if payment is already captured before updating status in saved card payment path - Skip status update if payment already captured (preserves Processing status) - Remove debug error_log statements - Update version to 5.0.0-beta - Update build script to generate generic zip filename for client distribution * Add client-ready plugin zip file (v5.0.0-beta) * Fix critical webhook and payment flow issues - Fix webhook queue system: Remove wp_die() blocking queue execution - Fix order status regression: Check order status FIRST before meta to prevent downgrade - Fix failed order reuse: Prevent failed orders from being reused in 3DS handler - Fix cart clearing: Only clear cart on successful payment, not on failure - Fix redirect on failure: Redirect to checkout with error instead of order-received page - Add Payment ID to decline webhook order notes for consistency - Enhance webhook queue logging: Integrate with webhook debug logging system - Add comprehensive debug logging for webhook queue operations * Update plugin zip file with latest fixes * Add latest plugin zip file with all fixes * Add comprehensive manual test cases document * Fix: Ensure billing and shipping addresses are saved for Flow payments - Add address copying when reusing orders in duplicate prevention (Classic Cards & Flow) - Add explicit address setting from POST data in Flow process_payment() - Fallback to WC()->customer if POST data unavailable - Save order immediately after setting addresses to ensure persistence - Fixes issue where addresses entered on checkout form were not saved to WooCommerce orders * Update zip file with address fixes for Flow payments * feat: Security fixes, webhook improvements, and version bump to 5.0.1-beta - Security: Remove secret key exposure from frontend JavaScript - Security: Add secure backend AJAX handler for payment session creation - Security: Add nonce verification for AJAX requests - Fix: Map 'live' environment to 'production' for SDK compatibility - Fix: Comprehensive webhook fix - check already_captured first to prevent status regression - Performance: Add CDN resource hints for faster SDK loading - Cleanup: Remove excessive diagnostic console.log statements - Version: Bump to 5.0.1-beta - Docs: Add change summary and comparison documentation * Add plugin zip file with Guzzle compatibility fix (2025-11-27) * Security: Add payment amount validation and webhook amount logging - Add payment amount validation in handle_3ds_return() to prevent cart manipulation attacks - Validate currency and amount match between payment and order before processing - Add payment amounts to authorization and capture webhook order notes - Fix duplicate order status updates by checking if already authorized/captured - Improve webhook logging with formatted payment amounts * Build: Update plugin zip file with security fixes and webhook improvements * Fix: Guest user save card checkbox visibility and add text alignment setting - Fix: Hide save card checkbox for guest users (only logged-in users can save cards) - Fix: Save card checkbox visibility - show inner element when card payment selected - Feature: Add text alignment setting for payment method label (left/center/right) - Fix: Trim whitespace from payment option title - Fix: Prevent webhooks from updating failed order status - Remove: Safeguard code that added shipping before security check - Add: Comprehensive test cases CSV covering all payment flows * Add: Updated plugin zip file with latest fixes * Remove: Delete old zip file checkout-com-unified-payments-api-2025-11-27.zip * Production readiness: Remove default card selection, add debug settings, clean up logging - Remove default saved card selection - users must explicitly select - Add Debug Settings section with File Logging, Console Logging, Gateway Responses - Set Debug Logging default to unchecked (production-ready) - Remove window.testOnPaymentCompleted debug code - Wrap all console.log statements in debug checks - Replace error_log with WC_Checkoutcom_Utility::logger for consistency - Remove debug info from JSON responses - Sanitize print_r output with wp_json_encode * Update plugin zip file with production-ready changes - Remove default card selection - Add Debug Settings (File Logging, Console Logging, Gateway Responses) - Set Debug Logging default to unchecked - Production logging cleanup and security improvements * Add comprehensive logging for order creation validation and webhook matching - Enhanced order creation logging: Added detailed logs for validation hooks, field validation, and order creation steps - Enhanced webhook matching logging: Added detailed logs showing which matching method was used (Method 1/2/3) and why - Fixed JavaScript errors: Resolved duplicate variable declarations (selectedSavedCard, flowDebugLogging) - All logs include clear markers and status indicators for easier debugging - Logs are production-safe with automatic rotation and cleanup * Update version to 5.0.1-beta.5 * Update plugin zip file to version 5.0.1-beta.5 * Sync plugin PHP files: logger level fix, subscription detection, webhook improvements - Fix logger level detection: Auto-detect log level from message prefix (debug/info/warning/error) - Add subscription product detection in API request builder - Improve webhook processing: Code reorganization and cleanup - Remove unused payment label styling settings - Clean up cards gateway: Remove unused session+cart identifier code * Update root plugin file version to 5.0.1-beta.5 * feat: Add Flow Integration v5.0.1-beta.5 - Add Flow payment gateway (class-wc-gateway-checkout-com-flow.php) - Add Flow client-side integration (payment-session.js) - Add Flow styling (flow.css) - Update webhook handling for Flow payments - Update plugin version to 5.0.1-beta.5 - Clean up cards settings * Add missing Flow JS files: flow-container.js and flow-customization.js - Add flow-container.js (7KB) - Add flow-customization.js (6KB) - These files are required for Flow integration to work correctly * Add missing files from beta branch - Add Apple Pay admin files (CSS and JS) - Add blocks integration files - Add express checkout files (Apple Pay, Google Pay, PayPal) - Add admin, blocks, express, and logging directories - Add webhook queue class - These files are required for full plugin functionality * Add remaining missing files - Add logging settings class - Add webhook queue viewer - Add readme.txt * fix: Restructure plugin files to match beta branch structure - Move all plugin directories (flow-integration, includes, assets, lib, templates, languages) into checkout-com-unified-payments-api/ - Move plugin main files (woocommerce-gateway-checkout-com.php, readme.txt, view-webhook-queue.php) into checkout-com-unified-payments-api/ - Structure now matches beta branch: all plugin files inside checkout-com-unified-payments-api/ subdirectory * fix: Update build script to copy from checkout-com-unified-payments-api subdirectory * fix: Add all missing files from beta zip to match beta structure exactly - Add flow-container.js and flow-customization.js - Add includes/admin, includes/blocks, includes/api, includes/apms - Add includes/Files, includes/express, includes/logging, includes/subscription - Add vendor directory (composer dependencies) - Add check-database-indexes.php - Add missing class files in includes/ Structure now matches beta zip exactly * fix: Update bin/build.sh to use correct structure matching build-correct-zip.sh - Copy from checkout-com-unified-payments-api/ subdirectory - Use same exclusions and verification logic - Ensure correct WordPress plugin structure - Match build-correct-zip.sh functionality - Fix shebang compatibility for sh * chore: Remove build-correct-zip.sh - functionality now in bin/build.sh - bin/build.sh has been updated to match build-correct-zip.sh functionality - No need for duplicate build scripts - bin/build.sh is the standard build script location * fix: Update main plugin file to match beta version - Beta file: 1,972 lines, 77KB - Release file was: 596 lines, 19KB (incomplete) - Now matches beta version exactly * fix: Add missing files from beta to match beta structure exactly - Add gateway class files (apple-pay, cards, google-pay, paypal) - Add settings/admin directory - Add settings class files (logging, webhook, workflows) - Update admin.js, cko-paypal-integration.js, class-checkout-sdk.php to match beta All files now match beta branch structure * chore: Update version from 5.0.1-beta.5 to 5.0.0 - Update main plugin file version - Update readme.txt version - Update all version references in PHP and JS files - Version changed to stable 5.0.0 release * docs: Update README.md for Flow integration v5.0.0 - Focus on Flow integration features - Add Flow integration details and workflow - Update installation and configuration instructions - Add development and file structure information - Update version to 5.0.0 * docs: Improve Flow Integration Details section for better readability - Add step-by-step payment flow explanation - Expand key features with detailed explanations - Add payment flow diagram - Add technical architecture overview - Make content more accessible and understandable * Fix: Account creation fields only required when account creation is enabled - Filter out account_username and account_password fields during guest checkout - Only require account fields when #createaccount checkbox is checked and fields are visible - Add watcher for account creation checkbox to re-evaluate Flow initialization - Fix flowLog duplicate declaration error (changed const to var) - Enhanced logging for field validation debugging Fixes issue where Flow wouldn't initialize during guest checkout because account fields were incorrectly required. * Add duplicate prevention to webhook queue processing - Prevent duplicate webhooks from being queued (check before insert) - Prevent duplicate processing of queued webhooks (check _cko_processed_webhook_ids) - Reload order before processing to get latest state - Mark webhooks as processed in both order meta and queue table - Consistent with direct webhook processing duplicate prevention --------- Co-authored-by: Lalit Swain <[email protected]> Co-authored-by: Lalit Swain <[email protected]>
1 parent 002fd8b commit 3ddaa64

File tree

983 files changed

+127901
-1003
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

983 files changed

+127901
-1003
lines changed

README.md

Lines changed: 298 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,318 @@
1-
[![N|Solid](https://cdn.checkout.com/img/checkout-logo-online-payments.jpg)](https://checkout.com/)
1+
# Checkout.com WooCommerce Plugin - Flow Integration
22

3-
# Woocommerce Extension
4-
[Checkout.com](https://www.checkout.com "Checkout.com") is a software platform that has integrated 100% of the value chain to create payment infrastructures that truly make a difference.
3+
Checkout.com Payment Gateway plugin for WooCommerce with Flow integration support.
54

6-
This extension allows shop owners to process online payments (card / alternative payments) using:
7-
- **Frames.js** - Customisable payment form, embedded within your website
8-
- **Apple Pay & Google Pay** - Shoppers can pay using mobile wallets
9-
- **Alternative payments** - Shoppers can pay using local payment options (Sofort, iDEAL, Boleto ... etc.)
5+
## Version
106

11-
# Installation
12-
You can find a full installation guide [here](https://github.com/checkout/checkout-woocommerce-plugin/wiki/Installation)
7+
**Current Version:** 5.0.0
138

14-
# Initial Setup
15-
If you do not have an account yet, simply go to [checkout.com](https://checkout.com/) and hit the "Get Test Account" button.
9+
## Features
1610

17-
# Keys
18-
There are 3 keys to configure in the module:
19-
- **Secret Key**
20-
- **Public Key**
21-
- **Private Shared Key** (not required if using v4.2.0+ of our WooCommerce plugin)
11+
### Flow Integration
12+
- **Checkout.com Flow** - Modern, secure payment processing using Checkout.com's Flow Web Components
13+
- **Saved Cards** - Customers can save payment methods for future use
14+
- **3D Secure (3DS)** - Full support for 3D Secure authentication
15+
- **Card Validation** - Real-time card validation before order creation
16+
- **Webhook Processing** - Reliable webhook handling with queue system
17+
- **Order Management** - Automatic order status updates based on payment status
2218

23-
> The Private Shared Key is generated when you [configure the Webhook URL](https://docs.checkout.com/the-hub/manage-webhooks) in the Checkout HUB.
19+
### Payment Methods Supported
20+
- Credit/Debit Cards (via Flow)
21+
- Saved Payment Methods
22+
- Apple Pay
23+
- Google Pay
24+
- PayPal
25+
- Alternative Payment Methods (APMs)
2426

25-
# Webhook
26-
In order to keep WooCommerce order statuses in sync you need to configure the following webhook URL in your Checkout HUB (where _example.com_ is your store URL):
27+
## Installation
2728

28-
> The following URL format is for plugins versions 4.X or newer; click [here](https://github.com/checkout/checkout-woocommerce-plugin/wiki/URLs--2.x) to get the URLs for older plugin versions
29+
1. Download the plugin zip file: `checkout-com-unified-payments-api.zip`
30+
2. Go to WordPress Admin → Plugins → Add New → Upload Plugin
31+
3. Upload the zip file
32+
4. Activate the plugin
33+
5. Configure your Checkout.com credentials in WooCommerce → Settings → Payments → Checkout.com Payment
2934

35+
## Configuration
3036

31-
| URL Example | API Version | Events |
32-
| ------ | ------ | ------ |
33-
| _example.com_**/?wc-api=wc_checkoutcom_webhook** &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | 2.0 | All |
37+
### Required Settings
3438

35-
> You can see a guide on how to manage webhooks in the HUB [here](https://docs.checkout.com/the-hub/manage-webhooks) ; You can find test card details [here](https://docs.checkout.com/testing)
39+
1. **Secret Key** - Your Checkout.com secret key
40+
2. **Public Key** - Your Checkout.com public key
41+
3. **Webhook URL** - Configure in Checkout.com Hub:
42+
```
43+
https://your-site.com/?wc-api=wc_checkoutcom_webhook
44+
```
3645

37-
# Going LIVE
46+
### Flow Integration Settings
3847

39-
Upon receiving your live credentials from your account manager, here are the required steps to start processing live transactions:
48+
- Enable Flow payment method
49+
- Configure Flow appearance and behavior
50+
- Set up saved cards functionality
51+
- Configure 3DS settings
4052

41-
- In the plugin settings, input your **Live** keys
42-
- Switch the _Endpoint URL mode_ to **Live**.
53+
## Flow Integration Details
4354

44-
# Development environment Setup
55+
### Overview
4556

46-
- Clone the repository to in `wp-content/plugins` folder with the name `woocommerce-gateway-checkout-com`
47-
`git clone [email protected]:checkout/checkout-woocommerce-plugin.git woocommerce-gateway-checkout-com`
48-
or
49-
`git clone https://github.com/checkout/checkout-woocommerce-plugin.git woocommerce-gateway-checkout-com`
50-
- Use required `npm` version by executing `nvm use`.
51-
- Install the `npm` packages using `npm install`.
52-
- Install the `composer` packages using `composer install`.
53-
- During pushing the committing the code the PHPCS check will run at pre-commit hook. **So, till the PHPCS errors are not fixed for during commit we have to use `--no-verify` option in the git commit command.**
57+
The Flow integration provides a modern, secure payment experience using Checkout.com's Flow Web Components. This integration ensures reliable payment processing with comprehensive validation, webhook handling, and order management.
5458

59+
### How Flow Integration Works
5560

56-
# Reference
61+
The payment flow follows these steps:
5762

58-
You can find our complete Documentation [here](http://docs.checkout.com/).
59-
If you would like to be assigned an account manager, please contact us at [email protected]
60-
For help during the integration process you can contact us at [email protected]
61-
For support, you can contact us at [email protected]
63+
#### Step 1: Checkout Page Load
64+
- Customer fills out billing and shipping information
65+
- Flow payment method is selected
66+
- Flow Web Component is initialized and mounted
6267

63-
_Checkout.com is authorised and regulated as a Payment institution by the UK Financial Conduct Authority._
68+
#### Step 2: Order Creation (Before Payment)
69+
- **Why Early?** Orders are created via AJAX before payment processing begins
70+
- This ensures the order exists in the database for webhook matching
71+
- Order status: `Pending payment`
72+
- Payment session ID is stored with the order
73+
74+
#### Step 3: Payment Session Creation
75+
- Payment session is created with Checkout.com API
76+
- Session includes order details, customer information, and amount
77+
- Payment session ID is returned and stored
78+
79+
#### Step 4: Flow Component Validation
80+
- **Client-Side Validation**: Flow component validates card details in real-time
81+
- Card number, expiry, CVV are validated before submission
82+
- Invalid cards are rejected before payment attempt
83+
84+
#### Step 5: Payment Processing
85+
- Customer submits payment through Flow component
86+
- Payment is processed securely through Checkout.com
87+
- For 3D Secure: Customer is redirected for authentication
88+
- Payment result is returned
89+
90+
#### Step 6: Webhook Processing
91+
- Checkout.com sends webhook with payment status
92+
- Webhook is matched to order using:
93+
1. Order ID from metadata (primary)
94+
2. Payment Session ID + Payment ID (secondary)
95+
3. Payment ID alone (fallback)
96+
- If order not found immediately, webhook is queued for later processing
97+
98+
#### Step 7: Order Status Update
99+
- Order status is automatically updated based on payment result:
100+
-**Payment Approved** → Order status: `Processing`
101+
-**Payment Captured** → Order status: `Processing` (if not already)
102+
-**Payment Declined** → Order status: `Failed`
103+
- ⏸️ **Payment Cancelled** → Order status: `Cancelled`
104+
105+
### Key Features Explained
106+
107+
#### 🔒 Early Order Creation
108+
**What it does:** Creates the WooCommerce order before payment processing begins.
109+
110+
**Why it's important:**
111+
- Ensures webhooks can always find the order
112+
- Prevents webhook matching failures
113+
- Allows order tracking throughout the payment process
114+
115+
**How it works:**
116+
- Order is created via AJAX when customer clicks "Place Order"
117+
- Order is saved with `Pending payment` status
118+
- Payment session ID is stored for webhook matching
119+
120+
#### ✅ Dual Validation System
121+
**Client-Side Validation:**
122+
- Flow component validates card details in real-time
123+
- Prevents invalid cards from being submitted
124+
- Provides instant feedback to customers
125+
126+
**Server-Side Validation:**
127+
- Comprehensive validation of all checkout fields
128+
- Validates billing/shipping addresses
129+
- Ensures data integrity before order creation
130+
- Blocks order creation if validation fails
131+
132+
#### 🚫 Duplicate Prevention
133+
**Problem:** Multiple clicks or slow networks can cause duplicate orders.
134+
135+
**Solution:**
136+
- Client-side lock prevents multiple simultaneous requests
137+
- Server-side check prevents duplicate orders with same payment session ID
138+
- If duplicate detected, existing order is returned instead of creating new one
139+
140+
#### 📬 Webhook Queue System
141+
**Problem:** Webhooks might arrive before order is fully saved to database.
142+
143+
**Solution:**
144+
- Webhook queue temporarily stores webhooks if order not found
145+
- Queue is processed when order becomes available
146+
- Ensures no webhooks are lost
147+
- Automatic retry mechanism
148+
149+
#### 🔐 3D Secure (3DS) Support
150+
**How it works:**
151+
1. Payment requires 3DS authentication
152+
2. Customer is redirected to bank's 3DS page
153+
3. Customer completes authentication
154+
4. Customer is redirected back to store
155+
5. Payment status is confirmed via webhook
156+
6. Order status is updated accordingly
157+
158+
**Features:**
159+
- Automatic 3DS detection
160+
- Seamless redirect flow
161+
- Webhook handling after 3DS return
162+
- Prevents duplicate status updates
163+
164+
#### 💳 Saved Cards
165+
**How it works:**
166+
1. Customer opts to save card during checkout
167+
2. Card is tokenized securely by Checkout.com
168+
3. Token is stored in customer's account
169+
4. Saved cards appear on future checkouts
170+
5. Customer can select saved card for quick checkout
171+
172+
**Security:**
173+
- Cards are never stored on your server
174+
- Only secure tokens are stored
175+
- PCI compliance handled by Checkout.com
176+
- Cards can be deleted by customer
177+
178+
### Payment Flow Diagram
179+
180+
```
181+
Customer Checkout
182+
183+
Fill Billing/Shipping Info
184+
185+
Select Flow Payment Method
186+
187+
Click "Place Order"
188+
189+
[VALIDATION] Client-Side + Server-Side
190+
191+
[ORDER CREATED] Status: Pending payment
192+
193+
Create Payment Session with Checkout.com
194+
195+
[FLOW COMPONENT] Card Details Entered
196+
197+
[VALIDATION] Flow Component Validates Card
198+
199+
Submit Payment
200+
201+
[3DS?] If Required → Redirect → Authenticate → Return
202+
203+
Payment Processed
204+
205+
[WEBHOOK] Payment Status Received
206+
207+
Match Webhook to Order
208+
209+
Update Order Status
210+
211+
[COMPLETE] Order Status: Processing/Failed
212+
```
213+
214+
### Technical Architecture
215+
216+
#### Frontend (JavaScript)
217+
- **payment-session.js**: Handles order creation, payment session, Flow component integration
218+
- **flow-container.js**: Manages Flow component container and initialization
219+
- **flow-customization.js**: Customizes Flow component appearance and behavior
220+
221+
#### Backend (PHP)
222+
- **class-wc-gateway-checkout-com-flow.php**: Main gateway class, handles payment processing
223+
- **Webhook Handler**: Processes incoming webhooks and updates orders
224+
- **Webhook Queue**: Manages webhook queuing system
225+
226+
#### Database
227+
- Order meta stores: Payment Session ID, Payment ID, Webhook IDs
228+
- Webhook queue table: Temporary storage for unmatched webhooks
229+
230+
## Webhook Configuration
231+
232+
Configure the following webhook URL in your Checkout.com Hub:
233+
234+
```
235+
https://your-site.com/?wc-api=wc_checkoutcom_webhook
236+
```
237+
238+
### Webhook Events Supported
239+
240+
- `payment_approved`
241+
- `payment_captured`
242+
- `payment_declined`
243+
- `payment_cancelled`
244+
- `payment_voided`
245+
- `payment_refunded`
246+
247+
## Development
248+
249+
### Building the Plugin
250+
251+
Use the build script to create the plugin zip:
252+
253+
```bash
254+
./bin/build.sh
255+
```
256+
257+
This will create `checkout-com-unified-payments-api.zip` with the correct WordPress plugin structure.
258+
259+
### File Structure
260+
261+
```
262+
checkout-com-unified-payments-api/
263+
├── woocommerce-gateway-checkout-com.php # Main plugin file
264+
├── flow-integration/ # Flow integration
265+
│ ├── class-wc-gateway-checkout-com-flow.php
266+
│ └── assets/
267+
│ ├── js/
268+
│ │ ├── payment-session.js
269+
│ │ ├── flow-container.js
270+
│ │ └── flow-customization.js
271+
│ └── css/
272+
│ └── flow.css
273+
├── includes/ # Core functionality
274+
│ ├── api/
275+
│ ├── settings/
276+
│ ├── admin/
277+
│ └── ...
278+
├── assets/ # Frontend assets
279+
├── lib/ # Libraries
280+
└── vendor/ # Composer dependencies
281+
```
282+
283+
## Requirements
284+
285+
- WordPress 5.0+
286+
- WooCommerce 3.0+
287+
- PHP 7.3+
288+
- SSL Certificate (required for production)
289+
290+
## Support
291+
292+
For support and integration help:
293+
- **Integration Support**: [email protected]
294+
- **General Support**: [email protected]
295+
- **Sales**: [email protected]
296+
297+
## License
298+
299+
MIT License
300+
301+
## Changelog
302+
303+
### Version 5.0.0
304+
- Initial Flow integration release
305+
- Complete Flow Web Components integration
306+
- Saved cards functionality
307+
- 3D Secure support
308+
- Webhook queue system
309+
- Enhanced order management
310+
- Comprehensive validation and error handling
311+
312+
## Documentation
313+
314+
For detailed documentation, visit: [Checkout.com Documentation](https://docs.checkout.com)
315+
316+
---
317+
318+
**Checkout.com** is authorised and regulated as a Payment institution by the UK Financial Conduct Authority.

0 commit comments

Comments
 (0)