data = $data; } public function isSuccess() { return $this->data['return_code'] == 'SUCCESS'; } public function get($key) { return $this->data[$key] ?? null; } public function toArray() { $data = []; if ($this->isSuccess()) { $data['is_success'] = true; $data['pay_url'] = $this->get('casherUrl'); } else { $data['error_code'] = $this->get('returnCode'); $data['error_msg'] = $this->get('returnMsg'); } return $data; } }