@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | } |
665 | 665 | |
666 | 666 | function wpinv_get_payment_key( $invoice_id = 0 ) { |
667 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
667 | + $invoice = new WPInv_Invoice( $invoice_id ); |
|
668 | 668 | return $invoice->get_key(); |
669 | 669 | } |
670 | 670 | |
@@ -1197,20 +1197,20 @@ discard block |
||
1197 | 1197 | } |
1198 | 1198 | |
1199 | 1199 | function wpinv_checkout_get_cc_info() { |
1200 | - $cc_info = array(); |
|
1201 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
1202 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
1203 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
1204 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
1205 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
1206 | - $cc_info['card_address'] = isset( $_POST['wpinv_address'] ) ? sanitize_text_field( $_POST['wpinv_address'] ) : ''; |
|
1207 | - $cc_info['card_city'] = isset( $_POST['wpinv_city'] ) ? sanitize_text_field( $_POST['wpinv_city'] ) : ''; |
|
1208 | - $cc_info['card_state'] = isset( $_POST['wpinv_state'] ) ? sanitize_text_field( $_POST['wpinv_state'] ) : ''; |
|
1209 | - $cc_info['card_country'] = isset( $_POST['wpinv_country'] ) ? sanitize_text_field( $_POST['wpinv_country'] ) : ''; |
|
1210 | - $cc_info['card_zip'] = isset( $_POST['wpinv_zip'] ) ? sanitize_text_field( $_POST['wpinv_zip'] ) : ''; |
|
1211 | - |
|
1212 | - // Return cc info |
|
1213 | - return $cc_info; |
|
1200 | + $cc_info = array(); |
|
1201 | + $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
1202 | + $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
1203 | + $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
1204 | + $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
1205 | + $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
1206 | + $cc_info['card_address'] = isset( $_POST['wpinv_address'] ) ? sanitize_text_field( $_POST['wpinv_address'] ) : ''; |
|
1207 | + $cc_info['card_city'] = isset( $_POST['wpinv_city'] ) ? sanitize_text_field( $_POST['wpinv_city'] ) : ''; |
|
1208 | + $cc_info['card_state'] = isset( $_POST['wpinv_state'] ) ? sanitize_text_field( $_POST['wpinv_state'] ) : ''; |
|
1209 | + $cc_info['card_country'] = isset( $_POST['wpinv_country'] ) ? sanitize_text_field( $_POST['wpinv_country'] ) : ''; |
|
1210 | + $cc_info['card_zip'] = isset( $_POST['wpinv_zip'] ) ? sanitize_text_field( $_POST['wpinv_zip'] ) : ''; |
|
1211 | + |
|
1212 | + // Return cc info |
|
1213 | + return $cc_info; |
|
1214 | 1214 | } |
1215 | 1215 | |
1216 | 1216 | function wpinv_checkout_validate_cc_zip( $zip = 0, $country_code = '' ) { |
@@ -1407,7 +1407,7 @@ discard block |
||
1407 | 1407 | $required_fields = wpinv_checkout_required_fields(); |
1408 | 1408 | |
1409 | 1409 | // Loop through required fields and show error messages |
1410 | - if ( !empty( $required_fields ) ) { |
|
1410 | + if ( !empty( $required_fields ) ) { |
|
1411 | 1411 | foreach ( $required_fields as $field_name => $value ) { |
1412 | 1412 | if ( in_array( $value, $required_fields ) && empty( $_POST[ 'wpinv_' . $field_name ] ) ) { |
1413 | 1413 | wpinv_set_error( $value['error_id'], $value['error_message'] ); |
@@ -1507,7 +1507,7 @@ discard block |
||
1507 | 1507 | } |
1508 | 1508 | |
1509 | 1509 | function wpinv_get_checkout_session() { |
1510 | - global $wpi_session; |
|
1510 | + global $wpi_session; |
|
1511 | 1511 | |
1512 | 1512 | return $wpi_session->get( 'wpinv_checkout' ); |
1513 | 1513 | } |
@@ -1859,53 +1859,53 @@ discard block |
||
1859 | 1859 | } |
1860 | 1860 | |
1861 | 1861 | function wpinv_get_invoice_id_by_key( $key ) { |
1862 | - global $wpdb; |
|
1862 | + global $wpdb; |
|
1863 | 1863 | |
1864 | - $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
1864 | + $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
1865 | 1865 | |
1866 | - if ( $invoice_id != NULL ) |
|
1867 | - return $invoice_id; |
|
1866 | + if ( $invoice_id != NULL ) |
|
1867 | + return $invoice_id; |
|
1868 | 1868 | |
1869 | - return 0; |
|
1869 | + return 0; |
|
1870 | 1870 | } |
1871 | 1871 | |
1872 | 1872 | function wpinv_can_view_receipt( $invoice_key = '' ) { |
1873 | - $return = false; |
|
1873 | + $return = false; |
|
1874 | 1874 | |
1875 | - if ( empty( $invoice_key ) ) { |
|
1876 | - return $return; |
|
1877 | - } |
|
1875 | + if ( empty( $invoice_key ) ) { |
|
1876 | + return $return; |
|
1877 | + } |
|
1878 | 1878 | |
1879 | - global $wpinv_receipt_args; |
|
1879 | + global $wpinv_receipt_args; |
|
1880 | 1880 | |
1881 | - $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
1882 | - if ( isset( $_GET['invoice-id'] ) ) { |
|
1883 | - $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0; |
|
1884 | - } |
|
1881 | + $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
1882 | + if ( isset( $_GET['invoice-id'] ) ) { |
|
1883 | + $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0; |
|
1884 | + } |
|
1885 | 1885 | |
1886 | - if ( empty( $wpinv_receipt_args['id'] ) ) { |
|
1887 | - return $return; |
|
1888 | - } |
|
1886 | + if ( empty( $wpinv_receipt_args['id'] ) ) { |
|
1887 | + return $return; |
|
1888 | + } |
|
1889 | 1889 | |
1890 | - $invoice = wpinv_get_invoice( $wpinv_receipt_args['id'] ); |
|
1891 | - if ( !( !empty( $invoice->ID ) && $invoice->get_key() === $invoice_key ) ) { |
|
1892 | - return $return; |
|
1893 | - } |
|
1890 | + $invoice = wpinv_get_invoice( $wpinv_receipt_args['id'] ); |
|
1891 | + if ( !( !empty( $invoice->ID ) && $invoice->get_key() === $invoice_key ) ) { |
|
1892 | + return $return; |
|
1893 | + } |
|
1894 | 1894 | |
1895 | 1895 | if ( is_user_logged_in() ) { |
1896 | - if ( (int)$invoice->get_user_id() === (int) get_current_user_id() ) { |
|
1897 | - $return = true; |
|
1898 | - } |
|
1899 | - } |
|
1900 | - |
|
1901 | - $session = wpinv_get_checkout_session(); |
|
1902 | - if ( isset( $_GET['invoice_key'] ) ) { |
|
1903 | - $return = $_GET['invoice_key'] === $invoice_key; |
|
1904 | - } else if ( $session && isset( $session['invoice_key'] ) ) { |
|
1905 | - $return = $session['invoice_key'] === $invoice_key; |
|
1906 | - } |
|
1907 | - |
|
1908 | - return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key ); |
|
1896 | + if ( (int)$invoice->get_user_id() === (int) get_current_user_id() ) { |
|
1897 | + $return = true; |
|
1898 | + } |
|
1899 | + } |
|
1900 | + |
|
1901 | + $session = wpinv_get_checkout_session(); |
|
1902 | + if ( isset( $_GET['invoice_key'] ) ) { |
|
1903 | + $return = $_GET['invoice_key'] === $invoice_key; |
|
1904 | + } else if ( $session && isset( $session['invoice_key'] ) ) { |
|
1905 | + $return = $session['invoice_key'] === $invoice_key; |
|
1906 | + } |
|
1907 | + |
|
1908 | + return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key ); |
|
1909 | 1909 | } |
1910 | 1910 | |
1911 | 1911 | function wpinv_pay_for_invoice() { |