Skip to content

Commit

Permalink
Merge pull request #31 from farayaz/30-update-sepehrpay-url
Browse files Browse the repository at this point in the history
update Sepehrpay url
  • Loading branch information
mehrdadx10 committed May 14, 2024
2 parents 9396805 + 1bad375 commit 5914cf3
Showing 1 changed file with 12 additions and 22 deletions.
34 changes: 12 additions & 22 deletions src/Gateways/Sepehrpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
namespace Farayaz\Larapay\Gateways;

use Farayaz\Larapay\Exceptions\LarapayException;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\BadResponseException;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Http\Client\RequestException;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\View;

final class Sepehrpay extends GatewayAbstract
{
private $url = 'https://mabna.shaparak.ir:8081/V1/PeymentApi/';
private $url = 'https://sepehr.shaparak.ir:8081/V1/PeymentApi/';

protected $statuses = [
'0' => '0',
'-1' => 'تراکنش پیدا نشد.',
'-2' => 'عدم تطابق ip / تراکنش قبلا Reserve شده است.',
'-3' => 'Exception خطای - عمومی خطای Total Error',
Expand Down Expand Up @@ -51,7 +51,7 @@ public function request(

public function redirect(int $id, string $token, string $callbackUrl)
{
$action = 'https://mabna.shaparak.ir:8080';
$action = 'https://sepehr.shaparak.ir:8080';
$fields = [
'token' => $token,
'terminalID' => $this->config['terminalId'],
Expand Down Expand Up @@ -114,25 +114,15 @@ public function verify(

private function _request(string $url, array $data)
{
$client = new Client;

try {
$response = $client->request(
'POST',
$url,
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
],
'json' => $data,
'timeout' => 10,
]
);

return json_decode($response->getBody(), true);
} catch (BadResponseException $e) {
return Http::timeout(10)
->post($url, $data)
->throw()
->json();
} catch (RequestException $e) {
throw new LarapayException($e->getMessage());
} catch (ConnectionException $e) {
throw new LarapayException($this->translateStatus('connection-exception'));
}
}
}

0 comments on commit 5914cf3

Please sign in to comment.