Plugin Directory

Changeset 3328058


Ignore:
Timestamp:
07/15/2025 09:04:28 AM (9 months ago)
Author:
starnetwork
Message:

Deploy version 1.0.29 from GitLab CI/CD

Location:
wc-smartpay
Files:
20 added
24 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wc-smartpay/tags/1.0.29/README.md

    r3290978 r3328058  
    11=== SmartPay for WooCommerce ===
    2 Stable tag: 1.0.26
     2Stable tag: 1.0.29
    33Tested up to: 6.4
    44License: GPLv2 or later
     
    9797- https://app11.smartpay.co.il/
    9898- https://api.protected-payment.com/
     99Privacy policy: https://www.smartpay.co.il/privacy-policy/
  • wc-smartpay/tags/1.0.29/assets/js/checkout.js

    r3039963 r3328058  
    1 const settings = window.wc.wcSettings.getSetting( 'wc-smartpay_data', {} );
    2 const label = window.wp.htmlEntities.decodeEntities( settings.title ) || window.wp.i18n.__( 'SmartPay', 'wc-smartpay' );
    3 const Content = () => {
    4     return window.wp.htmlEntities.decodeEntities( settings.description || '' );
    5 };
    6 const Block_Gateway = {
    7     name: 'wc-smartpay',
    8     label: label,
    9     content: Object( window.wp.element.createElement )( Content, null ),
    10     edit: Object( window.wp.element.createElement )( Content, null ),
    11     canMakePayment: () => true,
    12     ariaLabel: label,
    13     supports: {
    14         features: settings.supports,
    15     },
    16 };
    17 window.wc.wcBlocksRegistry.registerPaymentMethod( Block_Gateway );
     1(function(){
     2
     3    const Content = ( settings ) => {
     4        return window.wp.htmlEntities.decodeEntities( settings?.description || '' );
     5    };
     6
     7    const paymentMethodMap = new Map();
     8    paymentMethodMap.set( 'wc-smartpay', {label: window.wp.i18n.__( 'SmartPay', 'wc-smartpay' )} )
     9    paymentMethodMap.set( 'wc-smartpay-applepay', {label: window.wp.i18n.__( 'SmartPay - ApplePay', 'wc-smartpay' )} )
     10    paymentMethodMap.set( 'wc-smartpay-gpay', {label: window.wp.i18n.__( 'SmartPay - Google Pay', 'wc-smartpay' )} )
     11    paymentMethodMap.set( 'wc-smartpay-bitbygrow', {label: window.wp.i18n.__( 'SmartPay - bitByGrow', 'wc-smartpay' )} )
     12    paymentMethodMap.set( 'wc-smartpay-bitbyupay', {label: window.wp.i18n.__( 'SmartPay - bitByUpay', 'wc-smartpay' )} )
     13
     14    paymentMethodMap.forEach(( defaultSettings, paymentMethodCode ) => {
     15        const settings = window.wc.wcSettings.getSetting( paymentMethodCode + '_data', {} );
     16        const label = window.wp.htmlEntities.decodeEntities( settings.title ) || defaultSettings.label;
     17        window.wc.wcBlocksRegistry.registerPaymentMethod( {
     18            name: paymentMethodCode,
     19            label: label,
     20            content: Object( window.wp.element.createElement )( Content, settings ),
     21            edit: Object( window.wp.element.createElement )( Content, settings ),
     22            canMakePayment: () => true,
     23            ariaLabel: label,
     24            supports: {
     25                feature: settings.supports
     26            }
     27        } );
     28    });
     29
     30})();
  • wc-smartpay/tags/1.0.29/includes/class-smartpay-admin.php

    r3207141 r3328058  
    33class Smartpay_Admin
    44{
    5 
    65    /**
    76     * Retrieve request
     
    4039        }
    4140
    42         $payment_gateway   = SmartPay::instance()->get_payment_gateway();
     41        $payment_gateway   = SmartPay::instance()->get_payment_gateway( $order->get_payment_method() );
    4342        $payment_processor = new SmartPay_Payment_Processor( $payment_gateway );
    4443        $result            = $payment_processor->execute( $order );
  • wc-smartpay/tags/1.0.29/includes/class-smartpay-checkout-block.php

    r3040711 r3328058  
    33use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType;
    44
    5 class SmartPay_Checkout_Block extends AbstractPaymentMethodType
    6 {
    7     /** @var SmartPay_Payment_Gateway */
    8     private $gateway;
     5class SmartPay_Checkout_Block extends AbstractPaymentMethodType {
    96
    10     /**
    11      * Initialize
    12      *
    13      * @return void
    14      */
    15     public function initialize()
    16     {
    17         $this->name = Smartpay::instance()->get_app_id();
    18         $this->settings = get_option('woocommerce' . Smartpay::instance()->get_app_id() . '_settings');
    19         $this->gateway = new SmartPay_Payment_Gateway();
    20     }
     7    /** @var string $code */
     8    private $code;
    219
    22     /**
    23      * Check if payment method is active
    24      *
    25      * @return bool
    26      */
    27     public function is_active()
    28     {
    29         return $this->gateway->is_available();
    30     }
     10    /** @var SmartPay_Payment_Gateway */
     11    private $gateway;
    3112
    32     /**
    33      * Add script handle
    34      *
    35      * @return string[]
    36      */
    37     public function get_payment_method_script_handles()
    38     {
    39         $handle = $this->name . '-blocks-integration';
    40         wp_register_script(
    41             $handle,
    42             SmartPay::instance()->get_url('assets/js/checkout.js'),
    43             array(
    44                 'wc-blocks-registry',
    45                 'wc-settings',
    46                 'wp-element',
    47                 'wp-html-entities',
    48                 'wp-i18n'
    49             ),
    50             null,
    51             true
    52         );
     13    /**
     14     * Define class dependencies
     15     *
     16     * @param string $gateway_code
     17     */
     18    public function __construct( $gateway_code ) {
     19        $this->code = $gateway_code;
     20    }
    5321
    54         return array( $handle );
    55     }
     22    /**
     23     * Initialize
     24     *
     25     * @return void
     26     */
     27    public function initialize() {
     28        $this->gateway = SmartPay_Gateway_Resolver::instance()->resolve_by_code( $this->code );
     29        $this->name = $this->gateway->id;
     30        $this->settings = get_option('woocommerce' . $this->gateway->id . '_settings' );
     31    }
    5632
    57     /**
    58      * Retrieve payment method data
    59      *
    60      * @return array
    61      */
    62     public function get_payment_method_data()
    63     {
    64         return array(
    65             'title' => $this->gateway->get_title(),
    66             'description' => $this->gateway->get_description(),
    67             'supports' => $this->gateway->supports
    68         );
    69     }
     33    /**
     34     * Check if payment method is active
     35     *
     36     * @return bool
     37     */
     38    public function is_active() {
     39        return $this->gateway->is_available();
     40    }
     41
     42    /**
     43     * Add script handle
     44     *
     45     * @return string[]
     46     */
     47    public function get_payment_method_script_handles() {
     48        $handle = 'wc-smartpay-blocks-integration';
     49        wp_register_script(
     50            $handle,
     51            SmartPay::instance()->get_url('assets/js/checkout.js' ),
     52            array(
     53                'wc-blocks-registry',
     54                'wc-settings',
     55                'wp-element',
     56                'wp-html-entities',
     57                'wp-i18n'
     58            ),
     59            null,
     60            true
     61        );
     62
     63        return array( $handle );
     64    }
     65
     66    /**
     67     * Retrieve payment method data
     68     *
     69     * @return array
     70     */
     71    public function get_payment_method_data() {
     72        return array(
     73            'title' => $this->gateway->get_title(),
     74            'description' => $this->gateway->get_description(),
     75            'supports' => $this->gateway->supports
     76        );
     77    }
    7078}
  • wc-smartpay/tags/1.0.29/includes/class-smartpay-iframe-renderer.php

    r3031558 r3328058  
    5757         */
    5858        $order             = wc_get_order( $order_id );
    59         $payment_gateway   = SmartPay::instance()->get_payment_gateway();
     59        $payment_gateway   = SmartPay::instance()->get_payment_gateway( $order->get_payment_method() );
    6060        $payment_processor = new SmartPay_Payment_Processor( $payment_gateway );
    6161        $result            = $payment_processor->execute( $order );
  • wc-smartpay/tags/1.0.29/includes/class-smartpay-order-helper.php

    r3290978 r3328058  
    7171            'name'  => implode( ' ',  $name_array),
    7272            'email' => $customer_email,
    73             'phone' => $order->get_billing_phone(),
     73            'phone' => preg_replace('/\D+/i', '', $order->get_billing_phone() ?? ''),
    7474            'billing_address' => [
    7575                [
  • wc-smartpay/tags/1.0.29/includes/class-smartpay-payment-gateway.php

    r3290978 r3328058  
    1616
    1717    /**
     18     * @var string $integration_id
     19     */
     20    protected $integration_id;
     21
     22    /**
    1823     * Payment processor
    1924     *
    2025     * @var SmartPay_Payment_Processor
    2126     */
    22     private $payment_processor;
     27    protected $payment_processor;
    2328
    2429    /**
     
    4045            'pre-orders',
    4146            'products',
    42             'refunds',         
     47            'refunds',
    4348            'subscriptions',
    4449            'multiple_subscriptions',
     
    4954            'subscription_date_changes',
    5055            'subscription_payment_method_change',
    51             'subscription_payment_method_change_admin',         
     56            'subscription_payment_method_change_admin',
    5257            'subscription_payment_method_change_customer',
    5358        );
     59
     60        SmartPay_Gateway_Registry::instance()->register( $this->id, $this);
    5461
    5562        do_action( 'smartpay_payment_gateway_init_after', $this );
     
    6774
    6875        add_action( 'woocommerce_api_smartpay_ipn', array( $this->payment_processor(), 'process_ipn' ) );
    69         add_action( 'woocommerce_thankyou_' . self::METHOD_CODE, array( SmartPay_Iframe_Redirect_Renderer::class, 'render' ), 1, 1 );
     76        add_action( 'woocommerce_thankyou_' . $this->id, array( SmartPay_Iframe_Redirect_Renderer::class, 'render' ), 1, 1 );
     77        add_action( 'woocommerce_receipt_' . $this->id, array( new SmartPay_Iframe_Renderer(), 'render' ) );
    7078
    7179        if ( class_exists( 'WC_Subscriptions_Order' )
     
    8391
    8492    /**
     93     * Retrieve integration id
     94     *
     95     * @return string
     96     */
     97    public function get_integration_id() {
     98        return $this->integration_id;
     99    }
     100
     101    /**
    85102     * Plugin options.
    86103     */
     
    325342     */
    326343    public function admin_options() {
    327         echo '<h3>' . esc_html_e( 'SmartPay', 'wc-smartpay' ) . '</h3>';
     344        (new SmartPay_Admin_Gateway_Menu_Renderer())->render();
     345        echo '<h3>' . esc_html_e( $this->title, 'wc-smartpay' ) . '</h3>';
    328346        echo '<p>';
    329         // phpcs:disable
     347        // phpcs:disable
    330348        printf(
    331349            esc_html( __( 'For more information %s', 'wc-smartpay' ) ),
    332350            esc_url( 'http://www.smartpay.co.il' )
    333351        );
    334         // phpcs:enable
     352        // phpcs:enable
    335353        echo '</p>';
    336354        echo '<table class="form-table">';
     
    354372     * @return SmartPay_Payment_Processor
    355373     */
    356     private function payment_processor() {
     374    protected function payment_processor() {
    357375        if ( ! $this->payment_processor ) {
    358376            $this->payment_processor = new SmartPay_Payment_Processor( $this );
     
    369387    public function process_payment( $order_id ) {
    370388        $order = wc_get_order( $order_id );
    371         if ( SmartPay::instance()->config()->is( 'use_iframe' ) ) {
     389        $payment_method = SmartPay_Gateway_Registry::instance()->get_instance( $order->get_payment_method() );
     390        $use_iframe = $payment_method instanceof SmartPay_Payment_Subgateway
     391            ? $payment_method->config()->is('use_iframe' ) : Smartpay::instance()->config()->is( 'use_iframe' );
     392
     393        if ( $use_iframe ) {
    372394            return array(
    373395                'result'   => 'success',
  • wc-smartpay/tags/1.0.29/includes/class-smartpay-payment-processor.php

    r3290978 r3328058  
    180180
    181181        $send_currency = SmartPay::instance()->config()->get( 'currency' );
     182
     183        $gateway = SmartPay_Gateway_Resolver::instance()->resolve_by_code( $order->get_payment_method() );
    182184        $params        = array(
    183185            'page_uuid'                => SmartPay::instance()->config()->get( 'page_uuid' ),
     
    201203        );
    202204
     205        if ( $gateway instanceof SmartPay_Payment_Subgateway ) {
     206            $params['gateways_to_show'] = [$gateway->get_integration_id()];
     207        }
     208
    203209        $payment_steps = $this->calculate_payment_steps( $order->get_total() );
    204210        if ( ! empty( $payment_steps ) ) {
     
    303309        $payment_details = $order->get_meta( 'smartpay_details' );
    304310
    305         // adding backward compatibility
    306         if ( !$payment_details ) {
    307             $payment_details = get_post_meta( $order->get_id(), 'smartpay_details', true);
    308         }
     311        // adding backward compatibility
     312        if ( !$payment_details ) {
     313            $payment_details = get_post_meta( $order->get_id(), 'smartpay_details', true);
     314        }
    309315
    310316        if ( $payment_details ) {
     
    331337                $params['order_uid'] = $smartpay_order_id;
    332338            } else {
    333                 $params['order_details']['products_details'] = $this->order_helper()->prepare_items($order);
     339                $params['order_details']['products_details'] = $this->order_helper()->prepare_items( $order );
    334340            }
    335341
     
    415421            $order->add_order_note(
    416422                sprintf(
    417                     // translators: %1$s is replaced with "string".
     423                // translators: %1$s is replaced with "string".
    418424                    __( 'Could not refund the order. Reason: %1$s', 'wc-smartpay' ),
    419425                    esc_html( $message )
     
    425431        $order->add_order_note(
    426432            sprintf(
    427                 // translators: %1$s is replaced with "string".
     433            // translators: %1$s is replaced with "string".
    428434                __( 'Order refunded successfully. Transaction id: %1$s', 'wc-smartpay' ),
    429435                esc_html( $response['transaction_id'] )
     
    500506        $order->add_order_note(
    501507            sprintf(
    502                 // translators: %1$s is replaced with "string".
    503                 // translators: %2$s is replaced with "string".
     508            // translators: %1$s is replaced with "string".
     509            // translators: %2$s is replaced with "string".
    504510                __( 'Action param: %1$s. Status %2$s', 'wc-smartpay' ),
    505511                $data_object->transaction['action_param'] ?? null,
     
    691697        // exit if there was no POST data passed.
    692698        $order = new WC_Order( $order_id );
    693         if ( $order->get_payment_method() !== SmartPay_Payment_Gateway::METHOD_CODE || $order->get_transaction_id() ) {
     699
     700        $allowed_payment_methods = SmartPay_Gateway_Registry::instance()->get_all();
     701        if ( !isset( $allowed_payment_methods[ $order->get_payment_method() ] ) || $order->get_transaction_id() ) {
    694702            return;
    695703        }
     
    733741            $order->add_order_note(
    734742                sprintf(
    735                     // translators: %1$s is replaced with "string".
    736                     // translators: %2$s is replaced with "string".
     743                // translators: %1$s is replaced with "string".
     744                // translators: %2$s is replaced with "string".
    737745                    __( 'Action param: %1$s. Status %2$s', 'wc-smartpay' ),
    738746                    $response_object->action_param ?? null,
     
    841849            $this->logger()->log($order_id, 'ERROR', $e->getMessage());
    842850        }
    843 
    844851    }
    845852}
  • wc-smartpay/tags/1.0.29/includes/class-smartpay.php

    r3290978 r3328058  
    1616     * @var string
    1717     */
    18     private $version = '1.0.26';
     18    private $version = '1.0.29';
    1919
    2020    /**
     
    7979     */
    8080    private function __construct() {
    81         add_action( 'woocommerce_blocks_loaded', array( $this, 'enable_blocks_support') );
     81        add_action( 'woocommerce_blocks_loaded', array( $this, 'enable_blocks_support' ) );
    8282        add_action( 'woocommerce_init', array( $this, 'init_hooks' ) );
    8383        add_filter( 'auto_update_plugin', array( $this, 'enable_auto_updates' ), 10, 2 );
     
    164164        add_action( 'smartpay_payment_gateway_init_after', array( $this, 'init_config' ) );
    165165        add_filter( 'woocommerce_payment_gateways', array( $this, 'register_payment_method' ) );
    166         add_action( 'woocommerce_receipt_' . $this->get_app_id(), array( new SmartPay_Iframe_Renderer(), 'render' ) );
    167         add_filter( 'billi_can_sync_invoice', array( SmartPay_Billi_Observer::instance(), 'can_sync_invoice' ), 10, 2 );
     166
     167        add_filter( 'billi_can_sync_invoice', array( SmartPay_Invoice_Observer::instance(), 'can_sync_invoice' ), 10, 2 );
     168        add_filter( 'wc_smartpay_invoices_can_sync_invoice', array(
     169            SmartPay_Invoice_Observer::instance(),
     170            'can_sync_invoice'
     171        ), 10, 2 );
    168172        add_action( 'wp_footer', array( new SmartPay_Iframe_Return_Type_Top_Footer_Renderer(), 'render' ) );
    169173        add_action( 'template_redirect', array( new SmartPay_Success(), 'process') );
     
    205209    }
    206210
    207     /**
    208      * @return void
    209      */
    210     public function enable_blocks_support()
    211     {
    212         if ( class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType' ) ) {
    213             add_action(
    214                 'woocommerce_blocks_payment_method_type_registration',
    215                 function( $payment_method_registry ) {
    216                     $payment_method_registry->register( new SmartPay_Checkout_Block() );
    217                 }
    218             );
    219         }
    220     }
     211    /**
     212     * @return void
     213     */
     214    public function enable_blocks_support() {
     215        if ( class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType' ) ) {
     216            foreach ( SmartPay_Gateway_Resolver::instance()->all() as $gateway_code => $gateway_class ) {
     217                add_action(
     218                    'woocommerce_blocks_payment_method_type_registration',
     219                    function( $payment_method_registry ) use ( $gateway_code ) {
     220                        $payment_method_registry->register( new SmartPay_Checkout_Block( $gateway_code ) );
     221                    }
     222                );
     223            }
     224        }
     225    }
    221226
    222227    /**
     
    281286     * @return SmartPay_Payment_Gateway|null
    282287     */
    283     public function get_payment_gateway() {
    284         $payment_gateways = WC()->payment_gateways() ? WC()->payment_gateways()->payment_gateways() : array();
    285         foreach ( $payment_gateways  as $payment_gateway ) {
    286             if ( $payment_gateway instanceof SmartPay_Payment_Gateway ) {
    287                 return $payment_gateway;
    288             }
    289         }
    290         return null;
     288    public function get_payment_gateway( $gateway_code ) {
     289        return SmartPay_Gateway_Resolver::instance()->resolve_by_code( $gateway_code );
    291290    }
    292291
     
    333332     *
    334333     * @param array $methods payment methods list.
    335      * @return mixed
     334     * @return array
    336335     */
    337336    public function register_payment_method( $methods ) {
    338         array_push( $methods, new SmartPay_Payment_Gateway() );
    339         return $methods;
     337        return array_merge( $methods,  SmartPay_Gateway_Resolver::instance()->all() );
    340338    }
    341339
     
    349347    public function add_capture_action( $actions, $order ) {
    350348
    351         if ( $order->get_payment_method() !== SmartPay_Payment_Gateway::METHOD_CODE
     349        $allowed_methods = array_keys( SmartPay_Gateway_Registry::instance()->get_all() );
     350
     351        if ( !in_array( $order->get_payment_method(), $allowed_methods)
    352352            || $order->get_meta( 'action_param' ) === 'capture'
    353353        ) {
  • wc-smartpay/tags/1.0.29/readme.txt

    r3290979 r3328058  
    11=== SmartPay for WooCommerce ===
    2 Stable tag: 1.0.26
     2Stable tag: 1.0.29
    33Tested up to: 6.7.2
    44License: GPLv2 or later
     
    4545## Changelog
    4646
     47### 1.0.28
     48- added phone number sanitization
     49
     50### 1.0.27
     51- added support for BitByGrow, BitByUpay, ApplePay, Google Pay
     52
    4753### 1.0.26
    4854- new Orders sync feature
     
    7278- https://app11.smartpay.co.il/
    7379- https://api.protected-payment.com/
     80Privacy policy: https://www.smartpay.co.il/privacy-policy/
  • wc-smartpay/tags/1.0.29/smartpay.php

    r3290978 r3328058  
    44 * Plugin URI: https://smartpay.co.il/
    55 * Description: SmartPay payment plugin for WooCommerce
    6  * Version:     1.0.26
     6 * Version:     1.0.29
    77 * Author:      SmartPay
    88 * License:     GPLv2 or later
     
    1515defined( 'ABSPATH' ) || exit;
    1616
    17 define( 'SMARTPAY_VERSION', '1.0.26' );
     17define( 'SMARTPAY_VERSION', '1.0.29' );
    1818
    1919if ( ! defined( 'SMARTPAY_PLUGIN_FILE' ) ) {
  • wc-smartpay/tags/1.0.29/templates/iframe.php

    r3031558 r3328058  
    1313            name="smartpayiframe"
    1414            id="smartpayiframe"
     15            payment="allow"
    1516            width="<?php echo esc_attr( $this->iframe_width ); ?>"
    1617            height="<?php echo esc_attr( $this->iframe_height ); ?>" frameBorder="0">
  • wc-smartpay/trunk/README.md

    r3290978 r3328058  
    11=== SmartPay for WooCommerce ===
    2 Stable tag: 1.0.26
     2Stable tag: 1.0.29
    33Tested up to: 6.4
    44License: GPLv2 or later
     
    9797- https://app11.smartpay.co.il/
    9898- https://api.protected-payment.com/
     99Privacy policy: https://www.smartpay.co.il/privacy-policy/
  • wc-smartpay/trunk/assets/js/checkout.js

    r3039963 r3328058  
    1 const settings = window.wc.wcSettings.getSetting( 'wc-smartpay_data', {} );
    2 const label = window.wp.htmlEntities.decodeEntities( settings.title ) || window.wp.i18n.__( 'SmartPay', 'wc-smartpay' );
    3 const Content = () => {
    4     return window.wp.htmlEntities.decodeEntities( settings.description || '' );
    5 };
    6 const Block_Gateway = {
    7     name: 'wc-smartpay',
    8     label: label,
    9     content: Object( window.wp.element.createElement )( Content, null ),
    10     edit: Object( window.wp.element.createElement )( Content, null ),
    11     canMakePayment: () => true,
    12     ariaLabel: label,
    13     supports: {
    14         features: settings.supports,
    15     },
    16 };
    17 window.wc.wcBlocksRegistry.registerPaymentMethod( Block_Gateway );
     1(function(){
     2
     3    const Content = ( settings ) => {
     4        return window.wp.htmlEntities.decodeEntities( settings?.description || '' );
     5    };
     6
     7    const paymentMethodMap = new Map();
     8    paymentMethodMap.set( 'wc-smartpay', {label: window.wp.i18n.__( 'SmartPay', 'wc-smartpay' )} )
     9    paymentMethodMap.set( 'wc-smartpay-applepay', {label: window.wp.i18n.__( 'SmartPay - ApplePay', 'wc-smartpay' )} )
     10    paymentMethodMap.set( 'wc-smartpay-gpay', {label: window.wp.i18n.__( 'SmartPay - Google Pay', 'wc-smartpay' )} )
     11    paymentMethodMap.set( 'wc-smartpay-bitbygrow', {label: window.wp.i18n.__( 'SmartPay - bitByGrow', 'wc-smartpay' )} )
     12    paymentMethodMap.set( 'wc-smartpay-bitbyupay', {label: window.wp.i18n.__( 'SmartPay - bitByUpay', 'wc-smartpay' )} )
     13
     14    paymentMethodMap.forEach(( defaultSettings, paymentMethodCode ) => {
     15        const settings = window.wc.wcSettings.getSetting( paymentMethodCode + '_data', {} );
     16        const label = window.wp.htmlEntities.decodeEntities( settings.title ) || defaultSettings.label;
     17        window.wc.wcBlocksRegistry.registerPaymentMethod( {
     18            name: paymentMethodCode,
     19            label: label,
     20            content: Object( window.wp.element.createElement )( Content, settings ),
     21            edit: Object( window.wp.element.createElement )( Content, settings ),
     22            canMakePayment: () => true,
     23            ariaLabel: label,
     24            supports: {
     25                feature: settings.supports
     26            }
     27        } );
     28    });
     29
     30})();
  • wc-smartpay/trunk/includes/class-smartpay-admin.php

    r3207141 r3328058  
    33class Smartpay_Admin
    44{
    5 
    65    /**
    76     * Retrieve request
     
    4039        }
    4140
    42         $payment_gateway   = SmartPay::instance()->get_payment_gateway();
     41        $payment_gateway   = SmartPay::instance()->get_payment_gateway( $order->get_payment_method() );
    4342        $payment_processor = new SmartPay_Payment_Processor( $payment_gateway );
    4443        $result            = $payment_processor->execute( $order );
  • wc-smartpay/trunk/includes/class-smartpay-checkout-block.php

    r3040711 r3328058  
    33use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType;
    44
    5 class SmartPay_Checkout_Block extends AbstractPaymentMethodType
    6 {
    7     /** @var SmartPay_Payment_Gateway */
    8     private $gateway;
     5class SmartPay_Checkout_Block extends AbstractPaymentMethodType {
    96
    10     /**
    11      * Initialize
    12      *
    13      * @return void
    14      */
    15     public function initialize()
    16     {
    17         $this->name = Smartpay::instance()->get_app_id();
    18         $this->settings = get_option('woocommerce' . Smartpay::instance()->get_app_id() . '_settings');
    19         $this->gateway = new SmartPay_Payment_Gateway();
    20     }
     7    /** @var string $code */
     8    private $code;
    219
    22     /**
    23      * Check if payment method is active
    24      *
    25      * @return bool
    26      */
    27     public function is_active()
    28     {
    29         return $this->gateway->is_available();
    30     }
     10    /** @var SmartPay_Payment_Gateway */
     11    private $gateway;
    3112
    32     /**
    33      * Add script handle
    34      *
    35      * @return string[]
    36      */
    37     public function get_payment_method_script_handles()
    38     {
    39         $handle = $this->name . '-blocks-integration';
    40         wp_register_script(
    41             $handle,
    42             SmartPay::instance()->get_url('assets/js/checkout.js'),
    43             array(
    44                 'wc-blocks-registry',
    45                 'wc-settings',
    46                 'wp-element',
    47                 'wp-html-entities',
    48                 'wp-i18n'
    49             ),
    50             null,
    51             true
    52         );
     13    /**
     14     * Define class dependencies
     15     *
     16     * @param string $gateway_code
     17     */
     18    public function __construct( $gateway_code ) {
     19        $this->code = $gateway_code;
     20    }
    5321
    54         return array( $handle );
    55     }
     22    /**
     23     * Initialize
     24     *
     25     * @return void
     26     */
     27    public function initialize() {
     28        $this->gateway = SmartPay_Gateway_Resolver::instance()->resolve_by_code( $this->code );
     29        $this->name = $this->gateway->id;
     30        $this->settings = get_option('woocommerce' . $this->gateway->id . '_settings' );
     31    }
    5632
    57     /**
    58      * Retrieve payment method data
    59      *
    60      * @return array
    61      */
    62     public function get_payment_method_data()
    63     {
    64         return array(
    65             'title' => $this->gateway->get_title(),
    66             'description' => $this->gateway->get_description(),
    67             'supports' => $this->gateway->supports
    68         );
    69     }
     33    /**
     34     * Check if payment method is active
     35     *
     36     * @return bool
     37     */
     38    public function is_active() {
     39        return $this->gateway->is_available();
     40    }
     41
     42    /**
     43     * Add script handle
     44     *
     45     * @return string[]
     46     */
     47    public function get_payment_method_script_handles() {
     48        $handle = 'wc-smartpay-blocks-integration';
     49        wp_register_script(
     50            $handle,
     51            SmartPay::instance()->get_url('assets/js/checkout.js' ),
     52            array(
     53                'wc-blocks-registry',
     54                'wc-settings',
     55                'wp-element',
     56                'wp-html-entities',
     57                'wp-i18n'
     58            ),
     59            null,
     60            true
     61        );
     62
     63        return array( $handle );
     64    }
     65
     66    /**
     67     * Retrieve payment method data
     68     *
     69     * @return array
     70     */
     71    public function get_payment_method_data() {
     72        return array(
     73            'title' => $this->gateway->get_title(),
     74            'description' => $this->gateway->get_description(),
     75            'supports' => $this->gateway->supports
     76        );
     77    }
    7078}
  • wc-smartpay/trunk/includes/class-smartpay-iframe-renderer.php

    r3031558 r3328058  
    5757         */
    5858        $order             = wc_get_order( $order_id );
    59         $payment_gateway   = SmartPay::instance()->get_payment_gateway();
     59        $payment_gateway   = SmartPay::instance()->get_payment_gateway( $order->get_payment_method() );
    6060        $payment_processor = new SmartPay_Payment_Processor( $payment_gateway );
    6161        $result            = $payment_processor->execute( $order );
  • wc-smartpay/trunk/includes/class-smartpay-order-helper.php

    r3290978 r3328058  
    7171            'name'  => implode( ' ',  $name_array),
    7272            'email' => $customer_email,
    73             'phone' => $order->get_billing_phone(),
     73            'phone' => preg_replace('/\D+/i', '', $order->get_billing_phone() ?? ''),
    7474            'billing_address' => [
    7575                [
  • wc-smartpay/trunk/includes/class-smartpay-payment-gateway.php

    r3290978 r3328058  
    1616
    1717    /**
     18     * @var string $integration_id
     19     */
     20    protected $integration_id;
     21
     22    /**
    1823     * Payment processor
    1924     *
    2025     * @var SmartPay_Payment_Processor
    2126     */
    22     private $payment_processor;
     27    protected $payment_processor;
    2328
    2429    /**
     
    4045            'pre-orders',
    4146            'products',
    42             'refunds',         
     47            'refunds',
    4348            'subscriptions',
    4449            'multiple_subscriptions',
     
    4954            'subscription_date_changes',
    5055            'subscription_payment_method_change',
    51             'subscription_payment_method_change_admin',         
     56            'subscription_payment_method_change_admin',
    5257            'subscription_payment_method_change_customer',
    5358        );
     59
     60        SmartPay_Gateway_Registry::instance()->register( $this->id, $this);
    5461
    5562        do_action( 'smartpay_payment_gateway_init_after', $this );
     
    6774
    6875        add_action( 'woocommerce_api_smartpay_ipn', array( $this->payment_processor(), 'process_ipn' ) );
    69         add_action( 'woocommerce_thankyou_' . self::METHOD_CODE, array( SmartPay_Iframe_Redirect_Renderer::class, 'render' ), 1, 1 );
     76        add_action( 'woocommerce_thankyou_' . $this->id, array( SmartPay_Iframe_Redirect_Renderer::class, 'render' ), 1, 1 );
     77        add_action( 'woocommerce_receipt_' . $this->id, array( new SmartPay_Iframe_Renderer(), 'render' ) );
    7078
    7179        if ( class_exists( 'WC_Subscriptions_Order' )
     
    8391
    8492    /**
     93     * Retrieve integration id
     94     *
     95     * @return string
     96     */
     97    public function get_integration_id() {
     98        return $this->integration_id;
     99    }
     100
     101    /**
    85102     * Plugin options.
    86103     */
     
    325342     */
    326343    public function admin_options() {
    327         echo '<h3>' . esc_html_e( 'SmartPay', 'wc-smartpay' ) . '</h3>';
     344        (new SmartPay_Admin_Gateway_Menu_Renderer())->render();
     345        echo '<h3>' . esc_html_e( $this->title, 'wc-smartpay' ) . '</h3>';
    328346        echo '<p>';
    329         // phpcs:disable
     347        // phpcs:disable
    330348        printf(
    331349            esc_html( __( 'For more information %s', 'wc-smartpay' ) ),
    332350            esc_url( 'http://www.smartpay.co.il' )
    333351        );
    334         // phpcs:enable
     352        // phpcs:enable
    335353        echo '</p>';
    336354        echo '<table class="form-table">';
     
    354372     * @return SmartPay_Payment_Processor
    355373     */
    356     private function payment_processor() {
     374    protected function payment_processor() {
    357375        if ( ! $this->payment_processor ) {
    358376            $this->payment_processor = new SmartPay_Payment_Processor( $this );
     
    369387    public function process_payment( $order_id ) {
    370388        $order = wc_get_order( $order_id );
    371         if ( SmartPay::instance()->config()->is( 'use_iframe' ) ) {
     389        $payment_method = SmartPay_Gateway_Registry::instance()->get_instance( $order->get_payment_method() );
     390        $use_iframe = $payment_method instanceof SmartPay_Payment_Subgateway
     391            ? $payment_method->config()->is('use_iframe' ) : Smartpay::instance()->config()->is( 'use_iframe' );
     392
     393        if ( $use_iframe ) {
    372394            return array(
    373395                'result'   => 'success',
  • wc-smartpay/trunk/includes/class-smartpay-payment-processor.php

    r3290978 r3328058  
    180180
    181181        $send_currency = SmartPay::instance()->config()->get( 'currency' );
     182
     183        $gateway = SmartPay_Gateway_Resolver::instance()->resolve_by_code( $order->get_payment_method() );
    182184        $params        = array(
    183185            'page_uuid'                => SmartPay::instance()->config()->get( 'page_uuid' ),
     
    201203        );
    202204
     205        if ( $gateway instanceof SmartPay_Payment_Subgateway ) {
     206            $params['gateways_to_show'] = [$gateway->get_integration_id()];
     207        }
     208
    203209        $payment_steps = $this->calculate_payment_steps( $order->get_total() );
    204210        if ( ! empty( $payment_steps ) ) {
     
    303309        $payment_details = $order->get_meta( 'smartpay_details' );
    304310
    305         // adding backward compatibility
    306         if ( !$payment_details ) {
    307             $payment_details = get_post_meta( $order->get_id(), 'smartpay_details', true);
    308         }
     311        // adding backward compatibility
     312        if ( !$payment_details ) {
     313            $payment_details = get_post_meta( $order->get_id(), 'smartpay_details', true);
     314        }
    309315
    310316        if ( $payment_details ) {
     
    331337                $params['order_uid'] = $smartpay_order_id;
    332338            } else {
    333                 $params['order_details']['products_details'] = $this->order_helper()->prepare_items($order);
     339                $params['order_details']['products_details'] = $this->order_helper()->prepare_items( $order );
    334340            }
    335341
     
    415421            $order->add_order_note(
    416422                sprintf(
    417                     // translators: %1$s is replaced with "string".
     423                // translators: %1$s is replaced with "string".
    418424                    __( 'Could not refund the order. Reason: %1$s', 'wc-smartpay' ),
    419425                    esc_html( $message )
     
    425431        $order->add_order_note(
    426432            sprintf(
    427                 // translators: %1$s is replaced with "string".
     433            // translators: %1$s is replaced with "string".
    428434                __( 'Order refunded successfully. Transaction id: %1$s', 'wc-smartpay' ),
    429435                esc_html( $response['transaction_id'] )
     
    500506        $order->add_order_note(
    501507            sprintf(
    502                 // translators: %1$s is replaced with "string".
    503                 // translators: %2$s is replaced with "string".
     508            // translators: %1$s is replaced with "string".
     509            // translators: %2$s is replaced with "string".
    504510                __( 'Action param: %1$s. Status %2$s', 'wc-smartpay' ),
    505511                $data_object->transaction['action_param'] ?? null,
     
    691697        // exit if there was no POST data passed.
    692698        $order = new WC_Order( $order_id );
    693         if ( $order->get_payment_method() !== SmartPay_Payment_Gateway::METHOD_CODE || $order->get_transaction_id() ) {
     699
     700        $allowed_payment_methods = SmartPay_Gateway_Registry::instance()->get_all();
     701        if ( !isset( $allowed_payment_methods[ $order->get_payment_method() ] ) || $order->get_transaction_id() ) {
    694702            return;
    695703        }
     
    733741            $order->add_order_note(
    734742                sprintf(
    735                     // translators: %1$s is replaced with "string".
    736                     // translators: %2$s is replaced with "string".
     743                // translators: %1$s is replaced with "string".
     744                // translators: %2$s is replaced with "string".
    737745                    __( 'Action param: %1$s. Status %2$s', 'wc-smartpay' ),
    738746                    $response_object->action_param ?? null,
     
    841849            $this->logger()->log($order_id, 'ERROR', $e->getMessage());
    842850        }
    843 
    844851    }
    845852}
  • wc-smartpay/trunk/includes/class-smartpay.php

    r3290978 r3328058  
    1616     * @var string
    1717     */
    18     private $version = '1.0.26';
     18    private $version = '1.0.29';
    1919
    2020    /**
     
    7979     */
    8080    private function __construct() {
    81         add_action( 'woocommerce_blocks_loaded', array( $this, 'enable_blocks_support') );
     81        add_action( 'woocommerce_blocks_loaded', array( $this, 'enable_blocks_support' ) );
    8282        add_action( 'woocommerce_init', array( $this, 'init_hooks' ) );
    8383        add_filter( 'auto_update_plugin', array( $this, 'enable_auto_updates' ), 10, 2 );
     
    164164        add_action( 'smartpay_payment_gateway_init_after', array( $this, 'init_config' ) );
    165165        add_filter( 'woocommerce_payment_gateways', array( $this, 'register_payment_method' ) );
    166         add_action( 'woocommerce_receipt_' . $this->get_app_id(), array( new SmartPay_Iframe_Renderer(), 'render' ) );
    167         add_filter( 'billi_can_sync_invoice', array( SmartPay_Billi_Observer::instance(), 'can_sync_invoice' ), 10, 2 );
     166
     167        add_filter( 'billi_can_sync_invoice', array( SmartPay_Invoice_Observer::instance(), 'can_sync_invoice' ), 10, 2 );
     168        add_filter( 'wc_smartpay_invoices_can_sync_invoice', array(
     169            SmartPay_Invoice_Observer::instance(),
     170            'can_sync_invoice'
     171        ), 10, 2 );
    168172        add_action( 'wp_footer', array( new SmartPay_Iframe_Return_Type_Top_Footer_Renderer(), 'render' ) );
    169173        add_action( 'template_redirect', array( new SmartPay_Success(), 'process') );
     
    205209    }
    206210
    207     /**
    208      * @return void
    209      */
    210     public function enable_blocks_support()
    211     {
    212         if ( class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType' ) ) {
    213             add_action(
    214                 'woocommerce_blocks_payment_method_type_registration',
    215                 function( $payment_method_registry ) {
    216                     $payment_method_registry->register( new SmartPay_Checkout_Block() );
    217                 }
    218             );
    219         }
    220     }
     211    /**
     212     * @return void
     213     */
     214    public function enable_blocks_support() {
     215        if ( class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType' ) ) {
     216            foreach ( SmartPay_Gateway_Resolver::instance()->all() as $gateway_code => $gateway_class ) {
     217                add_action(
     218                    'woocommerce_blocks_payment_method_type_registration',
     219                    function( $payment_method_registry ) use ( $gateway_code ) {
     220                        $payment_method_registry->register( new SmartPay_Checkout_Block( $gateway_code ) );
     221                    }
     222                );
     223            }
     224        }
     225    }
    221226
    222227    /**
     
    281286     * @return SmartPay_Payment_Gateway|null
    282287     */
    283     public function get_payment_gateway() {
    284         $payment_gateways = WC()->payment_gateways() ? WC()->payment_gateways()->payment_gateways() : array();
    285         foreach ( $payment_gateways  as $payment_gateway ) {
    286             if ( $payment_gateway instanceof SmartPay_Payment_Gateway ) {
    287                 return $payment_gateway;
    288             }
    289         }
    290         return null;
     288    public function get_payment_gateway( $gateway_code ) {
     289        return SmartPay_Gateway_Resolver::instance()->resolve_by_code( $gateway_code );
    291290    }
    292291
     
    333332     *
    334333     * @param array $methods payment methods list.
    335      * @return mixed
     334     * @return array
    336335     */
    337336    public function register_payment_method( $methods ) {
    338         array_push( $methods, new SmartPay_Payment_Gateway() );
    339         return $methods;
     337        return array_merge( $methods,  SmartPay_Gateway_Resolver::instance()->all() );
    340338    }
    341339
     
    349347    public function add_capture_action( $actions, $order ) {
    350348
    351         if ( $order->get_payment_method() !== SmartPay_Payment_Gateway::METHOD_CODE
     349        $allowed_methods = array_keys( SmartPay_Gateway_Registry::instance()->get_all() );
     350
     351        if ( !in_array( $order->get_payment_method(), $allowed_methods)
    352352            || $order->get_meta( 'action_param' ) === 'capture'
    353353        ) {
  • wc-smartpay/trunk/readme.txt

    r3290979 r3328058  
    11=== SmartPay for WooCommerce ===
    2 Stable tag: 1.0.26
     2Stable tag: 1.0.29
    33Tested up to: 6.7.2
    44License: GPLv2 or later
     
    4545## Changelog
    4646
     47### 1.0.28
     48- added phone number sanitization
     49
     50### 1.0.27
     51- added support for BitByGrow, BitByUpay, ApplePay, Google Pay
     52
    4753### 1.0.26
    4854- new Orders sync feature
     
    7278- https://app11.smartpay.co.il/
    7379- https://api.protected-payment.com/
     80Privacy policy: https://www.smartpay.co.il/privacy-policy/
  • wc-smartpay/trunk/smartpay.php

    r3290978 r3328058  
    44 * Plugin URI: https://smartpay.co.il/
    55 * Description: SmartPay payment plugin for WooCommerce
    6  * Version:     1.0.26
     6 * Version:     1.0.29
    77 * Author:      SmartPay
    88 * License:     GPLv2 or later
     
    1515defined( 'ABSPATH' ) || exit;
    1616
    17 define( 'SMARTPAY_VERSION', '1.0.26' );
     17define( 'SMARTPAY_VERSION', '1.0.29' );
    1818
    1919if ( ! defined( 'SMARTPAY_PLUGIN_FILE' ) ) {
  • wc-smartpay/trunk/templates/iframe.php

    r3031558 r3328058  
    1313            name="smartpayiframe"
    1414            id="smartpayiframe"
     15            payment="allow"
    1516            width="<?php echo esc_attr( $this->iframe_width ); ?>"
    1617            height="<?php echo esc_attr( $this->iframe_height ); ?>" frameBorder="0">
Note: See TracChangeset for help on using the changeset viewer.