Plugin Directory

Changeset 3317578


Ignore:
Timestamp:
06/25/2025 11:13:34 AM (9 months ago)
Author:
tabbyai
Message:

tagging version 5.6.7

Location:
tabby-checkout
Files:
6 edited
34 copied

Legend:

Unmodified
Added
Removed
  • tabby-checkout/tags/5.6.7/includes/class-wc-tabby-api-feed.php

    r3170834 r3317578  
    66    const TABBY_CHECKOUT_FEED_CRED_OPTION = 'tabby_checkout_feed_cred';
    77    const TABBY_CHECKOUT_FEED_REG_ATTEMPT = 'tabby_checkout_feed_reg_attempt';
     8    const TABBY_CHECKOUT_FEED_UNREG_ATTEMPT = 'tabby_checkout_feed_unreg_attempt';
    89    const TABBY_CHECKOUT_FEED_CODES = ['AE', 'SA', 'KW'];
    910
     
    2425            return true;
    2526        }
     27        // check if there is previous uninstall attempt
     28        if (time() < (int)get_option(self::TABBY_CHECKOUT_FEED_UNREG_ATTEMPT, 0)) {
     29            // bypass request
     30            return false;
     31        }
    2632        $cred = json_decode(get_option(self::TABBY_CHECKOUT_FEED_CRED_OPTION, json_encode($this->getFeedCredentials())), true);
    2733        unset($cred['secretKey']);
    2834        $result = $this->request('uninstall', 'POST', $cred);
    29         delete_option(self::TABBY_CHECKOUT_FEED_TOKEN_OPTION);
    30         delete_option(self::TABBY_CHECKOUT_FEED_CRED_OPTION);
    31         delete_option(self::TABBY_CHECKOUT_FEED_REG_ATTEMPT);
     35        // successful
     36        if (sizeof((array)$result) == 0) {
     37            delete_option(self::TABBY_CHECKOUT_FEED_TOKEN_OPTION);
     38            delete_option(self::TABBY_CHECKOUT_FEED_CRED_OPTION);
     39            delete_option(self::TABBY_CHECKOUT_FEED_REG_ATTEMPT);
     40            delete_option(self::TABBY_CHECKOUT_FEED_UNREG_ATTEMPT);
     41        } else {
     42            // unregister failed
     43            update_option(self::TABBY_CHECKOUT_FEED_UNREG_ATTEMPT, time() + 2 * HOUR_IN_SECONDS);
     44        }
    3245
    3346        return true;
     
    3548    public function register() {
    3649        // check if there is previous registration attempt
    37         $reg_attempt_name = self::TABBY_CHECKOUT_FEED_REG_ATTEMPT;
    38         if (time() < (int)get_option($reg_attempt_name, 0)) {
     50        if (time() < (int)get_option(self::TABBY_CHECKOUT_FEED_REG_ATTEMPT, 0)) {
    3951            // bypass request
    4052            return false;
     
    5365        } else {
    5466            // registration failed - set transient to 4 hours
    55             update_option($reg_attempt_name, time() + 4 * HOUR_IN_SECONDS);
     67            update_option(self::TABBY_CHECKOUT_FEED_REG_ATTEMPT, time() + 4 * HOUR_IN_SECONDS);
    5668
    5769            // log site logo for failed registrations
  • tabby-checkout/tags/5.6.7/includes/class-wc-tabby-api.php

    r3287616 r3317578  
    7676        switch ($response['response']['code']) {
    7777        case 200:
    78             $result = json_decode($response["body"]);
     78            $result = json_decode($response["body"]) ?: new \StdClass();
    7979            static::debug(['response - success data', (array)$result]);
    8080            break;
     81        case 403:
     82            if (substr(trim($response["body"]), 0, 15) == '<!DOCTYPE html>') {
     83                static::ddlog('error', 'API html response detected', null, $logData);
     84            }
    8185        default:
    8286            $body = $response["body"];
    8387            $msg = "Server returned: " . $response['response']['code'] . '. ';
    8488            if (!empty($body)) {
    85                 $result = json_decode($body);
     89                $result = json_decode($body) ?: new \StdClass();
    8690                if (!property_exists($result, 'error')) {
    8791                    $result->error = '';
  • tabby-checkout/tags/5.6.7/includes/class-wc-tabby-webhook.php

    r3157667 r3317578  
    55    public static function register() {
    66        if (WC_Tabby_Api::needs_setup()) {
    7             static::ddlog("info", "Tabby is not configured, but webhook 'register' called. Possible first module installation.");
     7            static::ddlog("warn", "Tabby is not configured, but webhook 'register' called. Possible first module installation.");
    88            return;
    99        }
     
    5353        return WC_Tabby_Api::request('webhooks/' . $hook->id, 'PUT', $data, $code);
    5454    }
     55    public static function deleteWebhook($hook, $code) {
     56        static::ddlog("info", "Deleting webhook", null, $hook);
     57        return WC_Tabby_Api::request('webhooks/' . $hook->id, 'DELETE', null, $code);
     58    }
    5559    public static function getWebhooks($code) {
    5660        return WC_Tabby_Api::request('webhooks', 'GET', null, $code);
     
    6064    }
    6165    public static function unregister() {
     66        if (WC_Tabby_Api::needs_setup()) {
     67            static::ddlog("warn", "Tabby is not configured, but webhook 'unregister' called. Possible wrong module configuration.");
     68            return;
     69        }
     70        // get webhook url
     71        $url = WC_REST_Tabby_Controller::getEndpointUrl();
     72        static::ddlog("info", "unregister: Checking webhook is registered.", null, ['url' => $url]);
     73       
     74        // request all webhooks
     75        foreach (WC_Tabby_Config::ALLOWED_COUNTRIES as $country) {
     76            // get list of registered hooks
     77            $hooks = static::getWebhooks($country);
     78            // bypass not authorized errors
     79            if (static::isNotAuthorized($hooks)) {
     80                static::ddlog("info", "unregister: Store code not authorized for merchant", null, ['code' => $country]);
     81                continue;
     82            }
     83            if (!is_array($hooks)) {
     84                $hooks = [$hooks];
     85            }
     86            foreach ($hooks as $hook) {
     87                if (!is_object($hook)) continue;
     88                if (property_exists($hook, 'url') && $hook->url == $url && $hook->is_test === static::getIsTest()) {
     89                    static::deleteWebhook($hook, $country);
     90                }
     91            }
     92        }
    6293    }
    6394    public static function ddlog($status = "error", $message = "Something went wrong", $e = null, $data = null) {
  • tabby-checkout/tags/5.6.7/includes/class-wc-tabby.php

    r3294207 r3317578  
    4343        add_action('woocommerce_before_pay_action', array(__CLASS__, 'woocommerce_store_api_checkout_order_processed'));
    4444
     45        // remove old payment methods from settings page
     46        add_action('woocommerce_admin_field_payment_gateways', array(__CLASS__, 'woocommerce_admin_field_payment_gateways'));
    4547    }
     48
     49    public static function woocommerce_admin_field_payment_gateways() {
     50        foreach (WC()->payment_gateways()->payment_gateways as $key => $gateway) {
     51            switch (get_class($gateway)) {
     52                case 'WC_Gateway_Tabby_Credit_Card_Installments':
     53                case 'WC_Gateway_Tabby_PayLater':
     54                    unset (WC()->payment_gateways()->payment_gateways[$key]);
     55                    break;
     56            }
     57        }
     58    }
     59
    4660    public static function woocommerce_checkout_order_processed($order_id, $post_data, &$order) {
    4761        static::woocommerce_store_api_checkout_order_processed($order);
     
    6175        if ($transaction_id = (array_key_exists('transaction_id', $context->payment_data) ? $context->payment_data['transaction_id'] : false)) {
    6276            $gateway->update_order_payment_id($context->order, $transaction_id);
    63             $res = $gateway->update_payment_reference_id($transaction_id, $context->order->get_id());
     77            $res = $gateway->update_payment_reference_id(
     78                $transaction_id,
     79                woocommerce_tabby_get_order_reference_id($context->order)
     80            );
    6481            if (is_object($res) && property_exists($res, 'status') && ($res->status != 'error')) {
    6582                $result->set_status('success');
     
    8097        if ($order->get_transaction_id()) {
    8198            $gateway->update_order_payment_id($order, $order->get_transaction_id());
    82             $gateway->update_payment_reference_id($order->get_transaction_id(), $order->get_id());
     99            $gateway->update_payment_reference_id(
     100                $order->get_transaction_id(),
     101                woocommerce_tabby_get_order_reference_id($order)
     102            );
    83103        }
    84104        return $order;
  • tabby-checkout/tags/5.6.7/readme.txt

    r3294207 r3317578  
    44Requires at least: 5.7
    55Tested up to: 6.8
    6 Stable tag: 5.6.2
     6Stable tag: 5.6.7
    77Requires PHP: 7.0
    88License: GPLv3
  • tabby-checkout/tags/5.6.7/tabby-checkout.php

    r3294207 r3317578  
    44 * Plugin URI: https://tabby.ai/
    55 * Description: Tabby Checkout
    6  * Version: 5.6.2
     6 * Version: 5.6.7
    77 * Author: Tabby
    88 * Author URI: https://tabby.ai
     
    1414defined( 'ABSPATH' ) || exit;
    1515
    16 define ('MODULE_TABBY_CHECKOUT_VERSION', '5.6.2');
     16define ('MODULE_TABBY_CHECKOUT_VERSION', '5.6.7');
    1717define ('TABBY_CHECKOUT_DOMAIN', 'checkout.tabby.ai');
    1818define ('TABBY_CHECKOUT_API_DOMAIN', 'api.tabby.ai');
  • tabby-checkout/trunk/includes/class-wc-tabby-api-feed.php

    r3170834 r3317578  
    66    const TABBY_CHECKOUT_FEED_CRED_OPTION = 'tabby_checkout_feed_cred';
    77    const TABBY_CHECKOUT_FEED_REG_ATTEMPT = 'tabby_checkout_feed_reg_attempt';
     8    const TABBY_CHECKOUT_FEED_UNREG_ATTEMPT = 'tabby_checkout_feed_unreg_attempt';
    89    const TABBY_CHECKOUT_FEED_CODES = ['AE', 'SA', 'KW'];
    910
     
    2425            return true;
    2526        }
     27        // check if there is previous uninstall attempt
     28        if (time() < (int)get_option(self::TABBY_CHECKOUT_FEED_UNREG_ATTEMPT, 0)) {
     29            // bypass request
     30            return false;
     31        }
    2632        $cred = json_decode(get_option(self::TABBY_CHECKOUT_FEED_CRED_OPTION, json_encode($this->getFeedCredentials())), true);
    2733        unset($cred['secretKey']);
    2834        $result = $this->request('uninstall', 'POST', $cred);
    29         delete_option(self::TABBY_CHECKOUT_FEED_TOKEN_OPTION);
    30         delete_option(self::TABBY_CHECKOUT_FEED_CRED_OPTION);
    31         delete_option(self::TABBY_CHECKOUT_FEED_REG_ATTEMPT);
     35        // successful
     36        if (sizeof((array)$result) == 0) {
     37            delete_option(self::TABBY_CHECKOUT_FEED_TOKEN_OPTION);
     38            delete_option(self::TABBY_CHECKOUT_FEED_CRED_OPTION);
     39            delete_option(self::TABBY_CHECKOUT_FEED_REG_ATTEMPT);
     40            delete_option(self::TABBY_CHECKOUT_FEED_UNREG_ATTEMPT);
     41        } else {
     42            // unregister failed
     43            update_option(self::TABBY_CHECKOUT_FEED_UNREG_ATTEMPT, time() + 2 * HOUR_IN_SECONDS);
     44        }
    3245
    3346        return true;
     
    3548    public function register() {
    3649        // check if there is previous registration attempt
    37         $reg_attempt_name = self::TABBY_CHECKOUT_FEED_REG_ATTEMPT;
    38         if (time() < (int)get_option($reg_attempt_name, 0)) {
     50        if (time() < (int)get_option(self::TABBY_CHECKOUT_FEED_REG_ATTEMPT, 0)) {
    3951            // bypass request
    4052            return false;
     
    5365        } else {
    5466            // registration failed - set transient to 4 hours
    55             update_option($reg_attempt_name, time() + 4 * HOUR_IN_SECONDS);
     67            update_option(self::TABBY_CHECKOUT_FEED_REG_ATTEMPT, time() + 4 * HOUR_IN_SECONDS);
    5668
    5769            // log site logo for failed registrations
  • tabby-checkout/trunk/includes/class-wc-tabby-api.php

    r3287616 r3317578  
    7676        switch ($response['response']['code']) {
    7777        case 200:
    78             $result = json_decode($response["body"]);
     78            $result = json_decode($response["body"]) ?: new \StdClass();
    7979            static::debug(['response - success data', (array)$result]);
    8080            break;
     81        case 403:
     82            if (substr(trim($response["body"]), 0, 15) == '<!DOCTYPE html>') {
     83                static::ddlog('error', 'API html response detected', null, $logData);
     84            }
    8185        default:
    8286            $body = $response["body"];
    8387            $msg = "Server returned: " . $response['response']['code'] . '. ';
    8488            if (!empty($body)) {
    85                 $result = json_decode($body);
     89                $result = json_decode($body) ?: new \StdClass();
    8690                if (!property_exists($result, 'error')) {
    8791                    $result->error = '';
  • tabby-checkout/trunk/includes/class-wc-tabby-webhook.php

    r3157667 r3317578  
    55    public static function register() {
    66        if (WC_Tabby_Api::needs_setup()) {
    7             static::ddlog("info", "Tabby is not configured, but webhook 'register' called. Possible first module installation.");
     7            static::ddlog("warn", "Tabby is not configured, but webhook 'register' called. Possible first module installation.");
    88            return;
    99        }
     
    5353        return WC_Tabby_Api::request('webhooks/' . $hook->id, 'PUT', $data, $code);
    5454    }
     55    public static function deleteWebhook($hook, $code) {
     56        static::ddlog("info", "Deleting webhook", null, $hook);
     57        return WC_Tabby_Api::request('webhooks/' . $hook->id, 'DELETE', null, $code);
     58    }
    5559    public static function getWebhooks($code) {
    5660        return WC_Tabby_Api::request('webhooks', 'GET', null, $code);
     
    6064    }
    6165    public static function unregister() {
     66        if (WC_Tabby_Api::needs_setup()) {
     67            static::ddlog("warn", "Tabby is not configured, but webhook 'unregister' called. Possible wrong module configuration.");
     68            return;
     69        }
     70        // get webhook url
     71        $url = WC_REST_Tabby_Controller::getEndpointUrl();
     72        static::ddlog("info", "unregister: Checking webhook is registered.", null, ['url' => $url]);
     73       
     74        // request all webhooks
     75        foreach (WC_Tabby_Config::ALLOWED_COUNTRIES as $country) {
     76            // get list of registered hooks
     77            $hooks = static::getWebhooks($country);
     78            // bypass not authorized errors
     79            if (static::isNotAuthorized($hooks)) {
     80                static::ddlog("info", "unregister: Store code not authorized for merchant", null, ['code' => $country]);
     81                continue;
     82            }
     83            if (!is_array($hooks)) {
     84                $hooks = [$hooks];
     85            }
     86            foreach ($hooks as $hook) {
     87                if (!is_object($hook)) continue;
     88                if (property_exists($hook, 'url') && $hook->url == $url && $hook->is_test === static::getIsTest()) {
     89                    static::deleteWebhook($hook, $country);
     90                }
     91            }
     92        }
    6293    }
    6394    public static function ddlog($status = "error", $message = "Something went wrong", $e = null, $data = null) {
  • tabby-checkout/trunk/includes/class-wc-tabby.php

    r3294207 r3317578  
    4343        add_action('woocommerce_before_pay_action', array(__CLASS__, 'woocommerce_store_api_checkout_order_processed'));
    4444
     45        // remove old payment methods from settings page
     46        add_action('woocommerce_admin_field_payment_gateways', array(__CLASS__, 'woocommerce_admin_field_payment_gateways'));
    4547    }
     48
     49    public static function woocommerce_admin_field_payment_gateways() {
     50        foreach (WC()->payment_gateways()->payment_gateways as $key => $gateway) {
     51            switch (get_class($gateway)) {
     52                case 'WC_Gateway_Tabby_Credit_Card_Installments':
     53                case 'WC_Gateway_Tabby_PayLater':
     54                    unset (WC()->payment_gateways()->payment_gateways[$key]);
     55                    break;
     56            }
     57        }
     58    }
     59
    4660    public static function woocommerce_checkout_order_processed($order_id, $post_data, &$order) {
    4761        static::woocommerce_store_api_checkout_order_processed($order);
     
    6175        if ($transaction_id = (array_key_exists('transaction_id', $context->payment_data) ? $context->payment_data['transaction_id'] : false)) {
    6276            $gateway->update_order_payment_id($context->order, $transaction_id);
    63             $res = $gateway->update_payment_reference_id($transaction_id, $context->order->get_id());
     77            $res = $gateway->update_payment_reference_id(
     78                $transaction_id,
     79                woocommerce_tabby_get_order_reference_id($context->order)
     80            );
    6481            if (is_object($res) && property_exists($res, 'status') && ($res->status != 'error')) {
    6582                $result->set_status('success');
     
    8097        if ($order->get_transaction_id()) {
    8198            $gateway->update_order_payment_id($order, $order->get_transaction_id());
    82             $gateway->update_payment_reference_id($order->get_transaction_id(), $order->get_id());
     99            $gateway->update_payment_reference_id(
     100                $order->get_transaction_id(),
     101                woocommerce_tabby_get_order_reference_id($order)
     102            );
    83103        }
    84104        return $order;
  • tabby-checkout/trunk/readme.txt

    r3294207 r3317578  
    44Requires at least: 5.7
    55Tested up to: 6.8
    6 Stable tag: 5.6.2
     6Stable tag: 5.6.7
    77Requires PHP: 7.0
    88License: GPLv3
  • tabby-checkout/trunk/tabby-checkout.php

    r3294207 r3317578  
    44 * Plugin URI: https://tabby.ai/
    55 * Description: Tabby Checkout
    6  * Version: 5.6.2
     6 * Version: 5.6.7
    77 * Author: Tabby
    88 * Author URI: https://tabby.ai
     
    1414defined( 'ABSPATH' ) || exit;
    1515
    16 define ('MODULE_TABBY_CHECKOUT_VERSION', '5.6.2');
     16define ('MODULE_TABBY_CHECKOUT_VERSION', '5.6.7');
    1717define ('TABBY_CHECKOUT_DOMAIN', 'checkout.tabby.ai');
    1818define ('TABBY_CHECKOUT_API_DOMAIN', 'api.tabby.ai');
Note: See TracChangeset for help on using the changeset viewer.