Changeset 2346676
- Timestamp:
- 07/26/2020 09:21:43 AM (6 years ago)
- Location:
- total-donations/trunk
- Files:
-
- 8 edited
-
admin/admin-system-status.php (modified) (1 diff)
-
assets/js/admin/admin-campaign.js (modified) (1 diff)
-
classes/CLASS_DONATION.php (modified) (2 diffs)
-
frontend/widgets/migla-circle-widget.php (modified) (1 diff)
-
gateways/stripe/migla_class_webhook.php (modified) (1 diff)
-
migla-donation-class.php (modified) (1 diff)
-
migla-donations.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
total-donations/trunk/admin/admin-system-status.php
r2342838 r2346676 330 330 </form> 331 331 </div> 332 </div> 333 </section> 334 335 <section class="panel"> 336 <header class='panel-heading'> 337 <div class='panel-actions'><a class='fa fa-caret-down' data-toggle='collapse' data-parent='.panel' href='#collapse7' aria-expanded='true'></a></div> 338 <div class='panel-title'><i class='fa fa-cc-stripe' aria-hidden='true'></i><?php echo __( "Stripe Log","migla-donation");?></div> 339 340 </header> 341 <div id="collapse7" class="panel-body mg_error_log_div"> 342 <div id="mg_error_log_donation"> 343 <?php 344 $objStripeLog = new MIGLA_LOG(""); 345 $stripe_log = "td_stripe.log"; 346 347 if(!empty($stripe_log)) 348 { 349 $file = $objStripeLog->dir_log . $stripe_log; 350 $block =1024*1024; 351 if ($fh = fopen( $file, "r")) { 352 $left=''; 353 while (!feof($fh)) 354 { 355 $temp = fread($fh, $block); 356 $fgetslines = explode("\n",$temp); 357 $fgetslines[0]=$left.$fgetslines[0]; 358 359 if(!feof($fh) )$left = array_pop($lines); 360 361 foreach ($fgetslines as $k => $line) { 362 echo $line . "<br>"; 363 } 364 } 365 } 366 fclose($fh); 367 } 368 ?> 369 </div> 370 </div> 371 <div class="panel-footer"> 332 372 </div> 333 373 </section> -
total-donations/trunk/assets/js/admin/admin-campaign.js
r2343142 r2346676 324 324 newComer = newComer + "</div>"; 325 325 326 newComer = newComer + "<div class='col-sm-2 col-xs-12 '>";326 newComer = newComer + "<div class='col-sm-2 col-xs-12 row'>"; 327 327 newComer = newComer + '<input type="text" value="[totaldonations_circlebar id='2']" class="mg_label-shortcode">'; 328 328 newComer = newComer + "</div>"; -
total-donations/trunk/classes/CLASS_DONATION.php
r2342838 r2346676 135 135 } 136 136 137 public static function st_update_column( $columnUpdates, 138 $keyValues, 139 $columnTypes, 140 $keyTypes ) 141 { 142 global $wpdb; 143 144 $wpdb->update( "{$wpdb->prefix}migla_donation", 145 $columnUpdates , 146 $keyValues, 147 $columnTypes, 148 $keyTypes 149 ); 150 } 151 137 152 public function update_meta( $donation_id, $metakey, $metavalue ) 138 153 { … … 277 292 return $value ; 278 293 } 294 295 public static function st_get_any_donationmeta( $return_value, 296 $meta_key, 297 $meta_value, 298 $meta_keytype, 299 $meta_valtype, 300 $order_by, 301 $order, 302 $limit 303 ) 304 { 305 global $wpdb; 306 307 $sql = "SELECT ".$return_value." FROM {$wpdb->prefix}migla_donation_meta"; 308 $sql .= " WHERE meta_key = ". $meta_keytype; 309 $sql .= " AND meta_value = ". $meta_valtype; 310 $sql .= " ORDER BY " . $order_by . " " . $order; 311 312 if(!empty($limit)){ 313 $sql .= " limit 0," . $limit; 314 } 315 316 $value = ''; 317 $resultSetData = array(); 318 319 320 $resultSetData = $wpdb->get_results( 321 $wpdb->prepare($sql, $meta_key, $meta_value ) 322 , ARRAY_A); 323 324 if(!empty($resultSetData)){ 325 foreach( $resultSetData as $row ){ 326 $value = $row[$return_value]; 327 } 328 }//if not empty 329 330 return $value ; 331 } 279 332 280 333 public function is_metavalue_exist( $meta_key, $meta_value ) -
total-donations/trunk/frontend/widgets/migla-circle-widget.php
r2342838 r2346676 19 19 20 20 /* Create the widget. */ 21 WP_Widget::__construct( 'totaldonations_circle_widget', __('Total Donations Circle Widget','localization'), $widget_ops, $control_ops );21 WP_Widget::__construct( 'totaldonations_circle_widget', __('Total Donations - Circle Widget','localization'), $widget_ops, $control_ops ); 22 22 } 23 23 -
total-donations/trunk/gateways/stripe/migla_class_webhook.php
r2342838 r2346676 3 3 class migla_stripe_webhook_handler 4 4 { 5 public function __construct() 6 { 7 $this->log_file = TD_DIR_PATH . "logs/td_stripe.log" ; 8 $this->is_debug_on = true; 9 } 10 11 public function migla_stripe_webhook_frontend() 12 { 13 // retrieve the request's body and parse it as JSON 14 $body = @file_get_contents('php://input'); 15 $event_json = json_decode($body); 5 public function __construct() 6 { 7 $this->log_file = Totaldonations_DIR_PATH . "logs/td_stripe.log" ; 8 $this->is_debug_on = true; 9 } 10 11 public function migla_stripe_webhook_frontend() 12 { 13 include_once Totaldonations_DIR_PATH . 'classes/CLASS_OPTIONS.php'; 16 14 17 if ( $event_json->type == 'charge.succeeded' ) 18 { 15 $endpoint_secret = MIGLA_OPTION::st_get_option('migla_webhook_key'); 16 17 $payload = @file_get_contents('php://input'); 18 $event_json = json_decode($payload); 19 20 $sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE']; 21 $event = null; 22 23 if( MIGLA_OPTION::st_get_option('migla_stripemode') == 'test' ) 24 { 25 $SK = MIGLA_OPTION::st_get_option('migla_testSK'); 26 }else{ 27 $SK = MIGLA_OPTION::st_get_option('migla_liveSK'); 28 } 29 30 try { 31 32 $event = \Stripe\Webhook::constructEvent( 33 $payload, $sig_header, $endpoint_secret 34 ); 19 35 20 }else if ( $event_json->type == 'customer.subscription.created' ) 21 { 22 23 }else if( $event_json->type == 'invoice.payment_succeeded' ) 24 { 36 $this->handle_event($event_json, $SK); 37 38 } catch(\UnexpectedValueException $e) { 39 // Invalid payload 40 http_response_code(400); 41 exit(); 42 } catch(\Stripe\Exception\SignatureVerificationException $e) { 43 // Invalid signature 44 http_response_code(400); 45 exit(); 46 } 47 48 http_response_code(200); 49 } 50 51 public function handle_event($event_json, $SK) 52 { 53 if ( $event_json->type == 'charge.succeeded' ) 54 { 55 56 }else if ( $event_json->type == 'customer.subscription.created' ) 57 { 58 59 }else if( $event_json->type == 'invoice.payment_succeeded' ) 60 { 25 61 26 }else if( $event_json->type == 'charge.refunded' )27 {62 }else if( $event_json->type == 'charge.refunded' ) 63 { 28 64 if ( !class_exists( '\Stripe\Stripe' ) ){ 29 include_once TD_DIR_PATH . 'gateways/stripe/stripe-php-6.43.0/init.php';65 include_once Totaldonations_DIR_PATH . 'gateways/stripe/stripe-php-6.43.0/init.php'; 30 66 } 31 67 32 \Stripe\Stripe::setApiKey( migla_getSK());68 \Stripe\Stripe::setApiKey( $SK ); 33 69 34 70 $charge_id = $event_json->data->object->id; 35 71 36 $objD = new CLASS_MIGLA_DONATION; 72 $pid = CLASS_MIGLA_DONATION::st_get_any_donationmeta( 'donation_id', 73 'miglad_transactionId', 74 $charge_id, 75 '%s', 76 '%s', 77 'id', 78 'ASC', 79 '' 80 ); 81 82 CLASS_MIGLA_DONATION::st_update_column( array( "status" => 3, "gateway" => "Stripe-Refunded" ), 83 array( "id" => $pid ), 84 array( "%d", "%s" ), 85 array( "%d" ) ); 86 87 $message = "Charge [". $charge_id . "] is switch to pending because refunded"; 37 88 38 $pid = $objD->get_any_donationmeta( 'donation_id', 39 'miglad_transactionId', 40 $charge_id, 41 '%s', 42 '%s', 43 'id', 44 'ASC', 45 '' 46 ); 47 48 $objD->update_column( array( "status" => 3, "gateway" => "Stripe-Refunded" ), 49 array( "id" => $pid ), 50 array( "%d", "%s" ), 51 array( "%d" ) ); 52 53 $data = $objD->get_detail( $pid, 3); 54 55 if(isset($data['miglad_form_id'])) 56 { 57 $objE = new MIGLA_EMAIL; 58 59 $form_id = $data['miglad_form_id']; 60 61 $NotifEmails = $objE->get_column( $form_id, 'notify_emails' ); 62 63 $content = "Reason of this refunded:" . $event_json->data->object->refunds->object->data[0]->reason. "<br>"; 64 65 $extra = array( "subject" => "You got a refunded donation", 66 "content" => $content 67 ); 68 69 if(!empty( $NotifEmails )) 70 { 71 $emails = (array)unserialize( $NotifEmails ); 72 73 foreach( $emails as $nf ){ 74 $objE->send_change_notification_mail( $nf, $data, get_locale(), $extra ) ; 75 } 76 } 77 78 error_log( date('[Y-m-d H:i e] ') . 'Refunded transaction ' . $charge_id . "\n" , 3 , TD_DIR_PATH . "Logs/td_stripe.log" ); 79 } 80 81 82 }else if ( $event_json->type == 'charge.dispute.created' ) 83 { 84 //Ok get this charge id 85 $charge_id = $event_json->data->object->charge; 89 error_log( date('[Y-m-d H:i e] ') . $message ."\n" , 3 , Totaldonations_DIR_PATH . "logs/td_stripe.log" ); 90 91 }else if ( $event_json->type == 'charge.dispute.created' ) 92 { 93 //Ok get this charge id 94 $charge_id = $event_json->data->object->charge; 86 95 87 $m= "This transaction with id ".$charge_id." is suspected as dispute transaction. Check your stripe account for further action.";96 $message = "This transaction with id ".$charge_id." is suspected as dispute transaction. Check your stripe account for further action."; 88 97 89 error_log( date('[Y-m-d H:i e] ') . $m ."\n" , 3 , TD_DIR_PATH . "Logs/td_stripe.log" );98 error_log( date('[Y-m-d H:i e] ') . $message ."\n" , 3 , Totaldonations_DIR_PATH . "logs/td_stripe.log" ); 90 99 91 }else if ( $event_json->type == 'charge.dispute.closed' )92 {100 }else if ( $event_json->type == 'charge.dispute.closed' ) 101 { 93 102 $charge_id = $event_json->data->object->charge; 94 $m= "This transaction with id ".$charge_id." is closed from dispute accusition.";95 error_log( date('[Y-m-d H:i e] ') . $m ."\n" , 3 , TD_DIR_PATH . "Logs/td_stripe.log" ); 103 $message = "This transaction with id ".$charge_id." is closed from dispute accusition."; 104 error_log( date('[Y-m-d H:i e] ') . $message ."\n" , 3 , Totaldonations_DIR_PATH . "logs/td_stripe.log" ); 96 105 97 }else if( $event_json->type == 'payment_intent.succeeded' ) //Subscription Made98 {106 }else if( $event_json->type == 'payment_intent.succeeded' ) //Subscription Made 107 { 99 108 100 }else{ // ELSE This will send receipts on succesful invoices109 }else{ // ELSE This will send receipts on succesful invoices 101 110 102 } 103 } 104 111 } 112 113 echo $message; 114 115 } //handle event 105 116 } 106 117 -
total-donations/trunk/migla-donation-class.php
r2343197 r2346676 9 9 { 10 10 if( ! defined( 'Totaldonations_VERSION' ) ) 11 define( 'Totaldonations_VERSION', '3.0. 7' );11 define( 'Totaldonations_VERSION', '3.0.8' ); 12 12 13 13 if( ! defined( 'Totaldonations_FREE' ) ) -
total-donations/trunk/migla-donations.php
r2343197 r2346676 6 6 Domain Path: /languages 7 7 Description: A plugin for accepting donations. 8 Version: 3.0. 78 Version: 3.0.8 9 9 Author: Binti Brindamour and Astried Silvanie 10 10 Author URI: https://totaldonations.com/ -
total-donations/trunk/readme.txt
r2343587 r2346676 15 15 16 16 The top selling WordPress plugin from CodeCanyon/ThemeForest now has a feature-rich free version. Total Donations was built with a focus on productivity and ease-of-use to get things done faster for your non-profit, church or political organization. 17 18 ** Do not upgrade from previous commercial version to this free version.19 17 20 18 = Reporting & insights = … … 139 137 == Changelog == 140 138 139 = [3.0.8] - 2020-07-24 = 140 141 * (Adding Feature!) Detect refund and dispute via Stripe Weebhook 142 * (Adding Feature!) Stripe Log 143 141 144 = [3.0.7] - 2020-07-20 = 142 145
Note: See TracChangeset
for help on using the changeset viewer.