Plugin Directory

Changeset 3385898


Ignore:
Timestamp:
10/28/2025 02:23:27 PM (5 months ago)
Author:
peachpay
Message:

1.118.0

Location:
peachpay-for-woocommerce
Files:
918 added
8 edited

Legend:

Unmodified
Added
Removed
  • peachpay-for-woocommerce/trunk/changelog.txt

    r3385397 r3385898  
    11*** PeachPay for WooCommerce Changelog ***
     2
     32025-10-28 - version 1.118.0
     4* ConvesioPay- ApplePay Coupon Fix
    25
    362025-10-27 - version 1.117.9
  • peachpay-for-woocommerce/trunk/core/payments/convesiopay/assets/js/convesiopay-unified-blocks.js

    r3385397 r3385898  
    664664    const updateComponentAmount = async (newAmountInCents) => {
    665665        try {
    666             if (!convesioPayComponent) {
     666
     667            // Step 1: Unmount and destroy the old component
     668            if (convesioPayComponent) {
     669                try {
     670                    // Unmount the component if it has an unmount method
     671                    if (typeof convesioPayComponent.unmount === 'function') {
     672                        await convesioPayComponent.unmount();
     673                    }
     674
     675                    // Destroy the component if it has a destroy method
     676                    if (typeof convesioPayComponent.destroy === 'function') {
     677                        convesioPayComponent.destroy();
     678                    }
     679                } catch (unmountError) {
     680                    console.log('[ConvesioPay Blocks] Error during unmount/destroy:', unmountError);
     681                }
     682
     683                // Clear the component reference
     684                convesioPayComponent = null;
     685                isComponentMounted = false;
     686
     687                // Clear the container
     688                const componentContainer = document.querySelector('#convesiopay-unified-component-container');
     689                if (componentContainer) {
     690                    componentContainer.innerHTML = '';
     691                }
     692            }
     693
     694            // Step 2: Clear session state
     695            isSessionCreated = false;
     696            const hadBtcPaySession = btcPaySession !== null;
     697            btcPaySession = null;
     698
     699            // Step 3: Create and mount new component
     700            const componentResult = await createAndMountConvesioPayComponent();
     701
     702            if (!componentResult.success) {
     703                console.error('[ConvesioPay Blocks] Failed to create new component:', componentResult.message);
    667704                return;
    668705            }
    669706
    670             // Get fresh order data with updated amount
     707            // Mount the component in the container
     708            const componentContainer = document.querySelector('#convesiopay-unified-component-container');
     709            if (componentContainer) {
     710                componentContainer.innerHTML = '';
     711                await convesioPayComponent.mount('#convesiopay-unified-component-container');
     712            }
     713
     714            // Step 4: Get fresh order data with updated amount
    671715            const orderData = getOrderData();
    672716
     
    674718            orderData.amount = newAmountInCents;
    675719
    676             // Recreate ApplePay session with new amount
     720            // Step 5: Create ApplePay session with new amount
    677721            try {
    678722                await convesioPayComponent.createApplePaySession({
    679                     integration: window.peachpayConvesioPayUnified?.integration_name || 'PeachPay',
     723                    integration: settings.integration_name || window.peachpayConvesioPayUnified?.integration_name || 'PeachPay',
    680724                    returnUrl: window.location.href,
    681725                    orderNumber: orderData.orderNumber,
     
    686730                });
    687731            } catch (applePayError) {
    688                 // ApplePay might not be available on this device/browser
    689             }
    690 
    691             // Also try to recreate BTCPay session and intent if needed
    692             if (btcPaySession) {
     732                console.log('[ConvesioPay Blocks] ApplePay session creation failed (might not be available):', applePayError);
     733            }
     734
     735            // Step 6: Create BTCPay session and intent if it was previously active
     736            if (hadBtcPaySession) {
    693737                try {
    694                     // Clear the existing session flag so createBTCPaySession will create a new one
    695                     isSessionCreated = false;
    696738
    697739                    // Create new BTCPay session with updated amount
     
    702744                        btcPaySession = sessionResult.session;
    703745
    704                         // Then recreate the BTCPay intent with the new session
    705                         await convesioPayComponent.createBTCPayIntent({
     746                        // Prepare BTCPay intent data
     747                        const btcPayIntentData = {
    706748                            session: btcPaySession
    707                         });
     749                        };
     750
     751                        // Create the BTCPay intent with the new session
     752                        await convesioPayComponent.createBTCPayIntent(btcPayIntentData);
     753
     754                        // Re-setup the message listener
     755                        setupBTCPayMessageListener();
    708756                    }
    709757                } catch (btcPayError) {
    710                     // BTCPay session recreation failed
     758                    console.error('[ConvesioPay Blocks] BTCPay session/intent recreation failed:', btcPayError);
    711759                }
    712760            }
    713761
    714762        } catch (error) {
    715             // Error updating amount
     763            console.error('[ConvesioPay Blocks] Error updating component amount:', error);
    716764        }
    717765    };
     
    845893            try {
    846894                const checkoutStore = window.wp.data.select('wc/store/checkout');
     895
    847896                if (checkoutStore) {
    848897                    const orderId = checkoutStore.getOrderId();
     898
    849899                    if (orderId) {
    850900                        return orderId.toString();
     
    852902                }
    853903            } catch (e) {
    854                 // Fallback
     904                console.log('[ConvesioPay Blocks] Error accessing checkout store:', e);
    855905            }
    856906        }
     
    859909        const urlParams = new URLSearchParams(window.location.search);
    860910        const orderId = urlParams.get('order');
    861        
     911
    862912        if (orderId) {
    863913            return orderId;
     
    11211171           
    11221172        } catch (error) {
    1123            
    1124             // Show error in the content area
    1125             const contentContainer = document.querySelector('.wc-convesiopay-unified-blocks-content');
    1126             if (contentContainer) {
    1127                 const errorDiv = document.createElement('div');
    1128                 errorDiv.style.cssText = `
    1129                     color: red;
    1130                     font-size: 14px;
    1131                     text-align: center;
    1132                     padding: 20px;
    1133                     border: 1px solid #ff0000;
    1134                     border-radius: 5px;
    1135                     background: #fff5f5;
    1136                     margin: 0 0 10px 0;
    1137                 `;
    1138                 errorDiv.innerHTML = `
    1139                     <div>❌ Error</div>
    1140                     <small>Failed to create ConvesioPay payment: ${error.message}</small>
    1141                 `;
    1142 
    1143                 // Insert error message at the top
    1144                 contentContainer.insertBefore(errorDiv, contentContainer.firstChild);
    1145             }
     1173            console.error('Failed to create ConvesioPay payment:', error.message)
     1174            // // Show error in the content area
     1175            // const contentContainer = document.querySelector('.wc-convesiopay-unified-blocks-content');
     1176            // if (contentContainer) {
     1177            //     const errorDiv = document.createElement('div');
     1178            //     errorDiv.style.cssText = `
     1179            //         color: red;
     1180            //         font-size: 14px;
     1181            //         text-align: center;
     1182            //         padding: 20px;
     1183            //         border: 1px solid #ff0000;
     1184            //         border-radius: 5px;
     1185            //         background: #fff5f5;
     1186            //         margin: 0 0 10px 0;
     1187            //     `;
     1188            //     errorDiv.innerHTML = `
     1189            //         <div>❌ Error</div>
     1190            //         <small>Failed to create ConvesioPay payment: ${error.message}</small>
     1191            //     `;
     1192
     1193            //     // Insert error message at the top
     1194            //     contentContainer.insertBefore(errorDiv, contentContainer.firstChild);
     1195            // }
    11461196        }
    11471197    };
  • peachpay-for-woocommerce/trunk/core/payments/convesiopay/assets/js/convesiopay-unified-classic.js

    r3385397 r3385898  
    166166        // Create BTCPay session first, then mount component (following blocks pattern)
    167167        createBTCPaySession().then(sessionResult => {
    168             // console.log('sessionResult: ',sessionResult);
    169168            if (sessionResult.success) {
    170169                // After session is created, mount the ConvesioPay component
     
    957956    async function updateComponentAmount(newAmountInCents) {
    958957        try {
     958            // Step 1: Unmount and destroy the old component
     959            if (convesioPayComponent) {
     960                try {
     961                    // Unmount the component if it has an unmount method
     962                    if (typeof convesioPayComponent.unmount === 'function') {
     963                        await convesioPayComponent.unmount();
     964                    }
     965
     966                    // Destroy the component if it has a destroy method
     967                    if (typeof convesioPayComponent.destroy === 'function') {
     968                        convesioPayComponent.destroy();
     969                    }
     970                } catch (unmountError) {
     971                    console.log('Error during unmount/destroy:', unmountError);
     972                }
     973
     974                // Clear the component reference
     975                convesioPayComponent = null;
     976                isComponentMounted = false;
     977
     978                // Clear the container
     979                const container = document.getElementById('convesiopay-unified-payment-container');
     980                if (container) {
     981                    container.innerHTML = '';
     982                }
     983            }
     984
     985            // Step 2: Clear session state
     986            isSessionCreated = false;
     987            const hadBtcPaySession = btcPaySession !== null;
     988            btcPaySession = null;
     989
     990            // Step 3: Create new BTCPay session with updated amount
     991            const sessionResult = await createBTCPaySession();
     992
     993            if (!sessionResult.success) {
     994                return;
     995            }
     996
     997            btcPaySession = sessionResult.session;
     998
     999            // Step 4: Create and mount new component
     1000            await mountConvesioPayComponent();
     1001
    9591002            if (!convesioPayComponent) {
    9601003                return;
    9611004            }
    9621005
    963             // Get fresh order data with updated amount
     1006            // Step 5: Get fresh order data with updated amount
    9641007            const orderData = getOrderData();
    9651008
     
    9701013            const integrationName = config.integration_name || config.integrationName;
    9711014
    972             // Recreate ApplePay session with new amount
     1015            // Step 6: Create ApplePay session with new amount
    9731016            try {
    9741017                await convesioPayComponent.createApplePaySession({
     
    9811024                    name: orderData.name
    9821025                });
    983 
    9841026            } catch (applePayError) {
    985                 console.log('ApplePay session recreation skipped (might not be ApplePay)');
    986             }
    987 
    988             // Also recreate BTCPay session and intent if needed
    989             if (btcPaySession) {
    990                 try {
    991 
    992                     // Clear the existing session flag so createBTCPaySession will create a new one
    993                     isSessionCreated = false;
    994 
    995                     // Create new BTCPay session with updated amount
    996                     const sessionResult = await createBTCPaySession();
    997 
    998                     if (sessionResult.success && sessionResult.session) {
    999 
    1000                         // Update the global session variable
    1001                         btcPaySession = sessionResult.session;
    1002 
    1003                         // Then recreate the BTCPay intent with the new session
    1004                         await convesioPayComponent.createBTCPayIntent({
    1005                             session: btcPaySession
    1006                         });
    1007                     } else {
    1008                         throw new Error(sessionResult.message || 'Failed to create BTCPay session');
    1009                     }
    1010                 } catch (btcPayError) {
    1011                     console.error('BTCPay session/intent recreation failed', { error: btcPayError.message });
    1012                 }
     1027                console.log('ApplePay session creation failed (might not be available):', applePayError);
     1028            }
     1029
     1030            // Step 7: Create BTCPay intent with new session
     1031            try {
     1032
     1033                // Prepare BTCPay intent data
     1034                const btcPayIntentData = {
     1035                    session: btcPaySession
     1036                };
     1037
     1038                // Create the BTCPay intent with the new session
     1039                await convesioPayComponent.createBTCPayIntent(btcPayIntentData);
     1040
     1041                // Re-setup the message listener
     1042                setupBTCPayMessageListener();
     1043            } catch (btcPayError) {
     1044                console.log('BTCPay intent creation failed:', btcPayError);
    10131045            }
    10141046
  • peachpay-for-woocommerce/trunk/core/payments/convesiopay/gateways/class-peachpay-convesiopay-applepay-gateway.php

    r3385397 r3385898  
    215215        $payment_id = $this->get_payment_id_from_request();
    216216
    217         // Debug: Log what we received
    218         error_log( 'ApplePay process_payment - Payment ID received: ' . var_export( $payment_id, true ) );
    219         error_log( 'ApplePay process_payment - POST data: ' . var_export( $_POST, true ) );
    220 
    221217        // Use parent's PeachPay transaction system for processing
    222218        $result = parent::process_payment( $order_id );
     
    224220        // If payment ID was provided and it's not a fake timestamp-based ID, store it
    225221        if ( ! empty( $payment_id ) && strpos( $payment_id, 'applepay_' ) !== 0 ) {
    226             // This is a real ConvesioPay payment ID
    227             error_log( 'ApplePay process_payment - Storing real payment ID: ' . $payment_id );
    228222
    229223            $order->update_meta_data( '_convesiopay_payment_id', $payment_id );
  • peachpay-for-woocommerce/trunk/core/payments/convesiopay/gateways/class-peachpay-convesiopay-unified-gateway.php

    r3385397 r3385898  
    287287            // Enhanced payment method detection based on ConvesioPay events
    288288            $detected_method = $this->detect_payment_method( $payment_data );
    289 
    290289            // Handle different payment methods based on detection
    291290            // Act as interface/router - redirect to appropriate existing gateway
     
    322321        // Method 1: Check explicit payment method in data
    323322        $explicit_method = $payment_data['paymentMethod'] ?? $payment_data['paymentmethod'] ?? '';
     323
    324324        if ( ! empty( $explicit_method ) ) {
    325325            return $explicit_method;
     
    360360        // Method 3: Check status patterns
    361361        $status = $payment_data['status'] ?? '';
     362
    362363        if ( $status === 'Processing' && ( isset( $payment_data['invoiceId'] ) || isset( $payment_data['invoiceid'] ) ) ) {
    363364            return 'btcpay'; // BTCPay typically has Processing status with invoiceId
     
    368369        }
    369370
    370         // Method 4: Check for specific data structures
     371
    371372        if ( isset( $payment_data['qrCodeData'] ) || isset( $payment_data['qrcodedata'] ) || isset( $payment_data['paymentUri'] ) || isset( $payment_data['paymenturi'] ) ) {
    372373            return 'btcpay'; // BTCPay typically has QR code data
  • peachpay-for-woocommerce/trunk/core/payments/convesiopay/routes/class-peachpay-convesiopay-webhook.php

    r3385397 r3385898  
    159159            // Extract payment method information from ConvesioPay documentation structure
    160160            $payment_method_details = $webhook_data['paymentMethodDetails'] ?? array();
     161            // error_log( '[ConvesioPay webhook] Payment method details: ' . print_r( $payment_method_details, true ) );
    161162            $payment_method_type = $payment_method_details['type'] ?? '';
    162163            $payment_method_brand = $payment_method_details['brand'] ?? '';
     164            $payment_method_cardholder = $payment_method_details['cardHolderName'] ?? '';
    163165           
    164166            // Determine payment method for title (supporting card, btcPay, etc.)
     
    166168            if ( $payment_method_type === 'card' && ! empty( $payment_method_brand ) ) {
    167169                $payment_method = $payment_method_brand; // visa, mastercard, etc.
     170            }elseif ($payment_method_type === 'card' && $payment_method_brand == '' && $payment_method_cardholder == 'Apple Pay PlaceHolder') {
     171                $payment_method = 'applepay';
    168172            }
    169173           
     
    945949            case 'credit_card':
    946950            case 'debit_card':
     951                $title = 'ConvesioPay Card';
     952                break;
    947953            default:
    948                 $title = 'ConvesioPay Card';
    949                 break;
     954                $title = 'ConvesioPay';
    950955        }
    951956       
  • peachpay-for-woocommerce/trunk/peachpay.php

    r3385397 r3385898  
    44 * Plugin URI: https://woocommerce.com/products/peachpay
    55 * Description: Connect and manage all your payment methods, offer shoppers a beautiful Express Checkout, and reduce cart abandonment.
    6  * Version: 1.117.9
     6 * Version: 1.118.0
    77 * Text Domain: peachpay-for-woocommerce
    88 * Domain Path: /languages
  • peachpay-for-woocommerce/trunk/readme.txt

    r3385397 r3385898  
    44Requires at least: 5.8
    55Tested up to: 6.8.1
    6 Stable tag: 1.117.9
     6Stable tag: 1.118.0
    77Requires PHP: 7.0
    88License: GPLv2 or later
     
    262262
    263263== Changelog ==
     264
     265### 1.118.0 (2025-10-28)
     266
     267#### Bug Fixes
     268- ConvesioPay- ApplePay Coupon Fix
    264269
    265270### 1.117.9 (2025-10-27)
Note: See TracChangeset for help on using the changeset viewer.