/
inquire-by-reference-numbers.php
82 lines (76 loc) · 2.56 KB
/
inquire-by-reference-numbers.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
// You got this when you uploaded your public key to moadian
$username = 'A1B2C3';
// See the get-tax-org-public-key.php example
$taxOrgPublicKey = file_get_contents('moadian-public.key');
// See the get-tax-org-public-key.php example
$taxOrgKeyId = 'XXXX-XXXX-XXXX-XXXX';
// This is your private key, you have previously uploaded its corresponding public key to moadian
$privateKey = file_get_contents('private.key');
// Base URL for moadian API. For production, it is the default value for baseUrl parameter in Moadian class constructor
$baseUrl = 'https://sandboxrc.tax.gov.ir/';
$moadian = new \Baradaran\Moadian\Moadian(
$taxOrgPublicKey,
$privateKey,
$taxOrgKeyId,
$username,
$baseUrl
);
// Login first
$token = $moadian->login();
// Save the token for your future requests so that you don't have to login for every inquiry
// Make sure you use the getExpiresAt to get a new token when your old token expires.
$moadian->setToken($token);
$referenceNumbers = ["c1b111c1-b11e-11ad-111e-cbb1c1111111", "c2b222c2-b22e-22ad-222e-cbb2c2222222"];
$response = $moadian->inquireByReferenceNumbers($referenceNumbers);
/*
Response will look like this:
{
"signature": null,
"signatureKeyId": null,
"timestamp": 1111111111111,
"result": {
"uid": null,
"packetType": "INQUIRY_RESULT",
"data": [
{
"referenceNumber": "c1b111c1-b11e-11ad-111e-cbb1c1111111",
"uid": "XXXX",
"status": "FAILED",
"data": {
"error": [
{
"code": "0301",
"message": "XXXX"
}
],
"warning": [
{
"code": "1403",
"message": "XXXX"
}
],
"success": false
},
"packetType": "receive_invoice_confirm",
"fiscalId": "A1B2C3"
},
{
"referenceNumber": "c2b222c2-b22e-22ad-222e-cbb2c2222222",
"uid": "XXXX",
"status": "SUCCESS",
"data": {
"error": [],
"warning": [],
"success": true
},
"packetType": "receive_invoice_confirm",
"fiscalId": "A1B2C3"
}
],
"encryptionKeyId": null,
"symmetricKey": null,
"iv": null
}
}
*/