Plugin Directory

Changeset 3485383


Ignore:
Timestamp:
03/18/2026 08:25:33 AM (3 weeks ago)
Author:
coinsnap
Message:
  1. 1.5.1
Location:
coinsnap-for-contact-form-7
Files:
63 added
3 edited

Legend:

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

    r3485057 r3485383  
    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.0
     6 * Version:         1.5.1
    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.0' );}
     25if(!defined('COINSNAPCF7_VERSION' )){define( 'COINSNAPCF7_VERSION', '1.5.1' );}
    2626if(!defined('COINSNAP_SERVER_URL')){define( 'COINSNAP_SERVER_URL', 'https://app.coinsnap.io' );}
    2727if(!defined('COINSNAP_API_PATH')){define( 'COINSNAP_API_PATH', '/api/v1/');}
     
    6161            `status` varchar(20) NOT NULL DEFAULT 'Pending',       
    6262            `message` TEXT NOT NULL,
     63            `form_sent` INT(11) NOT NULL DEFAULT 0,
    6364            PRIMARY KEY (`id`)
    6465    ) DEFAULT COLLATE=utf8_general_ci";
  • coinsnap-for-contact-form-7/trunk/coinsnapcf7-class.php

    r3485057 r3485383  
    833833                $invoice_no = $wpdb->insert_id;
    834834               
    835                
    836                
    837                 //print_r($uploaded_files);
    838                 //exit();
    839 
    840                
    841835                if(is_array($uploaded_files) && count($uploaded_files) > 0 && $paymentFirst){
    842836                    $upload_dir = wp_upload_dir();
     
    846840                    foreach ($uploaded_files as $field => $path) {
    847841                       
    848                         if (!file_exists($path[0])){ continue; }
     842                        if (!isset($path[0]) || !file_exists($path[0])){ continue; }
    849843                        $new_path = $dir . '/' . basename($path[0]);
    850844                        copy($path[0], $new_path);
     
    10161010                unset( $payment_res['qrCodes'] );
    10171011                unset( $payment_res['lightningInvoice'] );
     1012               
    10181013                $table_name = $this->get_tablename();
    10191014               
     1015                $wpdb->update( $table_name,
     1016                    [
     1017                        'payment_details' => wp_json_encode( $payment_res, true ),
     1018                        'status' => $status
     1019                    ], array( 'id' => $order_id ), array( '%s', '%s' ), array( '%d' ));
     1020               
    10201021                $paymentFirst = get_post_meta( $form_id, "_cf7_coinsnap_paymentfirst", true );
    10211022               
    1022                 //$message = 'Test '. gmdate('Y-m-d H:i:s',time()) .': ';
    1023                
    1024                 if($status === 'Settled' && $paymentFirst > 0){
     1023                if($paymentFirst > 0 && $status === 'Settled'){
    10251024                   
    10261025                    $order_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM %i WHERE id=%d", $table_name, $order_id ), ARRAY_A );
    1027                     $currentStatus = $order_data['status'];
    1028                    
    1029                     if($currentStatus !== 'Settled'){
    1030                    
    1031                         $contact_form = WPCF7_ContactForm::get_instance($form_id);
    1032                         $body = json_decode($order_data['field_values'],true);
    1033                    
    1034                         $mail = $contact_form->prop('mail');
    1035                        
    1036                         foreach($body as $bkey => $bvalue){
    1037                             $mail['body'] = str_replace("[".$bkey."]", $bvalue, $mail['body']);
    1038                             $mail['subject'] = str_replace("[".$bkey."]", $bvalue, $mail['subject']);
    1039                             $mail['sender'] = str_replace("[".$bkey."]", $bvalue, $mail['sender']);
    1040                             $mail['recipient'] = str_replace("[".$bkey."]", $bvalue, $mail['recipient']);
    1041                             $mail['additional_headers'] = str_replace("[".$bkey."]", $bvalue, $mail['additional_headers']);
    1042                         }
    1043 
    1044                         $files_array = json_decode($order_data['files'],true);
    1045 
    1046                         if(count($files_array) > 0){
    1047                             $attachments = array();
    1048                             foreach($files_array as $_file){
    1049                                 $attachments[] = $_file;
    1050                             }
    1051                             $mail['attachments'] = implode("\n", $attachments);
    1052                         }
    1053 
    1054                         //$message .= ' --------------------------------------- '. print_r($mail,true);
    1055                    
    1056                         // Run submission
    1057                         $result = WPCF7_Mail::send($mail,'mail');
    1058                    
    1059                         //$message .= ' --------------------------------------- '. print_r($result,true);
    1060                     }
    1061                 }
    1062                
    1063                 $wpdb->update( $table_name, array(
    1064                     'payment_details' => wp_json_encode( $payment_res, true ),
    1065                     'status' => $status,
    1066                     //'message' => $message
    1067                     ),
    1068                     array( 'id' => $order_id ), array( '%s', '%s' ), array( '%d' )
    1069         );
     1026                   
     1027                    $mail_send_result = $this->cf7_mail_send($form_id,$order_data);
     1028                    $update_array = [
     1029                        'message' => $mail_send_result['message'],
     1030                        'form_sent' => ($mail_send_result['result'] > 0)? 1 : 0
     1031                    ];
     1032                    $wpdb->update( $table_name, $update_array, array( 'id' => $order_id ), array( '%s', '%s' ), array( '%d' ));
     1033                }
    10701034
    10711035                echo "OK";
     
    10811045            wp_die('Internal server error', '', ['response' => 500]);
    10821046        }
     1047    }
     1048   
     1049    public function cf7_mail_send($form_id,$order_data){
     1050       
     1051        $contact_form = WPCF7_ContactForm::get_instance($form_id);
     1052        $mail = $contact_form->prop('mail');
     1053       
     1054        // Sent values
     1055        $body = json_decode($order_data['field_values'],true);
     1056       
     1057        //  Template with sent values replace
     1058        foreach($body as $bkey => $bvalue){
     1059            $mail['body'] = str_replace("[".$bkey."]", $bvalue, $mail['body']);
     1060            $mail['subject'] = str_replace("[".$bkey."]", $bvalue, $mail['subject']);
     1061            $mail['sender'] = str_replace("[".$bkey."]", $bvalue, $mail['sender']);
     1062            $mail['recipient'] = str_replace("[".$bkey."]", $bvalue, $mail['recipient']);
     1063            $mail['additional_headers'] = str_replace("[".$bkey."]", $bvalue, $mail['additional_headers']);
     1064        }
     1065
     1066        //  Sent files
     1067        $files_array = json_decode($order_data['files'],true);
     1068
     1069        if(count($files_array) > 0){
     1070            $attachments = array();
     1071            foreach($files_array as $_file){ $attachments[] = $_file; }
     1072            $mail['attachments'] = implode("\n", $attachments);
     1073        }
     1074       
     1075        //  Submission message
     1076        $message = 'Submission after payment '. gmdate('Y-m-d H:i:s',time()).' --------------------------------------- '. wp_json_encode($mail,true);
     1077                   
     1078        // Run submission
     1079        $result = WPCF7_Mail::send($mail,'mail');
     1080        $result_array = array('result' => $result,'message' => $message);
     1081       
     1082        return $result_array;
    10831083    }
    10841084   
  • coinsnap-for-contact-form-7/trunk/readme.txt

    r3485057 r3485383  
    33Tags:  Coinsnap, Contact Form 7, Bitcoin, Lightning
    44Tested up to: 6.9
    5 Stable tag: 1.5.0
     5Stable tag: 1.5.1
    66License: GPLv2
    77License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    232232* Updated plugin description.
    233233
    234 
    235 
     234= 1.5.1 :: 2026-03-18 =
     235* Update: added form submission after payment status in payments table
     236
     237
Note: See TracChangeset for help on using the changeset viewer.