クラス
Logger
Methods for adding and retrieving logs
ソース ソース
ファイル: src/Models/Logger.php
class Logger { /** * 決済履歴ログ登録 * * Inserts record containing meta data of an Amazon Pay API response * * @author Evan D Shaw <evandanielshaw@gmail.com> * @global \wpdb $wpdb * @param Log $log * @return int|bool Number of rows affected/selected. Boolean false on error. */ public function logApiResponse(Log $log) { global $wpdb; $log_table_name = $wpdb->prefix . 'usces_log'; $query = $wpdb->prepare( "INSERT INTO {$log_table_name} (`datetime`, `log`, `log_type`, `log_key`) VALUES (%s, %s, %s, %s)", $log->getTimestamp(), json_encode($log), Log::LOG_TYPE, $log->getChargePermissionId() ); $res = $wpdb->query($query); return $res; } /** * 決済履歴ログ取得 * * @author Evan D Shaw <evandanielshaw@gmail.com> * @global \wpdb $wpdb * @param string $log_key '[chargeId]' * @return array */ public function getSettlementHistoryLog($log_key) { global $wpdb; $log_table_name = $wpdb->prefix . 'usces_log'; $query = $wpdb->prepare( "SELECT * FROM {$log_table_name} WHERE `log_type` = %s AND `log_key` = %s ORDER BY datetime DESC", Log::LOG_TYPE, $log_key ); $log_data = $wpdb->get_results($query, ARRAY_A); $decodedLog = []; foreach ($log_data as $entry) { $entry['log'] = json_decode($entry['log'], true); $entry['log']['actionTypeText'] = Log::getActionTypeText($entry['log']['actionType']); $decodedLog[] = $entry; } return $decodedLog; } }
- getSettlementHistoryLog — 決済履歴ログ取得
- logApiResponse — 決済履歴ログ登録