Skip to content

Commit

Permalink
[fix] check array key exist on response (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
alissn committed Jul 20, 2024
1 parent 1fb4410 commit 60ce9a2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Drivers/Digipay/Digipay.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public function reverse()

$body = json_decode($response->getBody()->getContents(), true);

if ($response->getStatusCode() != 200 || $body['result']['code'] != 0) {
if ($response->getStatusCode() != 200 || (isset($body['result']['code']) && $body['result']['code'] != 0)) {
$message = $body['result']['message'] ?? 'خطا در هنگام درخواست برای برگشت وجه رخ داده است.';
throw new InvalidPaymentException($message, (int) $response->getStatusCode());
}
Expand Down Expand Up @@ -337,7 +337,7 @@ public function deliver()

$body = json_decode($response->getBody()->getContents(), true);

if ($response->getStatusCode() != 200 || $body['result']['code'] != 0) {
if ($response->getStatusCode() != 200 || (isset($body['result']['code']) && $body['result']['code'] != 0)) {
$message = $body['result']['message'] ?? 'خطا در هنگام درخواست برای تحویل کالا رخ داده است.';
throw new InvalidPaymentException($message, (int) $response->getStatusCode());
}
Expand All @@ -361,7 +361,7 @@ public function getRefundConfig()

$body = json_decode($response->getBody()->getContents(), true);

if ($response->getStatusCode() != 200 || $body['result']['code'] != 0) {
if ($response->getStatusCode() != 200 || (isset($body['result']['code']) && $body['result']['code'] != 0)) {
$message = $body['result']['message'] ?? 'خطا در هنگام درخواست برای دریافت تنظیمات مرجوعی رخ داده است.';
throw new InvalidPaymentException($message, (int) $response->getStatusCode());
}
Expand Down Expand Up @@ -413,7 +413,7 @@ public function refundTransaction()

$body = json_decode($response->getBody()->getContents(), true);

if ($response->getStatusCode() != 200 || $body['result']['code'] != 0) {
if ($response->getStatusCode() != 200 || (isset($body['result']['code']) && $body['result']['code'] != 0)) {
$message = $body['result']['message'] ?? 'خطا در هنگام درخواست مرجوعی تراکنش رخ داده است.';
throw new InvalidPaymentException($message, (int) $response->getStatusCode());
}
Expand Down

0 comments on commit 60ce9a2

Please sign in to comment.