Changeset 2421686
- Timestamp:
- 11/19/2020 05:01:47 PM (5 years ago)
- Location:
- qr-payments-via-paypal/trunk
- Files:
-
- 1 added
- 3 edited
-
README.md (added)
-
includes/class-npqp-form-invoice-data.php (modified) (3 diffs)
-
nor1m-paypal-qr-payment.php (modified) (19 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
qr-payments-via-paypal/trunk/includes/class-npqp-form-invoice-data.php
r2140460 r2421686 1 1 <?php 2 3 //debug($order, 1);4 2 5 3 if ( !$order ){ … … 13 11 $billing = $order->data['billing']; 14 12 $country_code_res = $NPQP_Country_Code->getCountryCode( $billing['phone'] ); 13 15 14 $b_country_code = $country_code_res['country_code']; 16 15 $b_national_number = $country_code_res['number']; 17 16 18 17 $shipping = $order->data['shipping']; 18 19 // Если нет шипинга, то данные берем из биллинга 20 if ( empty($shipping['postcode']) && empty($shipping['country']) ) { 21 $shipping = $billing; 22 } 19 23 20 24 $invoice_number = $order->id; … … 117 121 } 118 122 } 119 120 //debug($items, 1);121 123 122 124 $primary_recipients = [ -
qr-payments-via-paypal/trunk/nor1m-paypal-qr-payment.php
r2192999 r2421686 5 5 * Author: Vitaly Mironov 6 6 * Author URI: http://nor1m.ru 7 * Version: 0. 47 * Version: 0.5 8 8 */ 9 9 10 if ( ! @npqp_is_woocommerce_active()) {10 if (!@npqp_is_woocommerce_active()) { 11 11 return false; 12 12 } 13 13 14 function npqp_is_woocommerce_active(){ 14 function npqp_is_woocommerce_active() 15 { 15 16 static $active_plugins; 16 if ( ! isset( $active_plugins )) {17 $active_plugins = (array) get_option( 'active_plugins', array());18 if ( is_multisite()) {19 $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ));17 if (!isset($active_plugins)) { 18 $active_plugins = (array)get_option('active_plugins', array()); 19 if (is_multisite()) { 20 $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array())); 20 21 } 21 22 } … … 28 29 * Translates 29 30 */ 30 add_action( 'plugins_loaded', 'npqp_init' ); 31 function npqp_init(){ 32 load_plugin_textdomain( 'npqp', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 31 add_action('plugins_loaded', 'npqp_init'); 32 function npqp_init() 33 { 34 load_plugin_textdomain('npqp', false, dirname(plugin_basename(__FILE__)) . '/languages/'); 33 35 } 34 36 … … 36 38 * Creating a page with a qr code when activating the plugin 37 39 */ 38 register_activation_hook( __FILE__, 'npqp_plugin_activate' ); 39 function npqp_plugin_activate(){ 40 register_activation_hook(__FILE__, 'npqp_plugin_activate'); 41 function npqp_plugin_activate() 42 { 40 43 41 44 $title = "QR Payment"; 42 $content = '<div id="qr_code_img" style="text-align: center;">[NPQP-QR-CODE-PAGE]</div>';45 $content = '<div id="qr_code_img" style="text-align: center;">[NPQP-QR-CODE-PAGE]</div>'; 43 46 $content .= '<div style="text-align: center; display: inline-block; position: relative; margin-top: -10px; width: 100%;">'; 44 $content .= '<img style="display: inline-block;" src="'. plugins_url('assets/img/processing.gif', __FILE__) .'" />';47 $content .= '<img style="display: inline-block;" src="' . plugins_url('assets/img/processing.gif', __FILE__) . '" />'; 45 48 $content .= '</div>'; 46 49 $content .= '<b style="text-align: center; display: inline-block; position: relative; top: -30px; width: 100%; font-size: 16px; color: #565656;">' . __('Payment is pending', 'npqp') . '</b>'; 47 50 $content .= '<a href="javascript:history.back()" style="background: #0f7fc3;padding: 10px 15px;display: inline-block;margin-top: 21px;border-radius: 3px;color: #fff;width: 250px;max-width: 100%;font-size: 16px;text-decoration: none;cursor: pointer;top: -30px;position: relative;">' . __('Back to checkout', 'npqp') . '</a>'; 48 51 49 if ( ! post_exists( $title )) {52 if (!post_exists($title)) { 50 53 $post_id = wp_insert_post(array( 51 'post_type' => 'page',52 'post_title' => $title,53 'post_content' => $content,54 'post_status' => 'publish',55 'post_author' => 1,56 'post_name' => 'qr-payments',54 'post_type' => 'page', 55 'post_title' => $title, 56 'post_content' => $content, 57 'post_status' => 'publish', 58 'post_author' => 1, 59 'post_name' => 'qr-payments', 57 60 )); 58 61 } 59 62 } 60 63 61 require_once dirname( __FILE__) . '/includes/class-npqp-paypal-api.php';64 require_once dirname(__FILE__) . '/includes/class-npqp-paypal-api.php'; 62 65 63 66 /* 64 67 * This action hook registers our PHP class as a WooCommerce payment gateway 65 68 */ 66 add_filter( 'woocommerce_payment_gateways', 'NPQP_add_gateway_class' ); 67 function NPQP_add_gateway_class( $gateways ) { 69 add_filter('woocommerce_payment_gateways', 'NPQP_add_gateway_class'); 70 function NPQP_add_gateway_class($gateways) 71 { 68 72 $gateways[] = 'WC_NPQP_Gateway'; 69 73 return $gateways; 70 74 } 71 75 72 // admin styles 73 wp_enqueue_style( 'npqp_admin_css', plugins_url('assets/css/admin.css', __FILE__) ); 74 75 // qr code generator 76 wp_enqueue_script( 'qrcode', plugins_url('assets/js/qrcode.min.js', __FILE__) ); 77 78 // frontend styles 79 wp_enqueue_style( 'npqp_frontend_css', plugins_url('assets/css/frontend.css', __FILE__) ); 76 // правильный способ подключить стили и скрипты 77 add_action('wp_enqueue_scripts', function () { 78 // admin styles 79 wp_enqueue_style('npqp_admin_css', plugins_url('assets/css/admin.css', __FILE__)); 80 // qr code generator 81 wp_enqueue_script('qrcode', plugins_url('assets/js/qrcode.min.js', __FILE__)); 82 // frontend styles 83 wp_enqueue_style('npqp_frontend_css', plugins_url('assets/css/frontend.css', __FILE__)); 84 // frontend scripts 85 wp_enqueue_script('npqp_main_js', plugins_url('assets/js/main.js', __FILE__), array('jquery')); 86 }); 80 87 81 88 /* 82 89 * The class itself, please note that it is inside plugins_loaded action hook 83 90 */ 84 add_action( 'plugins_loaded', 'NPQP_init_gateway_class' ); 85 function NPQP_init_gateway_class() { 91 add_action('plugins_loaded', 'NPQP_init_gateway_class'); 92 function NPQP_init_gateway_class() 93 { 86 94 87 95 // check ajax status 88 if ( isset($_GET['npqp_ajax_url'])) {96 if (isset($_GET['npqp_ajax_url'])) { 89 97 echo npqp_ajax(); 90 98 die(200); 91 99 } 92 100 93 class WC_NPQP_Gateway extends WC_Payment_Gateway { 94 95 public function __construct() { 96 97 $this->id = 'npqp'; // payment gateway plugin ID 98 $icon = ''; // URL of the icon that will be displayed on checkout page near your gateway name 99 $icon = apply_filters( 'npqp_icon', $icon ); // filter 100 $this->icon = $icon; 101 $this->has_fields = true; // in case you need a custom credit card form 102 $this->method_title = __('QR payments via PayPal', 'npqp'); 101 class WC_NPQP_Gateway extends WC_Payment_Gateway 102 { 103 104 public $id; 105 public $title; 106 public $icon; 107 public $has_fields; 108 public $method_title; 109 public $method_description; 110 public $form_fields; 111 public $description; 112 public $enabled; 113 public $testmode; 114 public $api_client_id; 115 public $api_secret_id; 116 public $paypal_webhook_id; 117 public $qr_code_page_url; 118 public $qr_code_width; 119 public $qr_code_height; 120 public $qr_code_stroke_color; 121 public $qr_code_background_color; 122 123 public function __construct() 124 { 125 126 $this->id = 'npqp'; // payment gateway plugin ID 127 $icon = ''; // URL of the icon that will be displayed on checkout page near your gateway name 128 $icon = apply_filters('npqp_icon', $icon); // filter 129 $this->icon = $icon; 130 $this->has_fields = true; // in case you need a custom credit card form 131 $this->method_title = __('QR payments via PayPal', 'npqp'); 103 132 $this->method_description = __('Payment with qr code', 'npqp'); // will be displayed on the options page 104 $this->form_fields = require dirname( __FILE__) . '/includes/class-npqp-form-fields.php';105 106 include_once dirname( __FILE__) . '/includes/class-npqp-country-code.php';133 $this->form_fields = require dirname(__FILE__) . '/includes/class-npqp-form-fields.php'; 134 135 include_once dirname(__FILE__) . '/includes/class-npqp-country-code.php'; 107 136 108 137 // gateways can support subscriptions, refunds, saved payment methods, … … 114 143 // Load the settings. 115 144 $this->init_settings(); 116 $this->title = $this->get_option( 'title' ); 117 $this->description = $this->get_option( 'description' ); 118 $this->enabled = $this->get_option( 'enabled' ); 119 $this->testmode = 'yes' === $this->get_option( 'testmode' ); 120 $this->api_client_id = $this->testmode ? $this->get_option( 'sandbox_api_client_id' ) : $this->get_option( 'live_api_client_id' ); 121 $this->api_secret_id = $this->testmode ? $this->get_option( 'sandbox_api_secret_id' ) : $this->get_option( 'live_api_secret_id' ); 122 $this->paypal_webhook_id = $this->testmode ? $this->get_option( 'sandbox_paypal_webhook_id' ) : $this->get_option( 'live_paypal_webhook_id' ); 123 124 $this->qr_code_page_url = $this->get_option( 'qr_code_page_url' ) ? $this->get_option( 'qr_code_page_url' ) : "qr-code-page"; 125 $this->qr_code_width = $this->get_option( 'qr_code_width' ) ? $this->get_option( 'qr_code_width' ) : "200"; 126 $this->qr_code_height = $this->get_option( 'qr_code_height' ) ? $this->get_option( 'qr_code_height' ) : "200"; 127 $this->qr_code_stroke_color = $this->get_option( 'qr_code_stroke_color' ) ? $this->get_option( 'qr_code_stroke_color' ) : "#00000"; 128 129 // and this is our custom JS in your plugin directory that works with token.js 130 wp_enqueue_script( 'npqp_main_js', plugins_url( 'assets/js/main.js', __FILE__ ), array('jquery') ); 131 132 /* if ( is_admin() && isset($_GET['section']) && $_GET['section'] == 'npqp' ) { 133 wp_localize_script('jquery', 'nqpp_l18n', array( 134 'Visit site' => __('Visit site', 'npqp'), 135 'Donate' => __('Donate', 'npqp') 136 )); 137 wp_enqueue_script( 'npqp_admin_js', plugins_url( 'assets/js/admin.js', __FILE__ ), array('jquery') ); 138 }*/ 139 140 // in most payment processors you have to use PUBLIC KEY to obtain a token 141 wp_localize_script( 'npqp_main_js', 'npqp_params', array( 142 'qr_code_page_url' => $this->qr_code_page_url, 143 'qr_code_width' => $this->qr_code_width, 144 'qr_code_height' => $this->qr_code_height, 145 'qr_code_stroke_color' => $this->qr_code_stroke_color, 146 'qr_code_background_color' => $this->qr_code_background_color, 147 'npqp_ajax_url' => home_url('/?npqp_ajax_url'), 148 'is_qrcodepage' => is_qrcodepage() 149 )); 145 $this->title = $this->get_option('title'); 146 $this->description = $this->get_option('description'); 147 $this->enabled = $this->get_option('enabled'); 148 $this->testmode = 'yes' === $this->get_option('testmode'); 149 $this->api_client_id = $this->testmode ? $this->get_option('sandbox_api_client_id') : $this->get_option('live_api_client_id'); 150 $this->api_secret_id = $this->testmode ? $this->get_option('sandbox_api_secret_id') : $this->get_option('live_api_secret_id'); 151 $this->paypal_webhook_id = $this->testmode ? $this->get_option('sandbox_paypal_webhook_id') : $this->get_option('live_paypal_webhook_id'); 152 153 $this->qr_code_page_url = $this->get_option('qr_code_page_url') ? $this->get_option('qr_code_page_url') : "qr-code-page"; 154 $this->qr_code_width = $this->get_option('qr_code_width') ? $this->get_option('qr_code_width') : "200"; 155 $this->qr_code_height = $this->get_option('qr_code_height') ? $this->get_option('qr_code_height') : "200"; 156 $this->qr_code_stroke_color = $this->get_option('qr_code_stroke_color') ? $this->get_option('qr_code_stroke_color') : "#00000"; 157 $this->qr_code_background_color = "#fff"; 158 159 add_action( 'wp_enqueue_scripts', function(){ 160 wp_localize_script('npqp_main_js', 'npqp_params', array( 161 'qr_code_page_url' => $this->qr_code_page_url, 162 'qr_code_width' => $this->qr_code_width, 163 'qr_code_height' => $this->qr_code_height, 164 'qr_code_stroke_color' => $this->qr_code_stroke_color, 165 'qr_code_background_color' => $this->qr_code_background_color, 166 'npqp_ajax_url' => home_url('/?npqp_ajax_url'), 167 'is_qrcodepage' => is_qrcodepage() 168 )); 169 }); 150 170 151 171 // This action hook saves the settings 152 add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, [172 add_action('woocommerce_update_options_payment_gateways_' . $this->id, [ 153 173 $this, 'process_admin_options' 154 174 ]); 155 175 156 176 // You can also register a webhook here 157 add_action( 'woocommerce_api_npqp', [ $this, 'webhook' ]);158 159 if ( isset($_GET['npqrdbg'])) {177 add_action('woocommerce_api_npqp', [$this, 'webhook']); 178 179 if (isset($_GET['npqrdbg'])) { 160 180 //... 161 181 } … … 166 186 * Payment fields in checkout 167 187 */ 168 public function payment_fields() { 169 if ( $this->description ) { 170 echo wpautop( wp_kses_post( trim( $this->description ) ) ); 188 public function payment_fields() 189 { 190 if ($this->description) { 191 echo wpautop(wp_kses_post(trim($this->description))); 171 192 } 172 193 } … … 175 196 * Get PayPal payment link 176 197 */ 177 public function get_payment_link($order){ 198 public function get_payment_link($order) 199 { 178 200 179 201 $PayPalApi = new NPQP_PayPal_API([ 180 'testmode' => $this->testmode,181 'api_client_id' => $this->api_client_id,182 'api_secret_id' => $this->api_secret_id,202 'testmode' => $this->testmode, 203 'api_client_id' => $this->api_client_id, 204 'api_secret_id' => $this->api_secret_id, 183 205 'paypal_webhook_id' => $this->paypal_webhook_id, 184 'order' => $order,185 'fields' => $this->settings206 'order' => $order, 207 'fields' => $this->settings 186 208 ]); 187 209 … … 192 214 * Fields validation 193 215 */ 194 public function validate_fields() { 216 public function validate_fields() 217 { 195 218 196 219 $validate = true; 197 220 198 $billing_first_name = sanitize_text_field( $_POST['billing_first_name']);199 200 if ( empty( $billing_first_name )) {201 wc_add_notice( __('First name is required!', 'npqp'), 'error');221 $billing_first_name = sanitize_text_field($_POST['billing_first_name']); 222 223 if (empty($billing_first_name)) { 224 wc_add_notice(__('First name is required!', 'npqp'), 'error'); 202 225 $validate = false; 203 226 } 204 227 205 $validate = apply_filters( 'npqp_validate_fields_flag', $validate); // filter228 $validate = apply_filters('npqp_validate_fields_flag', $validate); // filter 206 229 return $validate; 207 230 } … … 210 233 * We're processing the payments here 211 234 */ 212 public function process_payment( $order_id ) { 235 public function process_payment($order_id) 236 { 213 237 214 238 global $woocommerce; 215 239 216 240 // we need it to get any order detailes 217 $order = wc_get_order( $order_id);241 $order = wc_get_order($order_id); 218 242 219 243 $payment_link = $this->get_payment_link($order); 220 244 221 if ( isset($payment_link['status']) && $payment_link['status'] == 'error') {245 if (isset($payment_link['status']) && $payment_link['status'] == 'error') { 222 246 $error = $payment_link['error']; 223 $error = apply_filters( 'npqp_error_text', $error); // filter224 wc_add_notice( $error , 'error');247 $error = apply_filters('npqp_error_text', $error); // filter 248 wc_add_notice($error, 'error'); 225 249 return; 226 250 } 227 251 228 if ( !$payment_link) {252 if (!$payment_link) { 229 253 npqpLog('process_payment No valid payment link', [ 230 254 'order_id' => $order_id, 231 255 'payment_link' => $payment_link, 232 256 ]); 233 wc_add_notice( __('No valid payment link', 'npqp'), 'error');257 wc_add_notice(__('No valid payment link', 'npqp'), 'error'); 234 258 return; 235 259 } … … 238 262 $redirect_link = $this->qr_code_page_url ? $this->qr_code_page_url : 'qr-payments'; 239 263 $redirect_link = '/' . $redirect_link . '/?payment_link=' . htmlentities(urlencode(esc_url($payment_link))) . '&order_id=' . (int)$order_id; 240 $redirect_link = home_url( $redirect_link);241 $redirect_link = apply_filters( 'npqp_redirect_link', $redirect_link); // filter264 $redirect_link = home_url($redirect_link); 265 $redirect_link = apply_filters('npqp_redirect_link', $redirect_link); // filter 242 266 243 267 npqpLog('process_payment', [ 244 'order_id' => $order_id,245 'payment_link' => $payment_link,268 'order_id' => $order_id, 269 'payment_link' => $payment_link, 246 270 'redirect_link' => $redirect_link, 247 271 ]); … … 249 273 // redirect to qr page 250 274 return array( 251 'result' => 'success',275 'result' => 'success', 252 276 'redirect' => $redirect_link 253 277 ); … … 257 281 * In case you need a webhook, like PayPal IPN etc 258 282 */ 259 public function webhook() { 260 261 $post = json_decode( file_get_contents('php://input'), 1 ); 262 263 if ( isset($post['event_type']) && $post['event_type'] == 'INVOICING.INVOICE.PAID' ) { 283 public function webhook() 284 { 285 286 $post = json_decode(file_get_contents('php://input'), 1); 287 288 if (isset($post['event_type']) && $post['event_type'] == 'INVOICING.INVOICE.PAID') { 264 289 265 290 $PayPalApi = new NPQP_PayPal_API([ 266 'testmode' => $this->testmode,267 'api_client_id' => $this->api_client_id,268 'api_secret_id' => $this->api_secret_id,291 'testmode' => $this->testmode, 292 'api_client_id' => $this->api_client_id, 293 'api_secret_id' => $this->api_secret_id, 269 294 'paypal_webhook_id' => $this->paypal_webhook_id 270 295 ]); … … 276 301 ]); 277 302 278 if ( $verify == 'SUCCESS') {279 280 $webhook_event_arr = json_decode( file_get_contents('php://input'), true);303 if ($verify == 'SUCCESS') { 304 305 $webhook_event_arr = json_decode(file_get_contents('php://input'), true); 281 306 $status_success = 'PAID'; 282 $status_success = apply_filters( 'npqp_status_success', $status_success); // filter283 284 if ( $webhook_event_arr['resource']['invoice']['status'] != $status_success) {307 $status_success = apply_filters('npqp_status_success', $status_success); // filter 308 309 if ($webhook_event_arr['resource']['invoice']['status'] != $status_success) { 285 310 return; 286 311 } … … 290 315 ]); 291 316 292 if ( isset($webhook_event_arr['resource']['invoice']['detail']['invoice_number']) ){317 if (isset($webhook_event_arr['resource']['invoice']['detail']['invoice_number'])) { 293 318 294 319 $invoice_number = $webhook_event_arr['resource']['invoice']['detail']['invoice_number']; 295 320 296 321 // get clear invoice id 297 if ( strpos($invoice_number, '-') !== false) {322 if (strpos($invoice_number, '-') !== false) { 298 323 $invoice_number = explode('-', $invoice_number)[0]; 299 324 } 300 325 301 $order = wc_get_order( $invoice_number);302 303 $order = apply_filters( 'npqp_order', $order); // filter304 305 if ( $order) {306 307 if ( ! $order->is_paid()) {326 $order = wc_get_order($invoice_number); 327 328 $order = apply_filters('npqp_order', $order); // filter 329 330 if ($order) { 331 332 if (!$order->is_paid()) { 308 333 global $woocommerce; 309 334 $order->payment_complete(); … … 312 337 313 338 $add_order_note = __('Hey, your order is paid! Thank you!', 'npqp'); 314 $add_order_note = apply_filters( 'npqp_add_order_note', $add_order_note); // filter315 $order->add_order_note( $add_order_note);339 $add_order_note = apply_filters('npqp_add_order_note', $add_order_note); // filter 340 $order->add_order_note($add_order_note); 316 341 317 342 npqpLog('verifyWebhook', [ … … 334 359 335 360 } 361 362 363 new WC_NPQP_Gateway(); 336 364 } 337 365 338 366 // шорткод страницы с qr кодом 339 add_shortcode( 'NPQP-QR-CODE-PAGE', 'NPQP_QR_code_page' ); 340 function NPQP_QR_code_page() { 341 342 if ( isset($_GET['order_id']) ){ 343 $order = wc_get_order( $_GET['order_id'] ); 344 if ( $order ) { 367 add_shortcode('NPQP-QR-CODE-PAGE', 'NPQP_QR_code_page'); 368 function NPQP_QR_code_page() 369 { 370 371 if (isset($_GET['order_id'])) { 372 $order = wc_get_order($_GET['order_id']); 373 if ($order) { 345 374 $return_url = $order->get_checkout_order_received_url(); 346 375 } else { … … 353 382 echo '<div id="wc-npqp-qr-form" class="wc-npqp-qr-form">'; 354 383 355 do_action( 'npqp_qr_form_before', 'npqp'); // action356 357 echo '<div class="npqp-qr-form-wrapper">358 <input type="hidden" id="npqp-order-id" value="' . esc_attr( urldecode( $_GET['order_id'] ) ) .'">359 <input type="hidden" id="npqp-return-url" value="' . esc_attr( urldecode( $return_url ) ) .'">360 <input type="hidden" id="npqp-qrcode-text" value="' . esc_attr( urldecode( $_GET['payment_link'] ) ) .'">361 <a target="_blank" href="' . esc_attr( urldecode( $_GET['payment_link'] ) ) .'"><div id="npqp-qrcode"></div></a>362 <a class="npqp-paynow-btn onlymob" target="_blank" href="' . esc_attr( urldecode( $_GET['payment_link'] ) ) .'">' . __('Pay Now', 'npqp') . '</a>384 do_action('npqp_qr_form_before', 'npqp'); // action 385 386 echo '<div class="npqp-qr-form-wrapper"> 387 <input type="hidden" id="npqp-order-id" value="' . esc_attr(urldecode($_GET['order_id'])) . '"> 388 <input type="hidden" id="npqp-return-url" value="' . esc_attr(urldecode($return_url)) . '"> 389 <input type="hidden" id="npqp-qrcode-text" value="' . esc_attr(urldecode($_GET['payment_link'])) . '"> 390 <a target="_blank" href="' . esc_attr(urldecode($_GET['payment_link'])) . '"><div id="npqp-qrcode"></div></a> 391 <a class="npqp-paynow-btn onlymob" target="_blank" href="' . esc_attr(urldecode($_GET['payment_link'])) . '">' . __('Pay Now', 'npqp') . '</a> 363 392 </div>'; 364 393 365 do_action( 'npqp_qr_form_after', 'npqp'); // action394 do_action('npqp_qr_form_after', 'npqp'); // action 366 395 367 396 echo '<div class="clear"></div>'; … … 369 398 370 399 // npqp ajax 371 function npqp_ajax() { 372 if( empty( $_GET['action'] ) ) { 400 function npqp_ajax() 401 { 402 if (empty($_GET['action'])) { 373 403 return __('Action is missed', 'npqp'); 374 404 } 375 if ( $_GET['action'] == 'getorderpaidstatus') {405 if ($_GET['action'] == 'getorderpaidstatus') { 376 406 return npqp_order_is_paid($_GET['order_id']); 377 407 } … … 379 409 380 410 // order is paid 381 function npqp_order_is_paid($id){ 411 function npqp_order_is_paid($id) 412 { 382 413 $post = get_post($id); 383 if ( isset($post->post_status) ){414 if (isset($post->post_status)) { 384 415 return ($post->post_status == 'wc-processing' || $post->post_status == 'wc-completed') ? 1 : 0; 385 416 } else { … … 389 420 390 421 // debug 391 function npqpDebug($data, $die = false) { 392 echo "<pre>"; var_dump($data); echo "</pre>"; 422 function npqpDebug($data, $die = false) 423 { 424 echo "<pre>"; 425 var_dump($data); 426 echo "</pre>"; 393 427 if ($die) exit(200); 394 428 } 395 429 396 function is_qrcodepage(){ 397 return wc_post_content_has_shortcode( 'NPQP-QR-CODE-PAGE' ); 430 function is_qrcodepage() 431 { 432 return wc_post_content_has_shortcode('NPQP-QR-CODE-PAGE'); 398 433 } 399 434 400 435 // log 401 function npqpLog($title, $data = false){ 402 $filename = dirname( __FILE__ ) . '/log.txt'; 403 if ( !$data ) { 404 file_put_contents( $filename, date('d.m.Y/H:i:s') . ': ' . $_SERVER['REMOTE_ADDR'] . ': ' . $title . PHP_EOL, FILE_APPEND ); 436 function npqpLog($title, $data = false) 437 { 438 $filename = dirname(__FILE__) . '/log.txt'; 439 if (!$data) { 440 file_put_contents($filename, date('d.m.Y/H:i:s') . ': ' . $_SERVER['REMOTE_ADDR'] . ': ' . $title . PHP_EOL, FILE_APPEND); 405 441 } else { 406 file_put_contents( $filename, date('d.m.Y/H:i:s') . ': ' . $_SERVER['REMOTE_ADDR'] . ': ' . $title . PHP_EOL . var_export($data, true) . PHP_EOL, FILE_APPEND);407 } 408 } 442 file_put_contents($filename, date('d.m.Y/H:i:s') . ': ' . $_SERVER['REMOTE_ADDR'] . ': ' . $title . PHP_EOL . var_export($data, true) . PHP_EOL, FILE_APPEND); 443 } 444 } -
qr-payments-via-paypal/trunk/readme.txt
r2367945 r2421686 1 === Qr payments via PayPal ===1 === WooCommerce Qr payments via PayPal === 2 2 Contributors: nor1m 3 3 Donate link: https://paypal.me/nor1m
Note: See TracChangeset
for help on using the changeset viewer.