get_transaction_id() ) { $data = $this->set( $data, 'transaction_reference', $this->mapped_payment_id( $order->get_id() ) ); } $settings = get_option( 'woocommerce_dodo_payments_settings', array() ); if ( is_array( $settings ) && isset( $settings['testmode'] ) ) { $data = $this->extra( $data, __( 'Gateway mode now (not stored per order)', 'acrislip-order-receipts' ), 'yes' === $settings['testmode'] ? 'test' : 'live' ); } return $data; } /** * Payment id from the plugin's mapping table, if present. * * @param int $order_id Order id. * @return string */ private function mapped_payment_id( $order_id ) { global $wpdb; $table = $wpdb->prefix . 'dodo_payments_payment_mapping'; // phpcs:ignore WordPress.DB.DirectDatabaseQuery if ( $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $table ) ) ) !== $table ) { return ''; } $table = esc_sql( $table ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter return (string) $wpdb->get_var( $wpdb->prepare( "SELECT dodo_payment_id FROM {$table} WHERE order_id = %d", $order_id ) ); } }