Skip to content

Commit

Permalink
Refactor ThreedsPayment::retrieve method to use getHttpHeadersV2 for …
Browse files Browse the repository at this point in the history
…API request
  • Loading branch information
tarikkamat authored and erdemdmr committed Sep 17, 2024
1 parent d6438c7 commit 8499966
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
19 changes: 2 additions & 17 deletions src/Iyzipay/IyzipayResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,6 @@ class IyzipayResource extends ApiResource
private $systemTime;
private $conversationId;

protected static function getHttpHeaders(Request $request, Options $options)
{
$header = array(
"Accept: application/json",
"Content-type: application/json",
);

$rnd = uniqid();
array_push($header, "Authorization: " . self::prepareAuthorizationString($request, $options, $rnd));
array_push($header, "x-iyzi-rnd: " . $rnd);
array_push($header, "x-iyzi-client-version: " . "iyzipay-php-2.0.55");

return $header;
}

protected static function getHttpHeadersV2($uri, Request $request = null, Options $options, bool $addRandom = false)
{
$header = array(
Expand All @@ -38,7 +23,7 @@ protected static function getHttpHeadersV2($uri, Request $request = null, Option
array_push($header, "Authorization: " . self::prepareAuthorizationStringV2($uri, $request, $options, $rnd));
$addRandom && array_push($header, "x-iyzi-rnd: " . $rnd);
array_push($header, "AUTHORIZATION_FALLBACK_HEADER: " . self::prepareAuthorizationString($request, $options, $rnd));
array_push($header, "x-iyzi-client-version: " . "iyzipay-php-2.0.43");
array_push($header, "x-iyzi-client-version: " . "iyzipay-php-2.0.55");

return $header;
}
Expand All @@ -53,7 +38,7 @@ protected static function getHttpHeadersIsV2($uri, Request $request = null, Opti
$rnd = uniqid();
array_push($header, "Authorization: " . self::prepareAuthorizationStringV2($uri, $request, $options, $rnd));
$addRandom && array_push($header, "x-iyzi-rnd: " . $rnd);
array_push($header, "x-iyzi-client-version: " . "iyzipay-php-2.0.43");
array_push($header, "x-iyzi-client-version: " . "iyzipay-php-2.0.55");

return $header;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Iyzipay/Model/ThreedsPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public static function create(CreateThreedsPaymentRequest $request, Options $opt

public static function retrieve(RetrievePaymentRequest $request, Options $options)
{
$rawResult = parent::httpClient()->post($options->getBaseUrl() . "/payment/detail", parent::getHttpHeaders($request, $options), $request->toJsonString());
$uri = "/payment/detail";
$rawResult = parent::httpClient()->post($options->getBaseUrl() . $uri, parent::getHttpHeadersV2($uri, $request, $options), $request->toJsonString());
return ThreedsPaymentMapper::create($rawResult)->jsonDecode()->mapThreedsPayment(new ThreedsPayment());
}

Expand Down

0 comments on commit 8499966

Please sign in to comment.