Skip to content

Commit

Permalink
Direkt API
Browse files Browse the repository at this point in the history
  • Loading branch information
GizemSever committed Aug 1, 2023
1 parent aea784e commit e89862e
Show file tree
Hide file tree
Showing 7 changed files with 1,060 additions and 0 deletions.
65 changes: 65 additions & 0 deletions src/Direkt/BankIdentification.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
/**
* @author Gizem Sever <[email protected]>
*/

namespace Gizemsever\LaravelPaytr\Direkt;

use Gizemsever\LaravelPaytr\PaytrClient;
use Gizemsever\LaravelPaytr\PaytrResponse;

class BankIdentification extends PaytrClient
{

/**
* @var string|null
*/
private ?string $binNumber;

/**
* @return string|null
*/
public function getBinNumber(): ?string
{
return $this->binNumber;
}

/**
* @param string|null $binNumber
* @return BankIdentification
*/
public function setBinNumber(?string $binNumber): static
{
$this->binNumber = $binNumber;
return $this;
}

/**
* @return string
*/
private function getHash(): string
{
return '' .
$this->getBinNumber() .
$this->credentials['merchant_id'] .
$this->credentials['merchant_salt'];
}

/**
* @return PaytrResponse
*/
public function checkBin(): PaytrResponse
{
$hash = $this->getHash();
$token = $this->generateToken($hash);
$body = [
'merchant_id' => $this->credentials['merchant_id'],
'bin_number' => $this->getBinNumber(),
'paytr_token' => $token,
];
$response = $this->callApi('POST', 'odeme/api/bin-detail', $body);

return new PaytrResponse(json_decode((string)$response->getBody(), true));
}

}
47 changes: 47 additions & 0 deletions src/Direkt/Capi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* @author Gizem Sever <[email protected]>
*/

namespace Gizemsever\LaravelPaytr\Direkt;

use Gizemsever\LaravelPaytr\PaytrClient;
use Gizemsever\LaravelPaytr\PaytrResponse;

class Capi extends PaytrClient
{
private ?string $uToken;

/**
* @return string|null
*/
public function getUToken(): ?string
{
return $this->uToken;
}

/**
* @param string|null $uToken
* @return Capi
*/
public function setUToken(?string $uToken): static
{
$this->uToken = $uToken;
return $this;
}

public function getList()
{
$hash = $this->getUToken() . $this->credentials['merchant_salt'];
$token = $this->generateToken($hash);

$body = [
'merchant_id' => $this->credentials['merchant_id'],
'utoken' => $this->getUToken(),
'paytr_token' => $token,
];
$response = $this->callApi('POST', 'odeme/capi/list', $body);

return new PaytrResponse(json_decode((string)$response->getBody(), true));
}
}
Loading

0 comments on commit e89862e

Please sign in to comment.