-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathVerification.php
45 lines (33 loc) · 941 Bytes
/
Verification.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace Pishran\Zarinpal;
use Illuminate\Support\Facades\Http;
class Verification
{
/** @var string */
private $merchantId;
/** @var int */
private $amount;
/** @var string */
private $authority;
public function __construct(string $merchantId, int $amount)
{
$this->merchantId = $merchantId;
$this->amount = $amount;
}
public function send(): VerificationResponse
{
$url = 'https://api.zarinpal.com/pg/v4/payment/verify.json';
$data = [
'merchant_id' => $this->merchantId,
'amount' => $this->amount,
'authority' => $this->authority,
];
$response = Http::asJson()->acceptJson()->post($url, $data);
return new VerificationResponse($response->json());
}
public function authority(string $authority): self
{
$this->authority = $authority;
return $this;
}
}