Plugin Directory

Changeset 3486371


Ignore:
Timestamp:
03/19/2026 10:46:12 AM (2 weeks ago)
Author:
coinsnap
Message:
  1. 1.5.2
Location:
coinsnap-for-contact-form-7
Files:
63 added
4 edited

Legend:

Unmodified
Added
Removed
  • coinsnap-for-contact-form-7/trunk/coinsnap-for-contact-form-7.php

    r3485383 r3486371  
    44 * Plugin URI:      https://coinsnap.io/wp-add-ons/contact-form-7/
    55 * Description:     With this Bitcoin payment plugin for Contact Form 7 you can now offer products, downloads, bookings or get donations in Bitcoin right in your forms!
    6  * Version:         1.5.1
     6 * Version:         1.5.2
    77 * Author:          Coinsnap
    88 * Author URI:      https://coinsnap.io/
     
    2323
    2424if(!defined('COINSNAPCF7_REFERRAL_CODE' )){define( 'COINSNAPCF7_REFERRAL_CODE', 'D19827' );}
    25 if(!defined('COINSNAPCF7_VERSION' )){define( 'COINSNAPCF7_VERSION', '1.5.1' );}
     25if(!defined('COINSNAPCF7_VERSION' )){define( 'COINSNAPCF7_VERSION', '1.5.2' );}
    2626if(!defined('COINSNAP_SERVER_URL')){define( 'COINSNAP_SERVER_URL', 'https://app.coinsnap.io' );}
    2727if(!defined('COINSNAP_API_PATH')){define( 'COINSNAP_API_PATH', '/api/v1/');}
  • coinsnap-for-contact-form-7/trunk/coinsnapcf7-class.php

    r3485383 r3486371  
    790790                        '_date'       => date_i18n(get_option('date_format')),
    791791                        '_time'       => date_i18n(get_option('time_format')),
    792                         '_remote_ip' => sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR'])) ?? '',
    793                         '_user_agent' => sanitize_text_field(wp_unslash($_SERVER['HTTP_USER_AGENT'])) ?? '',
     792                        '_remote_ip' => (isset($_SERVER['REMOTE_ADDR']))? sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR'])) : '',
     793                        '_user_agent' => (isset($_SERVER['HTTP_USER_AGENT']))? sanitize_text_field(wp_unslash($_SERVER['HTTP_USER_AGENT'])) : '',
    794794                        '_url' => wp_unslash($submission->get_meta('url')),
    795                         '_referer' => sanitize_text_field(wp_unslash($_SERVER['HTTP_REFERER'])) ?? ''
     795                        '_referer' => (isset($_SERVER['HTTP_REFERER']))? sanitize_text_field(wp_unslash($_SERVER['HTTP_REFERER'])) : ''
    796796                    ];
    797797                   
     
    947947        if ( filter_input(INPUT_GET,'cf7-listener',FILTER_SANITIZE_FULL_SPECIAL_CHARS) === null  || filter_input(INPUT_GET,'cf7-listener',FILTER_SANITIZE_FULL_SPECIAL_CHARS) !== 'coinsnap' ) { return; }
    948948       
    949        
    950        
    951949        //  form_id get parameter check
    952950        $form_id = filter_input(INPUT_GET,'form_id',FILTER_VALIDATE_INT);
     
    1001999
    10021000                $invoice_id = $postData->invoiceId;
     1001                $payload_type = $postData->type;
    10031002
    10041003                $client = new \Coinsnap\Client\Invoice( $this->getApiUrl(), $this->getApiKey() );           
     
    10211020                $paymentFirst = get_post_meta( $form_id, "_cf7_coinsnap_paymentfirst", true );
    10221021               
    1023                 if($paymentFirst > 0 && $status === 'Settled'){
     1022                if($paymentFirst > 0 && ($payload_type === 'Settled' || $payload_type === 'InvoiceSettled')){
    10241023                   
    10251024                    $order_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM %i WHERE id=%d", $table_name, $order_id ), ARRAY_A );
    10261025                   
    1027                     $mail_send_result = $this->cf7_mail_send($form_id,$order_data);
     1026                    $mail_send_result = $this->cf7_mail_send($form_id,$order_data);//cf7_mail_send
    10281027                    $update_array = [
    10291028                        'message' => $mail_send_result['message'],
     
    10461045        }
    10471046    }
     1047    /*
     1048    public function cf7_emulate_send($form_id,$order_data){
     1049
     1050        $contact_form = WPCF7_ContactForm::get_instance($form_id);
     1051
     1052        // Sent values
     1053        $body = json_decode($order_data['field_values'],true);
     1054       
     1055        $_POST = $body;
     1056        $_POST['_wpcf7'] = $form_id;
     1057        $_POST['_wpcf7_unit_tag'] = 'wpcf7-f'.$form_id.'-p0-o1';
     1058        $_POST['_wpcf7_container_post'] = 0;
     1059       
     1060        $files_array = json_decode($order_data['files'],true);
     1061
     1062        // attachments
     1063        add_filter('wpcf7_mail_components', function($components) use ($files_array){
     1064
     1065            $valid = [];
     1066            //  Sent files
     1067
     1068            foreach ($files_array as $file) {
     1069                if (file_exists($file)) {
     1070                    $valid[] = $file;
     1071                }
     1072            }
     1073
     1074            $components['attachments'] = implode("\n", $valid);
     1075
     1076            return $components;
     1077        });
     1078
     1079        // отключаем spam
     1080        add_filter('wpcf7_spam', '__return_false');
     1081
     1082        //  Submission message
     1083        $message = 'Submission after payment '. gmdate('Y-m-d H:i:s',time()).
     1084                ' --------------------------------------- '. wp_json_encode($contact_form,true).
     1085                ' --------------------------------------- '. wp_json_encode($_POST,true);
     1086       
     1087       
     1088        // отправка как CF7
     1089        $result = $contact_form->submit(true);
     1090
     1091        remove_all_filters('wpcf7_mail_components');
     1092        remove_all_filters('wpcf7_spam');
     1093       
     1094        $result_array = array('result' => $result,'message' => $message);
     1095
     1096        return $result_array;
     1097    }*/
    10481098   
    10491099    public function cf7_mail_send($form_id,$order_data){
  • coinsnap-for-contact-form-7/trunk/library/Client/Invoice.php

    r3378565 r3486371  
    3030    public function loadExchangeRates(): array {
    3131        $url = 'https://api.coingecko.com/api/v3/exchange_rates';
    32         $headers = [];
     32        $headers = [
     33            'Host' => 'api.coingecko.com',
     34            'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:148.0) Gecko/20100101 Firefox/148.0',
     35            'Accept:' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
     36            'Accept-Language' => 'en-US,en;q=0.9',
     37            'Accept-Encoding' => 'gzip, deflate, br, zstd',
     38            'Connection' => 'keep-alive',
     39            'Priority' => 'u=0, i',
     40        ];
    3341        $method = 'GET';
    34         $response = $this->getHttpClient()->request($method, $url, $headers);
    35        
    36         if ($response->getStatus() === 200) {
    37             $body = json_decode($response->getBody(), true, 512, JSON_THROW_ON_ERROR);
    38         }
     42        $code = 1000;
     43       
     44        while($code > 399){
     45            if($code !== 1000){ sleep(2); }
     46            $response = $this->getHttpClient()->request($method, $url, $headers);
     47            $code = (int)$response->getStatus();
     48        }
     49       
     50        $body = json_decode($response->getBody(), true, 512, JSON_THROW_ON_ERROR);       
     51        /*
     52        if ((int)$response->getStatus() < 400) {}
    3953        else {
    40             return array('result' => false, 'error' => 'ratesLoadingError');
    41         }
     54            return array('result' => false, 'error' => 'ratesLoadingError ('.(int)$response->getStatus().')');
     55        }*/
    4256       
    4357        if (count($body)<1 || !isset($body['rates'])){
     
    5064    public function checkPaymentData($amount,$currency,$provider = 'coinsnap',$mode = 'invoice'): array {
    5165       
    52         $btcPayCurrencies = $this->loadExchangeRates();
     66        if(defined('COINSNAP_CURRENCY_RATES')){
     67            $btcPayCurrencies = COINSNAP_CURRENCY_RATES;
     68        }
     69        else {
     70            $btcPayCurrencies = $this->loadExchangeRates();
     71            define('COINSNAP_CURRENCY_RATES',$btcPayCurrencies);
     72        }
    5373           
    5474        if(!$btcPayCurrencies['result']){
  • coinsnap-for-contact-form-7/trunk/readme.txt

    r3485383 r3486371  
    33Tags:  Coinsnap, Contact Form 7, Bitcoin, Lightning
    44Tested up to: 6.9
    5 Stable tag: 1.5.1
     5Stable tag: 1.5.2
    66License: GPLv2
    77License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    235235* Update: added form submission after payment status in payments table
    236236
    237 
     237= 1.5.2 :: 2026-03-19 =
     238* Updated webhook payload handler.
     239* Updated currency rates handler functionality.
Note: See TracChangeset for help on using the changeset viewer.