Plugin Directory

Changeset 3379052


Ignore:
Timestamp:
10/15/2025 05:28:06 PM (6 months ago)
Author:
startbutton
Message:

Release version 1.1.7 - Updated plugin files and created new tag

Location:
startbutton-for-woocommerce
Files:
30 added
5 edited

Legend:

Unmodified
Added
Removed
  • startbutton-for-woocommerce/trunk/assets/js/startbutton.js

    r3378480 r3379052  
    1313        // const isDevelopment = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1';
    1414        console.log('url', location.origin + '/wc-api/WC_Startbutton_Webhook');
     15        console.log('wc_startbutton_params.env', wc_startbutton_params.env);
    1516        // Configuration for development environment
    1617        const config = {
     
    4243                success: (res) => {
    4344                    console.log('success');
    44                     $form = $( '#order_review' );
    45                     $form.append( '<input type="hidden" name="order_id" value="' + wc_startbutton_params.order_id + '"/>' );
    46                     $form.append( '<input type="hidden" name="startbutton_tx_ref" value="' + res.reference + '"/>' );
    47                     $form.append( '<input type="hidden" name="startbutton_tx_id" value="' + res.transaction + '"/>' );
    48                     $form.append( '<input type="hidden" name="startbutton_nonce" value="' + wc_startbutton_params.nonce + '"/>' );
    4945                   
    50                     $form.submit();
     46                    // Store payment data for redirect in finally()
     47                    window.startbuttonPaymentData = {
     48                        order_id: wc_startbutton_params.order_id,
     49                        tx_ref: res.reference,
     50                        tx_id: res.transaction,
     51                        nonce: wc_startbutton_params.nonce
     52                    };
     53                   
    5154                    console.log('res', res);
    5255                    resolve(res);
     
    6770            $('#startbutton-payment-button').removeClass('disabled');
    6871            $('#startbutton-cancel-payment-button').removeClass('disabled');
     72           
     73            // Handle redirect in finally() - this will execute regardless of success/error
     74            if (window.startbuttonPaymentData) {
     75                const { order_id, tx_ref, tx_id, nonce } = window.startbuttonPaymentData;
     76                console.log('resolved...', {order_id, tx_ref, tx_id, nonce});
     77                // Try form submission first
     78                // try {
     79                //     $form = $( '#order_review' );
     80                //     $form.append( '<input type="hidden" name="order_id" value="' + order_id + '"/>' );
     81                //     $form.append( '<input type="hidden" name="startbutton_tx_ref" value="' + tx_ref + '"/>' );
     82                //     $form.append( '<input type="hidden" name="startbutton_tx_id" value="' + tx_id + '"/>' );
     83                //     $form.append( '<input type="hidden" name="startbutton_nonce" value="' + nonce + '"/>' );
     84                   
     85                //     $form.submit();
     86                //     console.log('Form submitted successfully');
     87                // } catch (formError) {
     88                //     console.log('Form submission failed, attempting direct redirect:', formError);
     89                // Fallback to direct URL redirect
     90                const redirectUrl = wc_startbutton_params.api_url + '?' + new URLSearchParams({
     91                    order_id: order_id,
     92                    startbutton_tx_ref: tx_ref,
     93                    startbutton_tx_id: tx_id,
     94                    startbutton_nonce: nonce
     95                }).toString();
     96               
     97                console.log('Redirecting to:', redirectUrl);
     98                window.location.href = redirectUrl;
     99                // }
     100               
     101                // Clear the stored data
     102                delete window.startbuttonPaymentData;
     103            }
    69104        }); 
    70105    }
  • startbutton-for-woocommerce/trunk/changelog.txt

    r3378843 r3379052  
    24242025-10-14 - version 1.1.6
    2525* Bug fixes
     26
     272025-10-14 - version 1.1.7
     28* Bug fixes
  • startbutton-for-woocommerce/trunk/includes/class-wc-gateway-startbutton.php

    r3378480 r3379052  
    550550    }
    551551    $startbutton_params['shipping_address'] = $shipping_address;
     552    $startbutton_params['api_url'] = WC()->api_request_url( 'WC_Gateway_Startbutton' );
    552553
    553554        wp_localize_script( 'wc_startbutton', 'wc_startbutton_params', $startbutton_params );
     
    784785    error_log('=== STARTBUTTON TRANSACTION UPDATE STARTED ===');
    785786   
    786     // Update request parameters
    787     $order_id = isset( $_POST['order_id'] ) ? absint( $_POST['order_id'] ) : 0;
    788     $tx_ref   = isset( $_POST['startbutton_tx_ref'] ) ? sanitize_text_field( wp_unslash($_POST['startbutton_tx_ref'] )) : '';
    789     $tx_id    = isset( $_POST['startbutton_tx_id'] ) ? sanitize_text_field( wp_unslash($_POST['startbutton_tx_id'] )) : '';
    790     $nonce    = isset( $_POST['startbutton_nonce'] ) ? sanitize_text_field( wp_unslash($_POST['startbutton_nonce'] )) : '';
     787    // Update request parameters - support both POST and GET requests
     788    $order_id = isset( $_POST['order_id'] ) ? absint( $_POST['order_id'] ) : (isset( $_GET['order_id'] ) ? absint( $_GET['order_id'] ) : 0);
     789    $tx_ref   = isset( $_POST['startbutton_tx_ref'] ) ? sanitize_text_field( wp_unslash($_POST['startbutton_tx_ref'] )) : (isset( $_GET['startbutton_tx_ref'] ) ? sanitize_text_field( wp_unslash($_GET['startbutton_tx_ref'] )) : '');
     790    $tx_id    = isset( $_POST['startbutton_tx_id'] ) ? sanitize_text_field( wp_unslash($_POST['startbutton_tx_id'] )) : (isset( $_GET['startbutton_tx_id'] ) ? sanitize_text_field( wp_unslash($_GET['startbutton_tx_id'] )) : '');
     791    $nonce    = isset( $_POST['startbutton_nonce'] ) ? sanitize_text_field( wp_unslash($_POST['startbutton_nonce'] )) : (isset( $_GET['startbutton_nonce'] ) ? sanitize_text_field( wp_unslash($_GET['startbutton_nonce'] )) : '');
    791792
    792793    error_log('Order ID: ' . $order_id);
    793794    error_log('Transaction Ref: ' . $tx_ref);
    794795    error_log('Transaction ID: ' . $tx_id);
     796    error_log('Request method: ' . $_SERVER['REQUEST_METHOD']);
    795797
    796798    if ( ! $order_id || empty( $tx_ref ) || empty ( $tx_id ) || empty( $nonce )) {
  • startbutton-for-woocommerce/trunk/readme.txt

    r3378843 r3379052  
    44Requires at least: 6.2
    55Tested up to: 6.7
    6 Stable tag: 1.1.6
     6Stable tag: 1.1.7
    77Requires PHP: 7.4
    88License: GPLv2 or later
     
    123123* Bug fixes
    124124
     125= 1.1.7 - October 14, 2025 =
     126* Bug fixes
     127
    125128== Screenshots ==
    126129
  • startbutton-for-woocommerce/trunk/woo-startbutton.php

    r3378843 r3379052  
    44 * Plugin URI: https://startbutton.africa
    55 * Description: Startbutton payment gateway for WooCommerce.
    6  * Version: 1.1.6
     6 * Version: 1.1.7
    77 * Author: Sommysab
    88 * License: GPL-2.0+
     
    2929  'prod' => 'https://api.startbutton.tech',
    3030]);
    31 define( 'STARTBUTTON_WC_VERSION', '1.1.6' );
     31define( 'STARTBUTTON_WC_VERSION', '1.1.7' );
    3232
    3333/**
Note: See TracChangeset for help on using the changeset viewer.