Plugin Directory

Changeset 2886423


Ignore:
Timestamp:
03/24/2023 01:04:44 PM (3 years ago)
Author:
tabbyai
Message:

Qatar support, WP 6.2 compatibility

Location:
tabby-checkout/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • tabby-checkout/trunk/includes/class-wc-gateway-tabby-checkout-base.php

    r2828572 r2886423  
    125125                if (static::TABBY_METHOD_CODE == 'creditCardInstallments') $jsClass = 'TabbyPaymentMethodSnippetCCI';
    126126                echo '<div id="'.esc_attr($divId).'"></div>';
    127                 echo '<script>  new '.esc_js($jsClass).'(' . $this->getTabbyCardJsonConfig($divId) .');</script>';
     127                echo '<script>  if (typeof '.esc_js($jsClass).' !== \'undefined\') new '.esc_js($jsClass).'(' . $this->getTabbyCardJsonConfig($divId) .');</script>';
    128128                break;
    129129            case 2:
  • tabby-checkout/trunk/includes/class-wc-settings-tab-tabby.php

    r2828572 r2886423  
    142142            );
    143143            $settings_tabby[] = array(
     144                'name'     => __( 'Promotion snippets (additional settings)', 'tabby-checkout' ),
     145                'id'       => 'tabby_checkout_promo_type_price',
     146                'type'     => 'text',
     147                'desc'     => __( 'Please use this settings only in case if you have the recommendations from Tabby team.<br />
     148<br />
     149Set up -1 for Standard promotion snippets as a default value<br />
     150Set up 0 for Credit Card installments promotion snippets as a default value<br />
     151Set up the limit between 0 - 50000 to show Standard promotion snippets for the amount which is  lower than the limit and Credit Card installments promotion snippets for the amount which is higher than the limit. ', 'tabby-checkout' ),
     152                'type'              => 'number',
     153                'custom_attributes' => array(
     154                    'min'  => -1,
     155                    'step' => 1,
     156                ),
     157                'css'               => 'width: 80px;',
     158                'default'           => '-1',
     159                'autoload'          => false,
     160            );
     161            $settings_tabby[] = array(
    144162                'name'     => __( 'Tabby promotions theme', 'tabby-checkout' ),
    145163                'id'       => 'tabby_checkout_promo_theme',
  • tabby-checkout/trunk/includes/class-wc-tabby-config.php

    r2828572 r2886423  
    22
    33class WC_Tabby_Config {
    4     const ALLOWED_CURRENCIES = ['AED','SAR','BHD','KWD', 'EGP'];
    5     const ALLOWED_COUNTRIES  = [ 'AE', 'SA', 'BH', 'KW',  'EG'];
     4    const ALLOWED_CURRENCIES = ['AED','SAR','BHD','KWD', 'EGP', 'QAR'];
     5    const ALLOWED_COUNTRIES  = [ 'AE', 'SA', 'BH', 'KW',  'EG',  'QA'];
    66
    77    public static function isAvailableForCountry($country_code) {
  • tabby-checkout/trunk/includes/class-wc-tabby-promo.php

    r2828572 r2886423  
    77    }
    88    public static function wp_enqueue_scripts() {
    9         if (is_checkout()) {
     9        if (is_checkout()) {
    1010            // css
    1111            wp_enqueue_style('tabby-checkout', plugins_url('css/tabby.css', dirname(__FILE__)));
    1212            // js
    13             wp_enqueue_script('tabby-checkout-integration', 'https://'.TABBY_CHECKOUT_DOMAIN.'/integration.js', [], null, true);
    14             wp_enqueue_script('tabby-checkout-tabby-js', plugins_url('js/tabby.js', dirname(__FILE__)), [], MODULE_TABBY_CHECKOUT_VERSION, true);
     13            wp_enqueue_script('tabby-checkout-integration', 'https://'.TABBY_CHECKOUT_DOMAIN.'/cms-plugins.js', [], null, true);
     14            wp_enqueue_script('tabby-checkout-tabby-js', plugins_url('js/tabby.js', dirname(__FILE__)), [], MODULE_TABBY_CHECKOUT_VERSION, true);
     15        };
    1516
    16             if ($config = get_option('woocommerce_tabby_installments_settings')) {
    17                 if (!array_key_exists('description_type', $config) || $config['description_type'] < 2) {
    18                     wp_enqueue_script('tabby-checkout-tabby-card', 'https://'.TABBY_CHECKOUT_DOMAIN.'/tabby-card.js', [], null, true);
    19                 }
    20             };
    21 
    22             if ($config = get_option('woocommerce_tabby_credit_card_installments_settings')) {
    23                 if (!array_key_exists('description_type', $config) || $config['description_type'] < 2) {
    24                     wp_enqueue_script('tabby-checkout-cci', 'https://'.TABBY_CHECKOUT_DOMAIN.'/tabby-payment-method-snippet-cci.js', [], null, true);
    25                 }
    26             };
    27        
    28         };
    29         if ((is_product() || is_cart()) && static::is_tabby_promo_enabled()) {
    30             wp_enqueue_script('tabby-checkout-promo', 'https://'.TABBY_CHECKOUT_DOMAIN.'/tabby-promo.js', [], null, true);
     17        if ((is_product() || is_cart()) && static::is_tabby_promo_enabled()) {
     18            wp_enqueue_script('tabby-checkout-promo', 'https://'.TABBY_CHECKOUT_DOMAIN.'/tabby-promo.js', [], null, true);
    3119            static::product_promotion_scripts();
    3220        };
     
    10997    }
    11098    public static function getProductType() {
    111         return self::isCreditCardInstallmentsActive() && !self::isInstallmentsOrPayLaterActive() ? 'creditCardInstallments' : 'installments';
     99        return self::isCreditCardInstallmentsActive() && (!self::isInstallmentsOrPayLaterActive() || self::isCreditCardInstallmentsActiveByPrice()) ? 'creditCardInstallments' : 'installments';
    112100    }
    113101    public static function isInstallmentsOrPayLaterActive() {
    114         require_once dirname(__FILE__) . '/class-wc-gateway-tabby-paylater.php';
    115102        require_once dirname(__FILE__) . '/class-wc-gateway-tabby-installments.php';
    116         $payLater = new WC_Gateway_Tabby_PayLater();
    117         $payLater->init_settings();
    118103        $installments = new WC_Gateway_Tabby_Installments();
    119104        $installments->init_settings();
    120         return ($installments->enabled == 'yes') || ($payLater->enabled == 'yes');
     105        return ($installments->enabled == 'yes');
    121106    }
    122107    public static function isCreditCardInstallmentsActive() {
     
    125110        $cci->init_settings();
    126111        return $cci->enabled == 'yes';
     112    }
     113    public static function isCreditCardInstallmentsActiveByPrice() {
     114        $type_price = get_option('tabby_checkout_promo_type_price', -1);
     115       
     116        return $type_price >= 0 && self::getPrice() >= $type_price;
    127117    }
    128118    public static function getTheme() {
  • tabby-checkout/trunk/js/tabby.js

    r2828572 r2886423  
    11jQuery(document).ready(function () {
    2     jQuery('form.checkout input').on('change', updateTabbyCheckout);
    3     jQuery(document.body).on('updated_checkout', updateTabbyCheckout);
    4    
    5     function updateTabbyCheckout() {
    6         if (!window.tabbyRenderer) window.tabbyRenderer = new TabbyRenderer();
    7         tabbyRenderer.update();
    8     }
     2    jQuery('form.checkout input').on('change', updateTabbyCheckout);
     3    jQuery(document.body).on('updated_checkout', updateTabbyCheckout);
     4   
     5    function updateTabbyCheckout() {
     6        if (!window.tabbyRenderer) window.tabbyRenderer = new TabbyRenderer();
     7        tabbyRenderer.update();
     8    }
    99
    1010    updateTabbyCheckout();
    1111});
    1212class TabbyRenderer {
    13     constructor () {
    14         this.payment = null;
    15         this.email = null;
    16         this.phone = null;
    17         this.lastMethod = null;
    18         this.paymentAuthorized = false;
    19         this.methods = {
    20             creditCardInstallments: 'credit_card_installments',
    21             installments: 'installments',
    22             payLater: 'pay_later'
    23         };
    24         this.products = [];
    25         this.product = null;
     13    constructor () {
     14        this.payment = null;
     15        this.email = null;
     16        this.phone = null;
     17        this.lastMethod = null;
     18        this.methods = {
     19            creditCardInstallments: 'credit_card_installments',
     20            installments: 'installments',
     21            payLater: 'pay_later'
     22        };
     23        this.products = [];
     24        this.product = null;
    2625        this.formFilled = false;
    2726        this.formSubmitted = false;
    28         // update payment modules on phone/email change
    29         jQuery( 'form.checkout' ).on(
    30             'change',
    31             '#billing_email, #billing_phone',
    32             function () {jQuery( document.body ).trigger('update_checkout')}
    33         );
     27        this.actualSession = 0;
     28        // update payment modules on phone/email change
     29        jQuery( 'form.checkout' ).on(
     30            'change',
     31            '#billing_email, #billing_phone',
     32            function () {jQuery( document.body ).trigger('update_checkout')}
     33        );
    3434        // pay_for_order page
    3535        if (this.isPayForOrderPage() && jQuery('#order_review').length) {
    3636            jQuery('#order_review').submit(function (e) {
    37                 //e.preventDefault();
    3837                tabbyRenderer.updatePaymentIdField();
    39 /*
    40                 jQuery.ajax({
    41                     type:       'POST',
    42                     data:       jQuery('#order_review').serialize(),
    43                     success:    function () {
    44                         tabbyRenderer.launch();
    45                     }
    46                 });
    47 */
    4838            });
    4939        }
    50         jQuery( document.body ).bind( 'payment_method_selected', this.updatePlaceOrderButton );
     40        jQuery( document.body ).bind( 'payment_method_selected', this.updatePlaceOrderButton );
    5141        for (var i in this.methods) {
    5242            jQuery( 'form.checkout' ).bind( 'checkout_place_order_tabby_' + this.methods[i], this.updatePaymentIdField.bind(this));
    5343        }
    54         this.style = document.createElement('style');
    55         this.style.type = 'text/css';
    56         this.adjustStyleSheet();
     44        this.style = document.createElement('style');
     45        this.style.type = 'text/css';
     46        this.adjustStyleSheet();
    5747        setTimeout(function () {
    58             tabbyRenderer.updatePlaceOrderButton();
     48            tabbyRenderer.updatePlaceOrderButton();
    5949        }, 300);
    60         document.getElementsByTagName('head')[0].appendChild(this.style);
     50        document.getElementsByTagName('head')[0].appendChild(this.style);
    6151
    6252        // setup ajax to intercept ajaxSuccess callback for checkout url
    6353        this.setupAjax();
    6454        this.forceRedirect = false;
    65     }
     55    }
    6656    getFieldEmail() {
    67         return this.getFieldValue('email');
     57        return this.getFieldValue('email');
    6858    }
    6959    getFieldPhone() {
    70         return this.getFieldValue('phone');
     60        return this.getFieldValue('phone');
    7161    }
    7262    getFieldFirstName() {
     
    7767    }
    7868    getFieldValue(name) {
     69        // wp sms support
     70        if (name == 'phone' && jQuery('#wp-sms-input-mobile').length) {
     71            return jQuery('#wp-sms-input-mobile');
     72        }
     73
    7974        var field = jQuery('#billing_' + name);
    8075
     
    8479            }
    8580        }
     81       
    8682        return field;
    8783    }
     
    9086        return this.config.localeSource && this.config.localeSource == 'html' ? document.documentElement.lang : this.config.locale;
    9187    }
    92     updatePlaceOrderButton() {
    93         if (typeof tabbyRenderer == 'undefined') return;
    94         var selected = jQuery('input[name="payment_method"]:checked').val();
    95        
    96         jQuery("#place_order").attr('disabled', false);
    97         for (var i in tabbyRenderer.methods) {
    98             if (selected == ('tabby_' + tabbyRenderer.methods[i])) tabbyRenderer.product = i;
     88    updatePlaceOrderButton() {
     89        if (typeof tabbyRenderer == 'undefined') return;
     90        var selected = jQuery('input[name="payment_method"]:checked').val();
     91       
     92        jQuery("#place_order").attr('disabled', false);
     93        for (var i in tabbyRenderer.methods) {
     94            if (selected == ('tabby_' + tabbyRenderer.methods[i])) tabbyRenderer.product = i;
    9995            // remove error
    10096            jQuery(".payment_box.payment_method_tabby_" + tabbyRenderer.methods[i] + ' > .woocommerce-error').remove();
    10197            jQuery('.payment_box.payment_method_tabby_' + tabbyRenderer.methods[i] + ' > #tabbyCard, .payment_box.payment_method_tabby_' + tabbyRenderer.methods[i] + ' > .tabbyDesc').css('display', 'block');
    102             if ((selected == 'tabby_' + tabbyRenderer.methods[i]) && !tabbyRenderer.products.hasOwnProperty(i)) {
     98            if ((selected == 'tabby_' + tabbyRenderer.methods[i]) && !tabbyRenderer.products.hasOwnProperty(i)) {
    10399                jQuery("#place_order").attr('disabled', 'disabled');
    104100                if (tabbyConfig && tabbyRenderer.formFilled) {
     
    109105                }
    110106            }
    111         }
    112     }
    113     update() {
     107        }
     108    }
     109    update() {
    114110        // check payment methods form
    115111        jQuery("input[name=\"payment_method\"]").each (function () {
     
    123119            }
    124120        });
    125         this.config = window.tabbyConfig;
     121        this.config = window.tabbyConfig;
    126122        this.adjustStyleSheet();
    127         if (!this.canUpdate()) return;
    128         var payment = this.buildPayment();
    129         if (tabbyRenderer.config.debug) console.log(payment);
    130         if ((JSON.stringify(payment) == this.paymentJSON) && (this.oldMerchantCode == this.config.merchantCode)) {
     123        if (!this.canUpdate()) return;
     124        var payment = this.buildPayment();
     125        if (tabbyRenderer.config.debug) console.log(payment);
     126        if ((JSON.stringify(payment) == this.paymentJSON) && (this.oldMerchantCode == this.config.merchantCode)) {
    131127            // set form field values (because payment methods can be updated)
    132128            this.setPaymentIdForm();
    133129            return;
    134130        }
    135         this.paymentJSON = JSON.stringify(payment);
     131        this.payment = payment;
     132        this.paymentJSON = JSON.stringify(payment);
    136133        this.oldMerchantCode = this.config.merchantCode;
    137         // do tabby logic
    138         var tabbyConfig = {
    139             apiKey: this.config.apiKey
    140         };
    141         this.payment = payment;
    142         tabbyConfig.payment = payment;
    143         tabbyConfig.merchantCode = this.config.merchantCode;
    144         tabbyConfig.lang = this.getLocale();
    145         tabbyConfig.merchantUrls = this.config.merchantUrls;
    146         tabbyRenderer.products = [];
    147         tabbyConfig.onChange = data => {
    148             if (tabbyRenderer.config.debug) console.log(data);
    149             tabbyRenderer.formFilled = true;
    150             switch (data.status) {
    151                 case 'created':
    152                     tabbyRenderer.products = data.products;
    153                     // update payment id field
    154                     tabbyRenderer.setPaymentId(data.payment.id);
    155                     tabbyRenderer.ddLog('payment created', {payment:{id:data.payment.id}});
    156                     this.formSubmitted = false;
    157 
    158                     tabbyRenderer.enableButton();
    159 
    160                     if (tabbyRenderer.relaunchTabby) {
    161                         tabbyRenderer.relaunchTabby = false;
    162                         tabbyRenderer.launch();
    163                     }
    164                     break;
    165                 case 'authorized':
    166                 case 'approved':
    167                     // update payment id field
    168                     tabbyRenderer.setPaymentId(data.payment.id);
    169                     tabbyRenderer.ddLog('payment approved', {payment:{id:data.payment.id}});
    170 
    171                     if (data.payment.status == 'authorized' || data.payment.status == 'AUTHORIZED') {
    172                         tabbyRenderer.paymentAuthorized = true;
    173                         tabbyRenderer.placeTabbyOrder();
    174                     }
    175 
    176                     setTimeout(function () {
    177                         Tabby.destroy(); // close popup
    178                     }, 2000);
    179                     break;
    180                 case 'rejected':
    181                     tabbyRenderer.ddLog('payment rejected', {payment:{id:data.payment.id}});
    182                     tabbyRenderer.products = [];
    183                     // update payment id field
    184                     tabbyRenderer.setPaymentId(null);
    185                     tabbyRenderer.disableButton();
    186                     break;
    187                 default:
    188                     break;
    189             }
    190         };
    191         tabbyConfig.onClose = () => {
    192             //tabbyRenderer.relaunchTabby = true;
    193             // remove form blocking
    194             tabbyRenderer.unblockForm();
    195             jQuery( window ).unbind('beforeunload');
    196 
    197             tabbyRenderer.products = [];
    198             tabbyRenderer.create();
    199         };
    200 
    201         if (tabbyRenderer.config.debug) console.log(tabbyConfig);
    202         Tabby.init(tabbyConfig);
    203         this.create();
    204         tabbyRenderer.relaunchTabby = false;
    205     }
     134        this.create();
     135        tabbyRenderer.relaunchTabby = false;
     136    }
    206137    ddLog(msg, data) {
    207138        if (typeof ddLog !== 'undefined') {
     
    239170        return false;
    240171    }
    241     create() {
     172    create() {
    242173        tabbyRenderer.formFilled = false;
    243         this.disableButton();
     174        this.disableButton();
    244175        this.setPaymentId(null);
    245         Tabby.create();
    246         const checkout = document.querySelector('#tabby-checkout');
    247         if (checkout) checkout.style.display = 'none';
    248     }
    249     scroll_to_notices() {
    250         var scrollElement = jQuery( 'form.checkout' );
    251         jQuery.scroll_to_notices( scrollElement );
    252     }
    253     launch() {
     176        // create session configuration
     177        var tabbyConfig = {
     178            apiKey: this.config.apiKey
     179        };
     180        tabbyConfig.payment = this.payment;
     181        tabbyConfig.merchantCode = this.config.merchantCode;
     182        tabbyConfig.lang = this.getLocale();
     183        tabbyConfig.merchantUrls = this.config.merchantUrls;
     184        // clean available products
     185        tabbyRenderer.products = [];
     186        if (tabbyRenderer.config.debug) console.log(tabbyConfig);
     187        var sessNum = ++this.actualSession;
     188        window.TabbyCmsPlugins.createSession(tabbyConfig).then( (sess) => {
     189            tabbyRenderer.formSubmitted = false;
     190            tabbyRenderer.formFilled = true;
     191            // do nothing
     192            if (tabbyRenderer.actualSession > sessNum) {
     193                if (tabbyRenderer.config.debug) console.log("ignore old response");
     194                return;
     195            }
     196            // create session error
     197            if (!sess.hasOwnProperty('status') || sess.status != 'created') {
     198                if (tabbyRenderer.config.debug) console.log('create session error');
     199
     200                tabbyRenderer.disableButton();
     201                return;
     202            }
     203            // update currently available products
     204            tabbyRenderer.products = sess.availableProducts;
     205            // update payment id field
     206            tabbyRenderer.setPaymentId(sess.payment.id);
     207            tabbyRenderer.ddLog('payment created', {payment:{id:sess.payment.id}});
     208
     209            tabbyRenderer.enableButton();
     210
     211            if (tabbyRenderer.relaunchTabby) {
     212                tabbyRenderer.relaunchTabby = false;
     213                tabbyRenderer.launch();
     214            }
     215        });
     216    }
     217    launch() {
    254218
    255219        if (!tabbyRenderer.formSubmitted) {
     
    260224            return false;
    261225        }
    262         var product = tabbyRenderer.product;
    263         if (tabbyRenderer.config.debug) console.log('launch with product', tabbyRenderer.product);
    264 
    265         if (tabbyRenderer.relaunchTabby) {
    266             tabbyRenderer.create();
    267         } else {
     226        var product = tabbyRenderer.product;
     227        if (tabbyRenderer.config.debug) console.log('launch with product', tabbyRenderer.product);
     228
     229        if (tabbyRenderer.relaunchTabby) {
     230            tabbyRenderer.create();
     231        } else {
    268232            // remove form blocking
    269233            tabbyRenderer.unblockForm();
     
    271235
    272236            document.location.href = tabbyRenderer.products[product][0].webUrl;
    273         }
    274 
    275         return false;
    276     }
    277     adjustStyleSheet() {
     237        }
     238
     239        return false;
     240    }
     241    adjustStyleSheet() {
    278242        if (this.config && this.config.hideMethods) {
    279             this.style.innerHTML = '';
    280             for (var i in this.methods) {
    281                 if (this.products.hasOwnProperty(i)) {
    282                     //this.style.innerHTML += '.payment_method_tabby_' + this.methods[i] + '{visibility:visible;}\n';
    283                     this.style.innerHTML += '.payment_method_tabby_' + this.methods[i] + '{display:block;}\n';
    284                 } else {
     243            this.style.innerHTML = '';
     244            for (var i in this.methods) {
     245                if (this.products.hasOwnProperty(i)) {
     246                    this.style.innerHTML += '.payment_method_tabby_' + this.methods[i] + '{display:block;}\n';
     247                } else {
    285248                    if (tabbyConfig && tabbyRenderer.formFilled) {
    286                         this.style.innerHTML += '.payment_method_tabby_' + this.methods[i] + '{display:none;}\n';
     249                        this.style.innerHTML += '.payment_method_tabby_' + this.methods[i] + '{display:none;}\n';
    287250                    }
    288                 }
    289             }
    290         }
    291         this.updatePlaceOrderButton();
    292     }
    293     enableButton() {
    294         this.adjustStyleSheet();
    295     }
    296     disableButton() {
    297         this.adjustStyleSheet();
    298     }
    299     canUpdate() {
     251                }
     252            }
     253        }
     254        this.updatePlaceOrderButton();
     255    }
     256    enableButton() {
     257        this.adjustStyleSheet();
     258    }
     259    disableButton() {
     260        this.adjustStyleSheet();
     261    }
     262    canUpdate() {
    300263        if (!this.isPayForOrderPage()) {
    301             if (!this.getFieldFirstName().val()) return false;
    302             if (!this.getFieldEmail().val() || !this.getFieldPhone().val()) return false;
     264            if (!this.getFieldFirstName().val()) return false;
     265            if (!this.getFieldEmail().val() || !this.getFieldPhone().val()) return false;
    303266        };
    304         if (!window.tabbyConfig) return false;
    305         // reload order history if needed
    306         if (!this.loadOrderHistory()) return false;
    307         return true;
    308     }
    309     loadOrderHistory() {
    310         if (this.getFieldEmail().val() == this.email && this.getFieldPhone().val() == this.phone) {
    311             return true;
    312         }
    313         if ( typeof wc_checkout_params === 'undefined' ) {
    314             return false;
    315         }
    316 
    317         var data = {
    318             email: this.getFieldEmail().val(),
    319             phone: this.getFieldPhone().val(),
    320             security: wc_checkout_params.get_order_history_nonce
    321         };
    322 
    323         tabbyRenderer.xhr = jQuery.ajax({
    324             type:       'POST',
    325             url:        wc_checkout_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'get_order_history' ),
    326             data:       data,
    327             success:    function( data ) {
    328                 tabbyRenderer.order_history = data.order_history;
    329                 tabbyRenderer.email = data.email;
    330                 tabbyRenderer.phone = data.phone;
    331                 tabbyRenderer.update();
    332             }
    333         });
    334 
    335         return false;
    336     }
    337     buildPayment() {
    338         var payment = this.config.payment;
    339         payment.buyer = this.getBuyerObject();
     267        if (!window.tabbyConfig) return false;
     268        // reload order history if needed
     269        if (!this.loadOrderHistory()) return false;
     270        return true;
     271    }
     272    loadOrderHistory() {
     273        if (this.getFieldEmail().val() == this.email && this.getFieldPhone().val() == this.phone) {
     274            return true;
     275        }
     276        if ( typeof wc_checkout_params === 'undefined' ) {
     277            return false;
     278        }
     279
     280        var data = {
     281            email: this.getFieldEmail().val(),
     282            phone: this.getFieldPhone().val(),
     283            security: wc_checkout_params.get_order_history_nonce
     284        };
     285
     286        tabbyRenderer.xhr = jQuery.ajax({
     287            type:       'POST',
     288            url:        wc_checkout_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'get_order_history' ),
     289            data:       data,
     290            success:    function( data ) {
     291                tabbyRenderer.order_history = data.order_history;
     292                tabbyRenderer.email = data.email;
     293                tabbyRenderer.phone = data.phone;
     294                tabbyRenderer.update();
     295            }
     296        });
     297
     298        return false;
     299    }
     300    buildPayment() {
     301        var payment = this.config.payment;
     302        payment.buyer = this.getBuyerObject();
    340303        if (this.config.buyer_history) {
    341             payment.buyer_history = this.config.buyer_history;
    342         }
    343         payment.shipping_address = this.getShippingAddress();
    344         payment.order_history = this.order_history;
    345         return payment;
    346     }
    347     getBuyerObject() {
     304            payment.buyer_history = this.config.buyer_history;
     305        }
     306        payment.shipping_address = this.getShippingAddress();
     307        payment.order_history = this.order_history;
     308        return payment;
     309    }
     310    getBuyerObject() {
    348311        if (this.isPayForOrderPage()) return this.config.buyer;
    349         return {
    350             dob: null,
    351             email: this.getFieldEmail().val().toString(),
    352             name: this.getFieldFirstName().val() + (this.getFieldLastName().length ? ' ' + this.getFieldLastName().val() : ''),
    353             phone: this.getFieldPhone().val().toString()
    354         }
    355     }
     312        return {
     313            dob: null,
     314            email: this.getFieldEmail().val().toString(),
     315            name: this.getFieldFirstName().val() + (this.getFieldLastName().length ? ' ' + this.getFieldLastName().val() : ''),
     316            phone: this.getFieldPhone().val().toString()
     317        }
     318    }
    356319    isPayForOrderPage() {
    357320        return jQuery('input[name=woocommerce_pay]').length && (jQuery('input[name=woocommerce_pay]').val() == 1);
    358321    }
    359     getShippingAddress() {
     322    getShippingAddress() {
    360323        if (this.isPayForOrderPage()) return this.config.shipping_address;
    361         const prefix = jQuery('#ship-to-different-address-checkbox:checked').length > 0 ? 'shipping' : 'billing';
    362         return {
    363             address: this.getAddressStreet(prefix),
    364             city: this.getAddressCity(prefix)
    365         }
    366     }
    367     getAddressStreet(prefix) {
    368         const street1 = jQuery('#' + prefix + '_address_1');
    369         const street2 = jQuery('#' + prefix + '_address_2');
    370        
    371         return (street1 ? street1.val() : '') + (street2 && street2.val() ? ', ' + street2.val() : '');
    372     }
    373     getAddressCity(prefix) {
    374         const city = jQuery('#' + prefix + '_city');
    375         return city ? city.val() : null;
    376     }
    377     placeTabbyOrder() {
    378         // assign payment id to related input
     324        const prefix = jQuery('#ship-to-different-address-checkbox:checked').length > 0 ? 'shipping' : 'billing';
     325        return {
     326            address: this.getAddressStreet(prefix),
     327            city: this.getAddressCity(prefix)
     328        }
     329    }
     330    getAddressStreet(prefix) {
     331        const street1 = jQuery('#' + prefix + '_address_1');
     332        const street2 = jQuery('#' + prefix + '_address_2');
     333       
     334        return (street1 ? street1.val() : '') + (street2 && street2.val() ? ', ' + street2.val() : '');
     335    }
     336    getAddressCity(prefix) {
     337        const city = jQuery('#' + prefix + '_city');
     338        return city ? city.val() : null;
     339    }
     340    placeTabbyOrder() {
     341        // assign payment id to related input
    379342        this.setPaymentIdForm();
    380         jQuery('#place_order').trigger('click');
     343        jQuery('#place_order').trigger('click');
    381344        this.forceRedirect = true;
    382     }
     345    }
    383346    setupAjax() {
    384347        // creates a new callback function
  • tabby-checkout/trunk/readme.txt

    r2828572 r2886423  
    33Tags: tabby, tabby plugin, tabby checkout, bnpl, tabby bnpl
    44Requires at least: 5.7
    5 Tested up to: 6.1
    6 Stable tag: 4.1.3
     5Tested up to: 6.2
     6Stable tag: 4.3.1
    77Requires PHP: 7.0
    88License: GPLv3
     
    2828
    2929== Changelog ==
     30
     31= 4.3.1 =
     32
     33* readme.txt file changes
     34
     35= 4.3.0 =
     36
     37* Qatar support added
     38
     39= 4.2.0 =
     40
     41* Checkout script load optimization
     42
     43= 4.1.5 =
     44
     45* Tabby Promo additional configuration option
     46
     47= 4.1.4 =
     48
     49* WP SMS Pro support added
    3050
    3151= 4.1.3 =
     
    128148
    129149Tabby billing plan for checkout payment methods description:
    130 https://checkout.tabby.ai/tabby-card.js
    131 https://checkout.tabby.ai/tabby-payment-method-snippet-cci.js
     150https://checkout.tabby.ai/cms-plugins.js
    132151
    133152
  • tabby-checkout/trunk/tabby-checkout.php

    r2828572 r2886423  
    44 * Plugin URI: https://tabby.ai/
    55 * Description: Tabby Checkout
    6  * Version: 4.1.3
     6 * Version: 4.3.1
    77 * Author: Tabby
    88 * Author URI: https://tabby.ai
     
    1616defined( 'ABSPATH' ) || exit;
    1717
    18 define ('MODULE_TABBY_CHECKOUT_VERSION', '4.1.3');
     18define ('MODULE_TABBY_CHECKOUT_VERSION', '4.3.1');
    1919define ('TABBY_CHECKOUT_DOMAIN', 'checkout.tabby.ai');
    2020define ('TABBY_CHECKOUT_API_DOMAIN', 'api.tabby.ai');
Note: See TracChangeset for help on using the changeset viewer.