Plugin Directory

Changeset 3833154


Ignore:
Timestamp:
11/29/2026 02:18:19 PM (less than one hour ago)
Author:
starnetwork
Message:

Deploy version 1.2.4 from GitLab CI/CD

Location:
wc-smartpay
Files:
2 added
16 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wc-smartpay/tags/1.2.4/includes/class-smartpay-adapter.php

    r3764750 r3833154  
    273273                $request_data = apply_filters( 'smartpay_generate_payment_page_link_before', $request_data );
    274274                $request_data['transaction_source'] = $this->get_transaction_source( 'iframe' );
    275                 return $this->request( $request_data, 'checkout/pages', $use_alternative );
     275                return $this->with_company_pages_address(
     276                        $this->request( $request_data, 'checkout/pages', $use_alternative ),
     277                        $use_alternative
     278                );
    276279        }
    277280
    … …  
    288291        $request_data['page_type'] = 'hosted_fields';
    289292        $request_data['transaction_source'] = $this->get_transaction_source( 'iframe' );
    290         return $this->request( $request_data, 'checkout/pages', $user_alternative );
     293        return $this->with_company_pages_address(
     294            $this->request( $request_data, 'checkout/pages', $user_alternative ),
     295            $user_alternative
     296        );
    291297    }
     298
     299        /**
     300         * Point the hosted link of a checkout session at the company's own pages
     301         * address, when SmartPay gave the company one. Anything else is returned
     302         * untouched.
     303         *
     304         * @param mixed $response checkout/pages response.
     305         * @param bool  $use_alternative flag to define if to use alternative API credentials.
     306         * @return mixed
     307         */
     308        private function with_company_pages_address( $response, $use_alternative = false ) {
     309                if ( is_array( $response ) && isset( $response['url'] ) && is_string( $response['url'] ) ) {
     310                        $response['url'] = SmartPay_Pages_Address::instance()->rewrite( $response['url'], $use_alternative );
     311                }
     312                return $response;
     313        }
    292314
    293315        /**
  • wc-smartpay/tags/1.2.4/includes/class-smartpay-cc-form-renderer.php

    r3700234 r3833154  
    1818        wp_enqueue_script(
    1919            'smartpay-lib',
    20             'https://app13.smartpay.co.il/v1/sdk/sdk.js'
     20            SmartPay_Pages_Address::instance()->get_sdk_url()
    2121        );
    2222
  • wc-smartpay/tags/1.2.4/includes/class-smartpay-checkout-block.php

    r3700234 r3833154  
    9393                        wp_register_script(
    9494                        $hostedFieldsHandle,
    95                         'https://app13.smartpay.co.il/v1/sdk/sdk.js'
     95                        SmartPay_Pages_Address::instance()->get_sdk_url()
    9696                        );
    9797                }
  • wc-smartpay/tags/1.2.4/includes/class-smartpay-order-helper.php

    r3700234 r3833154  
    251251
    252252                return $card;
     253        }
     254
     255        /**
     256         * Non-card methods the payment page can charge with: lowercase API name
     257         * => [ checkout gateway id (null when the plugin has none), default title ].
     258         *
     259         * @return array
     260         */
     261        private function paid_method_titles() {
     262                return array(
     263                        'bitbyupay' => array( SmartPay_Payment_Gateway_Bitbyupay::METHOD_CODE, 'Bit' ),
     264                        'bitbygrow' => array( SmartPay_Payment_Gateway_Bitbygrow::METHOD_CODE, 'Bit' ),
     265                        'bitbygama' => array( null, 'Bit' ),
     266                        'applepay'  => array( SmartPay_Payment_Gateway_Applepay::METHOD_CODE, 'Apple Pay' ),
     267                        'gpay'      => array( SmartPay_Payment_Gateway_Gpay::METHOD_CODE, 'Google Pay' ),
     268                );
     269        }
     270
     271        /**
     272         * Method the charge was paid with, as the API reports it. Card and
     273         * wallet charges carry `transaction_method`; Bit charges (UPay / Grow)
     274         * only carry the wallet in `transaction_source`, or the Bit terminal name.
     275         *
     276         * @param StdClass $transaction confirmed charge.
     277         * @return string key of paid_method_titles(), empty for a card charge or an unknown method.
     278         */
     279        private function resolve_paid_method( $transaction ) {
     280                $source = $transaction->transaction_source ?? null;
     281                if ( is_string( $source ) ) {
     282                        $source = json_decode( $source, true );
     283                }
     284                $source = is_object( $source ) ? get_object_vars( $source ) : $source;
     285
     286                $candidates = array(
     287                        is_array( $source ) && isset( $source['wallet'] ) ? $source['wallet'] : null,
     288                        $transaction->transaction_method ?? null,
     289                        $transaction->terminalName ?? null,
     290                );
     291
     292                $known = $this->paid_method_titles();
     293                foreach ( $candidates as $candidate ) {
     294                        $key = is_string( $candidate ) ? strtolower( trim( $candidate ) ) : '';
     295                        if ( isset( $known[ $key ] ) ) {
     296                                return $key;
     297                        }
     298                }
     299
     300                return '';
     301        }
     302
     303        /**
     304         * The payment page of the card gateway also offers the terminal's other
     305         * methods (Bit, Apple Pay, Google Pay). When the charge was paid with one
     306         * of them, show that method on the order (admin, e-mails, thank-you page)
     307         * instead of the title of the gateway picked at checkout.
     308         *
     309         * Only the title changes: the method id keeps driving refunds, renewals
     310         * and the invoices plugin mapping. Must run before the status change that
     311         * sends the customer e-mail. The caller saves the order.
     312         *
     313         * @param WC_Order $order              order object.
     314         * @param string   $transaction_method resolve_paid_method() result.
     315         * @return void
     316         */
     317        private function sync_paid_method_title( WC_Order $order, $transaction_method ) {
     318                $paid_methods = $this->paid_method_titles();
     319                $key          = (string) $transaction_method;
     320                if ( ! isset( $paid_methods[ $key ] ) ) {
     321                        return;
     322                }
     323
     324                list( $method_code, $title ) = $paid_methods[ $key ];
     325                if ( $method_code === $order->get_payment_method() ) {
     326                        return;
     327                }
     328
     329                // A store that offers the method at checkout gets the title it configured there.
     330                if ( $method_code ) {
     331                        $settings = get_option( 'woocommerce_' . $method_code . '_settings' );
     332                        if ( is_array( $settings )
     333                                && isset( $settings['enabled'], $settings['title'] )
     334                                && 'yes' === $settings['enabled']
     335                                && '' !== trim( (string) $settings['title'] )
     336                        ) {
     337                                $title = trim( (string) $settings['title'] );
     338                        }
     339                }
     340
     341                /**
     342                 * Title shown on an order paid with another method than the gateway picked at checkout.
     343                 *
     344                 * @param string   $title              title to show.
     345                 * @param string   $transaction_method key of paid_method_titles(), e.g. `bitbyupay`.
     346                 * @param WC_Order $order              order object.
     347                 */
     348                $title = (string) apply_filters( 'smartpay_paid_method_title', $title, $transaction_method, $order );
     349                if ( '' === $title || $title === $order->get_payment_method_title() ) {
     350                        return;
     351                }
     352
     353                $order->set_payment_method_title( $title );
    253354        }
    254355
    … …  
    321422        $order->update_meta_data( 'transaction_method', $transaction->transaction_method ?? null );
    322423
     424        $this->sync_paid_method_title( $order, $this->resolve_paid_method( $transaction ) );
     425
    323426        $order->set_transaction_id( $transaction->tuid );
    324427        $order->save();
  • wc-smartpay/tags/1.2.4/includes/class-smartpay-payment-gateway.php

    r3707394 r3833154  
    7777                do_action( 'smartpay_payment_gateway_init_after', $this );
    7878
     79                // Saving the settings also asks the SmartPay dashboard again which
     80                // hosted pages address applies to this store.
     81                add_action(
     82                        'woocommerce_update_options_payment_gateways_' . $this->id,
     83                        array( SmartPay_Pages_Address::instance(), 'flush' ),
     84                        5
     85                );
     86
    7987                // This action hook saves the settings.
    8088                add_action(
  • wc-smartpay/tags/1.2.4/includes/class-smartpay.php

    r3764750 r3833154  
    1616         * @var string
    1717         */
    18         private $version = '1.2.3';
     18        private $version = '1.2.4';
    1919
    2020        /**
  • wc-smartpay/tags/1.2.4/readme.txt

    r3764750 r3833154  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.2.3
     7Stable tag: 1.2.4
    88Requires Plugins: woocommerce
    99License: GPLv2 or later
    … …  
    7878* https://sandboxapi.smartpay.co.il/ (sandbox)
    7979
    80 The hosted payment page and hosted fields are served from SmartPay servers. The hosted fields script is loaded on the checkout page from https://app13.smartpay.co.il/ only when the embedded card form is enabled; the card fields themselves load from the address SmartPay returns for the checkout session. Data sent includes the order amount, currency, order number, customer billing and shipping details, and, for Multipass, the voucher card number entered by the customer.
     80The plugin also asks the SmartPay dashboard which hosted pages address applies to the store's SmartPay account. The request carries only the store's API credentials and is answered from a one-hour cache. It goes to:
     81
     82* https://my-backend.smartpay.co.il/ (production)
     83* https://mysandbox-backend.smartpay.co.il/ (sandbox)
     84
     85The hosted payment page and hosted fields are served from SmartPay servers. The hosted fields script is loaded on the checkout page only when the embedded card form is enabled, from https://app13.smartpay.co.il/ or, for accounts SmartPay has moved to their own pages address, from that address (always a smartpay.co.il or protected-payment.com host); the card fields themselves load from the address SmartPay returns for the checkout session. Data sent includes the order amount, currency, order number, customer billing and shipping details, and, for Multipass, the voucher card number entered by the customer.
    8186
    8287SmartPay.co.il terms of use and privacy policy: https://www.smartpay.co.il/terms/
    8388
    8489== Changelog ==
     90
     91= 1.2.4 =
     92* New: SmartPay can move a merchant account to a different hosted pages address. The plugin reads the address from the SmartPay dashboard with the store's API credentials and uses it for the payment page, the embedded card form and its script. Stores whose account has no address of its own are not affected, and when the dashboard cannot be reached the plugin keeps using the address it gets from the payments API.
     93* Fixed: an order paid with Bit, Apple Pay or Google Pay on the card payment page showed "credit card" as its payment method in the admin, the e-mails and the thank-you page. The title now follows the method the charge was confirmed with.
    8594
    8695= 1.2.3 =
  • wc-smartpay/tags/1.2.4/smartpay.php

    r3764750 r3833154  
    44 * Plugin URI:        https://smartpay.co.il/
    55 * Description:       Accept credit cards, Apple Pay, Google Pay, Bit and Multipass vouchers in WooCommerce through the SmartPay.co.il payment gateway.
    6  * Version:           1.2.3
     6 * Version:           1.2.4
    77 * Requires at least: 6.5
    88 * Requires PHP:      7.4
    … …  
    5151}
    5252
    53 define( 'SMARTPAY_VERSION', '1.2.3' );
     53define( 'SMARTPAY_VERSION', '1.2.4' );
    5454
    5555if ( ! defined( 'SMARTPAY_PLUGIN_FILE' ) ) {
  • wc-smartpay/trunk/includes/class-smartpay-adapter.php

    r3764750 r3833154  
    273273                $request_data = apply_filters( 'smartpay_generate_payment_page_link_before', $request_data );
    274274                $request_data['transaction_source'] = $this->get_transaction_source( 'iframe' );
    275                 return $this->request( $request_data, 'checkout/pages', $use_alternative );
     275                return $this->with_company_pages_address(
     276                        $this->request( $request_data, 'checkout/pages', $use_alternative ),
     277                        $use_alternative
     278                );
    276279        }
    277280
    … …  
    288291        $request_data['page_type'] = 'hosted_fields';
    289292        $request_data['transaction_source'] = $this->get_transaction_source( 'iframe' );
    290         return $this->request( $request_data, 'checkout/pages', $user_alternative );
     293        return $this->with_company_pages_address(
     294            $this->request( $request_data, 'checkout/pages', $user_alternative ),
     295            $user_alternative
     296        );
    291297    }
     298
     299        /**
     300         * Point the hosted link of a checkout session at the company's own pages
     301         * address, when SmartPay gave the company one. Anything else is returned
     302         * untouched.
     303         *
     304         * @param mixed $response checkout/pages response.
     305         * @param bool  $use_alternative flag to define if to use alternative API credentials.
     306         * @return mixed
     307         */
     308        private function with_company_pages_address( $response, $use_alternative = false ) {
     309                if ( is_array( $response ) && isset( $response['url'] ) && is_string( $response['url'] ) ) {
     310                        $response['url'] = SmartPay_Pages_Address::instance()->rewrite( $response['url'], $use_alternative );
     311                }
     312                return $response;
     313        }
    292314
    293315        /**
  • wc-smartpay/trunk/includes/class-smartpay-cc-form-renderer.php

    r3700234 r3833154  
    1818        wp_enqueue_script(
    1919            'smartpay-lib',
    20             'https://app13.smartpay.co.il/v1/sdk/sdk.js'
     20            SmartPay_Pages_Address::instance()->get_sdk_url()
    2121        );
    2222
  • wc-smartpay/trunk/includes/class-smartpay-checkout-block.php

    r3700234 r3833154  
    9393                        wp_register_script(
    9494                        $hostedFieldsHandle,
    95                         'https://app13.smartpay.co.il/v1/sdk/sdk.js'
     95                        SmartPay_Pages_Address::instance()->get_sdk_url()
    9696                        );
    9797                }
  • wc-smartpay/trunk/includes/class-smartpay-order-helper.php

    r3700234 r3833154  
    251251
    252252                return $card;
     253        }
     254
     255        /**
     256         * Non-card methods the payment page can charge with: lowercase API name
     257         * => [ checkout gateway id (null when the plugin has none), default title ].
     258         *
     259         * @return array
     260         */
     261        private function paid_method_titles() {
     262                return array(
     263                        'bitbyupay' => array( SmartPay_Payment_Gateway_Bitbyupay::METHOD_CODE, 'Bit' ),
     264                        'bitbygrow' => array( SmartPay_Payment_Gateway_Bitbygrow::METHOD_CODE, 'Bit' ),
     265                        'bitbygama' => array( null, 'Bit' ),
     266                        'applepay'  => array( SmartPay_Payment_Gateway_Applepay::METHOD_CODE, 'Apple Pay' ),
     267                        'gpay'      => array( SmartPay_Payment_Gateway_Gpay::METHOD_CODE, 'Google Pay' ),
     268                );
     269        }
     270
     271        /**
     272         * Method the charge was paid with, as the API reports it. Card and
     273         * wallet charges carry `transaction_method`; Bit charges (UPay / Grow)
     274         * only carry the wallet in `transaction_source`, or the Bit terminal name.
     275         *
     276         * @param StdClass $transaction confirmed charge.
     277         * @return string key of paid_method_titles(), empty for a card charge or an unknown method.
     278         */
     279        private function resolve_paid_method( $transaction ) {
     280                $source = $transaction->transaction_source ?? null;
     281                if ( is_string( $source ) ) {
     282                        $source = json_decode( $source, true );
     283                }
     284                $source = is_object( $source ) ? get_object_vars( $source ) : $source;
     285
     286                $candidates = array(
     287                        is_array( $source ) && isset( $source['wallet'] ) ? $source['wallet'] : null,
     288                        $transaction->transaction_method ?? null,
     289                        $transaction->terminalName ?? null,
     290                );
     291
     292                $known = $this->paid_method_titles();
     293                foreach ( $candidates as $candidate ) {
     294                        $key = is_string( $candidate ) ? strtolower( trim( $candidate ) ) : '';
     295                        if ( isset( $known[ $key ] ) ) {
     296                                return $key;
     297                        }
     298                }
     299
     300                return '';
     301        }
     302
     303        /**
     304         * The payment page of the card gateway also offers the terminal's other
     305         * methods (Bit, Apple Pay, Google Pay). When the charge was paid with one
     306         * of them, show that method on the order (admin, e-mails, thank-you page)
     307         * instead of the title of the gateway picked at checkout.
     308         *
     309         * Only the title changes: the method id keeps driving refunds, renewals
     310         * and the invoices plugin mapping. Must run before the status change that
     311         * sends the customer e-mail. The caller saves the order.
     312         *
     313         * @param WC_Order $order              order object.
     314         * @param string   $transaction_method resolve_paid_method() result.
     315         * @return void
     316         */
     317        private function sync_paid_method_title( WC_Order $order, $transaction_method ) {
     318                $paid_methods = $this->paid_method_titles();
     319                $key          = (string) $transaction_method;
     320                if ( ! isset( $paid_methods[ $key ] ) ) {
     321                        return;
     322                }
     323
     324                list( $method_code, $title ) = $paid_methods[ $key ];
     325                if ( $method_code === $order->get_payment_method() ) {
     326                        return;
     327                }
     328
     329                // A store that offers the method at checkout gets the title it configured there.
     330                if ( $method_code ) {
     331                        $settings = get_option( 'woocommerce_' . $method_code . '_settings' );
     332                        if ( is_array( $settings )
     333                                && isset( $settings['enabled'], $settings['title'] )
     334                                && 'yes' === $settings['enabled']
     335                                && '' !== trim( (string) $settings['title'] )
     336                        ) {
     337                                $title = trim( (string) $settings['title'] );
     338                        }
     339                }
     340
     341                /**
     342                 * Title shown on an order paid with another method than the gateway picked at checkout.
     343                 *
     344                 * @param string   $title              title to show.
     345                 * @param string   $transaction_method key of paid_method_titles(), e.g. `bitbyupay`.
     346                 * @param WC_Order $order              order object.
     347                 */
     348                $title = (string) apply_filters( 'smartpay_paid_method_title', $title, $transaction_method, $order );
     349                if ( '' === $title || $title === $order->get_payment_method_title() ) {
     350                        return;
     351                }
     352
     353                $order->set_payment_method_title( $title );
    253354        }
    254355
    … …  
    321422        $order->update_meta_data( 'transaction_method', $transaction->transaction_method ?? null );
    322423
     424        $this->sync_paid_method_title( $order, $this->resolve_paid_method( $transaction ) );
     425
    323426        $order->set_transaction_id( $transaction->tuid );
    324427        $order->save();
  • wc-smartpay/trunk/includes/class-smartpay-payment-gateway.php

    r3707394 r3833154  
    7777                do_action( 'smartpay_payment_gateway_init_after', $this );
    7878
     79                // Saving the settings also asks the SmartPay dashboard again which
     80                // hosted pages address applies to this store.
     81                add_action(
     82                        'woocommerce_update_options_payment_gateways_' . $this->id,
     83                        array( SmartPay_Pages_Address::instance(), 'flush' ),
     84                        5
     85                );
     86
    7987                // This action hook saves the settings.
    8088                add_action(
  • wc-smartpay/trunk/includes/class-smartpay.php

    r3764750 r3833154  
    1616         * @var string
    1717         */
    18         private $version = '1.2.3';
     18        private $version = '1.2.4';
    1919
    2020        /**
  • wc-smartpay/trunk/readme.txt

    r3764750 r3833154  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.2.3
     7Stable tag: 1.2.4
    88Requires Plugins: woocommerce
    99License: GPLv2 or later
    … …  
    7878* https://sandboxapi.smartpay.co.il/ (sandbox)
    7979
    80 The hosted payment page and hosted fields are served from SmartPay servers. The hosted fields script is loaded on the checkout page from https://app13.smartpay.co.il/ only when the embedded card form is enabled; the card fields themselves load from the address SmartPay returns for the checkout session. Data sent includes the order amount, currency, order number, customer billing and shipping details, and, for Multipass, the voucher card number entered by the customer.
     80The plugin also asks the SmartPay dashboard which hosted pages address applies to the store's SmartPay account. The request carries only the store's API credentials and is answered from a one-hour cache. It goes to:
     81
     82* https://my-backend.smartpay.co.il/ (production)
     83* https://mysandbox-backend.smartpay.co.il/ (sandbox)
     84
     85The hosted payment page and hosted fields are served from SmartPay servers. The hosted fields script is loaded on the checkout page only when the embedded card form is enabled, from https://app13.smartpay.co.il/ or, for accounts SmartPay has moved to their own pages address, from that address (always a smartpay.co.il or protected-payment.com host); the card fields themselves load from the address SmartPay returns for the checkout session. Data sent includes the order amount, currency, order number, customer billing and shipping details, and, for Multipass, the voucher card number entered by the customer.
    8186
    8287SmartPay.co.il terms of use and privacy policy: https://www.smartpay.co.il/terms/
    8388
    8489== Changelog ==
     90
     91= 1.2.4 =
     92* New: SmartPay can move a merchant account to a different hosted pages address. The plugin reads the address from the SmartPay dashboard with the store's API credentials and uses it for the payment page, the embedded card form and its script. Stores whose account has no address of its own are not affected, and when the dashboard cannot be reached the plugin keeps using the address it gets from the payments API.
     93* Fixed: an order paid with Bit, Apple Pay or Google Pay on the card payment page showed "credit card" as its payment method in the admin, the e-mails and the thank-you page. The title now follows the method the charge was confirmed with.
    8594
    8695= 1.2.3 =
  • wc-smartpay/trunk/smartpay.php

    r3764750 r3833154  
    44 * Plugin URI:        https://smartpay.co.il/
    55 * Description:       Accept credit cards, Apple Pay, Google Pay, Bit and Multipass vouchers in WooCommerce through the SmartPay.co.il payment gateway.
    6  * Version:           1.2.3
     6 * Version:           1.2.4
    77 * Requires at least: 6.5
    88 * Requires PHP:      7.4
    … …  
    5151}
    5252
    53 define( 'SMARTPAY_VERSION', '1.2.3' );
     53define( 'SMARTPAY_VERSION', '1.2.4' );
    5454
    5555if ( ! defined( 'SMARTPAY_PLUGIN_FILE' ) ) {
Note: See TracChangeset for help on using the changeset viewer.