Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/Services/KnetResponseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,23 @@ public function updateTransaction(KnetTransaction $transaction): KnetTransaction
*/
public static function decryptAndParse(Request $request): array
{
$trandata = $request->getContent();
// 1. Get the full request content
$content = $request->getContent();

// 2. Parse the content into an array
parse_str($content, $output);

// 3. Extract only the trandata field
$trandata = $output['trandata'] ?? null;

if (! $trandata) {
throw new AccessDeniedHttpException('Invalid Request');
}

// 4. Decrypt only the trandata field
$payload = KPayClient::decryptAES($trandata, config('knet.resource_key'));

// 5. Parse the decrypted result
parse_str($payload, $payloadArray);

if (! isset($payloadArray['trackid'])) {
Expand Down