Plugin Directory

Changeset 3431602


Ignore:
Timestamp:
01/03/2026 12:07:06 PM (3 months ago)
Author:
depayfi
Message:

Update to version 3.0.6 from GitHub

Location:
depay-payments-for-woocommerce
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • depay-payments-for-woocommerce/tags/3.0.6/changelog.txt

    r3389400 r3431602  
    11*** DePay Web3 Payments for WooCommerce Changelog ***
     2
     32026-1-3 - version 3.0.6
     4* fixes token denomination issue (where no price is available)
    25
    362025-11-4 - version 3.0.5
  • depay-payments-for-woocommerce/tags/3.0.6/depay-woocommerce-payments.php

    r3389400 r3431602  
    1212 * Requires at least: 5.8
    1313 * Requires PHP: 7.0
    14  * Version: 3.0.5
     14 * Version: 3.0.6
    1515 *
    1616 * @package DePay\Payments
     
    2222define( 'DEPAY_WC_ABSPATH', __DIR__ . '/' );
    2323define( 'DEPAY_MIN_WC_ADMIN_VERSION', '0.23.2' );
    24 define( 'DEPAY_CURRENT_VERSION', '3.0.5' );
     24define( 'DEPAY_CURRENT_VERSION', '3.0.6' );
    2525
    2626require_once DEPAY_WC_ABSPATH . '/vendor/autoload.php';
  • depay-payments-for-woocommerce/tags/3.0.6/includes/class-depay-wc-payments-gateway.php

    r3217507 r3431602  
    136136        $token_denominated = false;
    137137        $token = null;
     138        $total_in_usd = null;
    138139        $api_key = get_option( 'depay_wc_api_key' );
    139140        if ( empty( $api_key ) ) {
     
    176177            } else if ( is_wp_error($usd_amount) || wp_remote_retrieve_response_code( $usd_amount ) != 200 ) {
    177178                DePay_WC_Payments::log( 'Price request failed!' );
    178                 throw new Exception( 'Price request failed!' );
    179             }
    180             $total_in_usd = bcmul( $usd_amount['body'], 1, 3 );
     179                // throw new Exception( 'Price request failed!' );
     180            } else {
     181                $total_in_usd = bcmul( $usd_amount['body'], 1, 3 );
     182            }
    181183        } else if ( 'USD' == $currency ) {
    182184            $total_in_usd = $total;
     
    205207        }
    206208
    207         if ( empty($total_in_usd) ) {
     209        if ( empty($total_in_usd) && !$token_denominated ) {
    208210            DePay_WC_Payments::log( 'total_in_usd empty!' );
    209211            throw new Exception( 'total_in_usd empty!' );
     
    218220        }
    219221
    220         foreach ( $accepted_payments as $accepted_payment ) {
    221             if ( $api_key ) {
    222                 $requests[] = array(
    223                     'url' => sprintf( 'https://api.depay.com/v2/conversions/%s/%s/USD?amount=' . $price_format_specifier, $accepted_payment->blockchain, $accepted_payment->token, $total_in_usd ),
    224                     'type' => 'GET',
    225                     'timeout' => 10,
    226                     'headers' => array(
    227                         'x-api-key' => $api_key
    228                     )
    229                 );
    230                 $requests[] = array(
    231                     'url' => sprintf( 'https://api.depay.com/v2/tokens/decimals/%s/%s', $accepted_payment->blockchain, $accepted_payment->token ),
    232                     'type' => 'GET',
    233                     'headers' => array(
    234                         'x-api-key' => $api_key
    235                     )
    236                 );
    237             } else {
    238                 $requests[] = array(
    239                     'url' => sprintf( 'https://public.depay.com/conversions/%s/%s/USD?amount=' . $price_format_specifier, $accepted_payment->blockchain, $accepted_payment->token, $total_in_usd ),
    240                     'type' => 'GET',
    241                     'timeout' => 10
    242                 );
    243                 $requests[] = array(
    244                     'url' => sprintf( 'https://public.depay.com/tokens/decimals/%s/%s', $accepted_payment->blockchain, $accepted_payment->token ),
    245                     'type' => 'GET'
    246                 );
    247             }
    248         }
    249 
    250         $responses = Requests::request_multiple( $requests );
    251 
    252222        $accept = [];
    253 
    254         for ($i = 0; $i < count($responses); $i++) {
    255             if ( 0 === $i % 2 ) { // even 0, 2, 4 ...
    256                 if ( 429 === $responses[$i]->status_code ) {
    257                     DePay_WC_Payments::log( 'To many requests! Please upgrade to DePay PRO.' );
    258                     throw new Exception( 'To many requests! Please upgrade to DePay PRO.' );
    259                 } else if ( $responses[$i]->success && $responses[$i+1]->success && !empty( $responses[$i]->body ) && !empty( $responses[$i+1]->body ) ) {
    260                     $accepted_payment = $accepted_payments[ $i / 2 ];
    261                     if ( $token_denominated && $token && $token->blockchain === $accepted_payment->blockchain && $token->address === $accepted_payment->token ) {
    262                         $amount = $total;
     223        $requests = [];
     224
     225        if ( empty($total_in_usd) && $token_denominated ) {
     226
     227            $match = null;
     228
     229            foreach ( $accepted_payments as $accepted_payment ) {
     230                if (
     231                    $accepted_payment->blockchain === $token->blockchain &&
     232                    $accepted_payment->token === $token->address
     233                ) {
     234                    $match = $accepted_payment;
     235                    break;
     236                }
     237            }
     238
     239            if ( null !== $match ) {
     240                array_push($accept, [
     241                    'blockchain' => $match->blockchain,
     242                    'token' => $match->token,
     243                    'amount' => $total,
     244                    'receiver' => $match->receiver
     245                ]);
     246            }
     247
     248        } else {
     249
     250            foreach ( $accepted_payments as $accepted_payment ) {
     251                if ( $api_key ) {
     252                    $requests[] = array(
     253                        'url' => sprintf( 'https://api.depay.com/v2/conversions/%s/%s/USD?amount=' . $price_format_specifier, $accepted_payment->blockchain, $accepted_payment->token, $total_in_usd ),
     254                        'type' => 'GET',
     255                        'timeout' => 10,
     256                        'headers' => array(
     257                            'x-api-key' => $api_key
     258                        )
     259                    );
     260                    $requests[] = array(
     261                        'url' => sprintf( 'https://api.depay.com/v2/tokens/decimals/%s/%s', $accepted_payment->blockchain, $accepted_payment->token ),
     262                        'type' => 'GET',
     263                        'headers' => array(
     264                            'x-api-key' => $api_key
     265                        )
     266                    );
     267                } else {
     268                    $requests[] = array(
     269                        'url' => sprintf( 'https://public.depay.com/conversions/%s/%s/USD?amount=' . $price_format_specifier, $accepted_payment->blockchain, $accepted_payment->token, $total_in_usd ),
     270                        'type' => 'GET',
     271                        'timeout' => 10
     272                    );
     273                    $requests[] = array(
     274                        'url' => sprintf( 'https://public.depay.com/tokens/decimals/%s/%s', $accepted_payment->blockchain, $accepted_payment->token ),
     275                        'type' => 'GET'
     276                    );
     277                }
     278            }
     279
     280            $responses = Requests::request_multiple( $requests );
     281
     282            for ($i = 0; $i < count($responses); $i++) {
     283                if ( 0 === $i % 2 ) { // even 0, 2, 4 ...
     284                    if ( 429 === $responses[$i]->status_code ) {
     285                        DePay_WC_Payments::log( 'To many requests! Please upgrade to DePay PRO.' );
     286                        throw new Exception( 'To many requests! Please upgrade to DePay PRO.' );
     287                    } else if ( $responses[$i]->success && $responses[$i+1]->success && !empty( $responses[$i]->body ) && !empty( $responses[$i+1]->body ) ) {
     288                        $accepted_payment = $accepted_payments[ $i / 2 ];
     289                        if ( $token_denominated && $token && $token->blockchain === $accepted_payment->blockchain && $token->address === $accepted_payment->token ) {
     290                            $amount = $total;
     291                        } else {
     292                            $amount = $this->round_token_amount( $responses[$i]->body );
     293                        }
     294                        if ( !empty( $amount ) && strval( $amount ) !== '0.00' ) {
     295                            array_push($accept, [
     296                                'blockchain' => $accepted_payment->blockchain,
     297                                'token' => $accepted_payment->token,
     298                                'amount' => $amount,
     299                                'receiver' => $accepted_payment->receiver
     300                            ]);
     301                        } else {
     302                            DePay_WC_Payments::log( 'Amount is empty: ' . $requests[$i]['url'] );
     303                        }
    263304                    } else {
    264                         $amount = $this->round_token_amount( $responses[$i]->body );
     305                        DePay_WC_Payments::log( 'Accept request failed: ' . $responses[$i]->status_code . ' ' . $requests[$i]['url'] );
    265306                    }
    266                     if ( !empty( $amount ) && strval( $amount ) !== '0.00' ) {
    267                         array_push($accept, [
    268                             'blockchain' => $accepted_payment->blockchain,
    269                             'token' => $accepted_payment->token,
    270                             'amount' => $amount,
    271                             'receiver' => $accepted_payment->receiver
    272                         ]);
    273                     } else {
    274                         DePay_WC_Payments::log( 'Amount is empty: ' . $requests[$i]['url'] );
    275                     }
    276                 } else {
    277                     DePay_WC_Payments::log( 'Accept request failed: ' . $responses[$i]->status_code . ' ' . $requests[$i]['url'] );
    278307                }
    279308            }
    280309        }
    281        
     310
    282311        if ( empty( $accept ) ) {
    283312            DePay_WC_Payments::log( 'No valid payment route found!' );
  • depay-payments-for-woocommerce/tags/3.0.6/languages/depay-woocommerce-payments.pot

    r3389400 r3431602  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: DePay WooCommerce Payments 3.0.5\n"
     5"Project-Id-Version: DePay WooCommerce Payments 3.0.6\n"
    66"Report-Msgid-Bugs-To: "
    77"support@depay.com\n"
  • depay-payments-for-woocommerce/tags/3.0.6/package.json

    r3389400 r3431602  
    22  "name": "@depay/web3-woocommerce-depay-payments",
    33  "moduleName": "WooCommerceDePayPayments",
    4   "version": "3.0.5",
     4  "version": "3.0.6",
    55  "description": "Accept Web3 Crypto Payments. Supports various tokens, blockchains and wallets. MetaMask, Phantom, USDC, USDT, ETH, SOL, BSC, POL, xDAI…",
    66  "main": "./dist/umd/index.js",
  • depay-payments-for-woocommerce/tags/3.0.6/readme.txt

    r3389400 r3431602  
    55Tested up to: 6.8
    66Requires PHP: 7.2
    7 Stable tag: 3.0.5
     7Stable tag: 3.0.6
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    8282== Changelog ==
    8383
     84= 2026-1-3 - v3.0.6 =
     85* fixes token denomination issue (where no price is available)
     86
    8487= 2025-11-4 - v3.0.5 =
    8588* fixes Solana issues
  • depay-payments-for-woocommerce/trunk/changelog.txt

    r3389400 r3431602  
    11*** DePay Web3 Payments for WooCommerce Changelog ***
     2
     32026-1-3 - version 3.0.6
     4* fixes token denomination issue (where no price is available)
    25
    362025-11-4 - version 3.0.5
  • depay-payments-for-woocommerce/trunk/depay-woocommerce-payments.php

    r3389400 r3431602  
    1212 * Requires at least: 5.8
    1313 * Requires PHP: 7.0
    14  * Version: 3.0.5
     14 * Version: 3.0.6
    1515 *
    1616 * @package DePay\Payments
     
    2222define( 'DEPAY_WC_ABSPATH', __DIR__ . '/' );
    2323define( 'DEPAY_MIN_WC_ADMIN_VERSION', '0.23.2' );
    24 define( 'DEPAY_CURRENT_VERSION', '3.0.5' );
     24define( 'DEPAY_CURRENT_VERSION', '3.0.6' );
    2525
    2626require_once DEPAY_WC_ABSPATH . '/vendor/autoload.php';
  • depay-payments-for-woocommerce/trunk/includes/class-depay-wc-payments-gateway.php

    r3217507 r3431602  
    136136        $token_denominated = false;
    137137        $token = null;
     138        $total_in_usd = null;
    138139        $api_key = get_option( 'depay_wc_api_key' );
    139140        if ( empty( $api_key ) ) {
     
    176177            } else if ( is_wp_error($usd_amount) || wp_remote_retrieve_response_code( $usd_amount ) != 200 ) {
    177178                DePay_WC_Payments::log( 'Price request failed!' );
    178                 throw new Exception( 'Price request failed!' );
    179             }
    180             $total_in_usd = bcmul( $usd_amount['body'], 1, 3 );
     179                // throw new Exception( 'Price request failed!' );
     180            } else {
     181                $total_in_usd = bcmul( $usd_amount['body'], 1, 3 );
     182            }
    181183        } else if ( 'USD' == $currency ) {
    182184            $total_in_usd = $total;
     
    205207        }
    206208
    207         if ( empty($total_in_usd) ) {
     209        if ( empty($total_in_usd) && !$token_denominated ) {
    208210            DePay_WC_Payments::log( 'total_in_usd empty!' );
    209211            throw new Exception( 'total_in_usd empty!' );
     
    218220        }
    219221
    220         foreach ( $accepted_payments as $accepted_payment ) {
    221             if ( $api_key ) {
    222                 $requests[] = array(
    223                     'url' => sprintf( 'https://api.depay.com/v2/conversions/%s/%s/USD?amount=' . $price_format_specifier, $accepted_payment->blockchain, $accepted_payment->token, $total_in_usd ),
    224                     'type' => 'GET',
    225                     'timeout' => 10,
    226                     'headers' => array(
    227                         'x-api-key' => $api_key
    228                     )
    229                 );
    230                 $requests[] = array(
    231                     'url' => sprintf( 'https://api.depay.com/v2/tokens/decimals/%s/%s', $accepted_payment->blockchain, $accepted_payment->token ),
    232                     'type' => 'GET',
    233                     'headers' => array(
    234                         'x-api-key' => $api_key
    235                     )
    236                 );
    237             } else {
    238                 $requests[] = array(
    239                     'url' => sprintf( 'https://public.depay.com/conversions/%s/%s/USD?amount=' . $price_format_specifier, $accepted_payment->blockchain, $accepted_payment->token, $total_in_usd ),
    240                     'type' => 'GET',
    241                     'timeout' => 10
    242                 );
    243                 $requests[] = array(
    244                     'url' => sprintf( 'https://public.depay.com/tokens/decimals/%s/%s', $accepted_payment->blockchain, $accepted_payment->token ),
    245                     'type' => 'GET'
    246                 );
    247             }
    248         }
    249 
    250         $responses = Requests::request_multiple( $requests );
    251 
    252222        $accept = [];
    253 
    254         for ($i = 0; $i < count($responses); $i++) {
    255             if ( 0 === $i % 2 ) { // even 0, 2, 4 ...
    256                 if ( 429 === $responses[$i]->status_code ) {
    257                     DePay_WC_Payments::log( 'To many requests! Please upgrade to DePay PRO.' );
    258                     throw new Exception( 'To many requests! Please upgrade to DePay PRO.' );
    259                 } else if ( $responses[$i]->success && $responses[$i+1]->success && !empty( $responses[$i]->body ) && !empty( $responses[$i+1]->body ) ) {
    260                     $accepted_payment = $accepted_payments[ $i / 2 ];
    261                     if ( $token_denominated && $token && $token->blockchain === $accepted_payment->blockchain && $token->address === $accepted_payment->token ) {
    262                         $amount = $total;
     223        $requests = [];
     224
     225        if ( empty($total_in_usd) && $token_denominated ) {
     226
     227            $match = null;
     228
     229            foreach ( $accepted_payments as $accepted_payment ) {
     230                if (
     231                    $accepted_payment->blockchain === $token->blockchain &&
     232                    $accepted_payment->token === $token->address
     233                ) {
     234                    $match = $accepted_payment;
     235                    break;
     236                }
     237            }
     238
     239            if ( null !== $match ) {
     240                array_push($accept, [
     241                    'blockchain' => $match->blockchain,
     242                    'token' => $match->token,
     243                    'amount' => $total,
     244                    'receiver' => $match->receiver
     245                ]);
     246            }
     247
     248        } else {
     249
     250            foreach ( $accepted_payments as $accepted_payment ) {
     251                if ( $api_key ) {
     252                    $requests[] = array(
     253                        'url' => sprintf( 'https://api.depay.com/v2/conversions/%s/%s/USD?amount=' . $price_format_specifier, $accepted_payment->blockchain, $accepted_payment->token, $total_in_usd ),
     254                        'type' => 'GET',
     255                        'timeout' => 10,
     256                        'headers' => array(
     257                            'x-api-key' => $api_key
     258                        )
     259                    );
     260                    $requests[] = array(
     261                        'url' => sprintf( 'https://api.depay.com/v2/tokens/decimals/%s/%s', $accepted_payment->blockchain, $accepted_payment->token ),
     262                        'type' => 'GET',
     263                        'headers' => array(
     264                            'x-api-key' => $api_key
     265                        )
     266                    );
     267                } else {
     268                    $requests[] = array(
     269                        'url' => sprintf( 'https://public.depay.com/conversions/%s/%s/USD?amount=' . $price_format_specifier, $accepted_payment->blockchain, $accepted_payment->token, $total_in_usd ),
     270                        'type' => 'GET',
     271                        'timeout' => 10
     272                    );
     273                    $requests[] = array(
     274                        'url' => sprintf( 'https://public.depay.com/tokens/decimals/%s/%s', $accepted_payment->blockchain, $accepted_payment->token ),
     275                        'type' => 'GET'
     276                    );
     277                }
     278            }
     279
     280            $responses = Requests::request_multiple( $requests );
     281
     282            for ($i = 0; $i < count($responses); $i++) {
     283                if ( 0 === $i % 2 ) { // even 0, 2, 4 ...
     284                    if ( 429 === $responses[$i]->status_code ) {
     285                        DePay_WC_Payments::log( 'To many requests! Please upgrade to DePay PRO.' );
     286                        throw new Exception( 'To many requests! Please upgrade to DePay PRO.' );
     287                    } else if ( $responses[$i]->success && $responses[$i+1]->success && !empty( $responses[$i]->body ) && !empty( $responses[$i+1]->body ) ) {
     288                        $accepted_payment = $accepted_payments[ $i / 2 ];
     289                        if ( $token_denominated && $token && $token->blockchain === $accepted_payment->blockchain && $token->address === $accepted_payment->token ) {
     290                            $amount = $total;
     291                        } else {
     292                            $amount = $this->round_token_amount( $responses[$i]->body );
     293                        }
     294                        if ( !empty( $amount ) && strval( $amount ) !== '0.00' ) {
     295                            array_push($accept, [
     296                                'blockchain' => $accepted_payment->blockchain,
     297                                'token' => $accepted_payment->token,
     298                                'amount' => $amount,
     299                                'receiver' => $accepted_payment->receiver
     300                            ]);
     301                        } else {
     302                            DePay_WC_Payments::log( 'Amount is empty: ' . $requests[$i]['url'] );
     303                        }
    263304                    } else {
    264                         $amount = $this->round_token_amount( $responses[$i]->body );
     305                        DePay_WC_Payments::log( 'Accept request failed: ' . $responses[$i]->status_code . ' ' . $requests[$i]['url'] );
    265306                    }
    266                     if ( !empty( $amount ) && strval( $amount ) !== '0.00' ) {
    267                         array_push($accept, [
    268                             'blockchain' => $accepted_payment->blockchain,
    269                             'token' => $accepted_payment->token,
    270                             'amount' => $amount,
    271                             'receiver' => $accepted_payment->receiver
    272                         ]);
    273                     } else {
    274                         DePay_WC_Payments::log( 'Amount is empty: ' . $requests[$i]['url'] );
    275                     }
    276                 } else {
    277                     DePay_WC_Payments::log( 'Accept request failed: ' . $responses[$i]->status_code . ' ' . $requests[$i]['url'] );
    278307                }
    279308            }
    280309        }
    281        
     310
    282311        if ( empty( $accept ) ) {
    283312            DePay_WC_Payments::log( 'No valid payment route found!' );
  • depay-payments-for-woocommerce/trunk/languages/depay-woocommerce-payments.pot

    r3389400 r3431602  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: DePay WooCommerce Payments 3.0.5\n"
     5"Project-Id-Version: DePay WooCommerce Payments 3.0.6\n"
    66"Report-Msgid-Bugs-To: "
    77"support@depay.com\n"
  • depay-payments-for-woocommerce/trunk/package.json

    r3389400 r3431602  
    22  "name": "@depay/web3-woocommerce-depay-payments",
    33  "moduleName": "WooCommerceDePayPayments",
    4   "version": "3.0.5",
     4  "version": "3.0.6",
    55  "description": "Accept Web3 Crypto Payments. Supports various tokens, blockchains and wallets. MetaMask, Phantom, USDC, USDT, ETH, SOL, BSC, POL, xDAI…",
    66  "main": "./dist/umd/index.js",
  • depay-payments-for-woocommerce/trunk/readme.txt

    r3389400 r3431602  
    55Tested up to: 6.8
    66Requires PHP: 7.2
    7 Stable tag: 3.0.5
     7Stable tag: 3.0.6
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    8282== Changelog ==
    8383
     84= 2026-1-3 - v3.0.6 =
     85* fixes token denomination issue (where no price is available)
     86
    8487= 2025-11-4 - v3.0.5 =
    8588* fixes Solana issues
Note: See TracChangeset for help on using the changeset viewer.