Skip to content

Commit ef46004

Browse files
author
Aboozar Ghaffari
authored
Merge pull request #13 from miladkian/new-version
hot-fix json decode
2 parents a6f6150 + 8688b48 commit ef46004

File tree

10 files changed

+500
-305
lines changed

10 files changed

+500
-305
lines changed

src/Adapter/AdapterInterface.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ public function setParameters(array $parameters = []): AdapterInterface;
1515
*/
1616
public function form(): string;
1717

18+
/**
19+
* @return array
20+
*/
21+
public function formParams(): array;
22+
1823
/**
1924
* @return bool
2025
*/

src/Adapter/Mellat.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,20 @@ protected function generateForm()
9696
]);
9797
}
9898

99+
/**
100+
* @return array
101+
* @throws Exception
102+
*/
103+
public function formParams(): array
104+
{
105+
$refId = $this->requestToken();
106+
107+
return [
108+
'endPoint' => $this->getEndPoint(),
109+
'refId' => $refId,
110+
];
111+
}
112+
99113
/**
100114
* @return bool
101115
* @throws Exception

src/Adapter/Parsian.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,21 @@ protected function generateForm(): string
107107
]);
108108
}
109109

110+
/**
111+
* @return array
112+
* @throws Exception
113+
* @throws \Tartan\Larapay\Adapter\Exception
114+
*/
115+
public function fromParams(): array
116+
{
117+
$authority = $this->requestToken();
118+
119+
return [
120+
'endPoint' => $this->getEndPoint(),
121+
'refId' => $authority,
122+
];
123+
}
124+
110125
/**
111126
* @return bool
112127
* @throws Exception

src/Adapter/Pasargad.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,49 @@ protected function generateForm(): string
6767
));
6868
}
6969

70+
/**
71+
* @return array
72+
* @throws Exception
73+
*/
74+
public function formParams(): array
75+
{
76+
$this->checkRequiredParameters([
77+
'amount',
78+
'order_id',
79+
'redirect_url'
80+
]);
81+
82+
$processor = new RSAProcessor(config('larapay.pasargad.certificate_path'), RSAKeyType::XMLFile);
83+
84+
$url = $this->getEndPoint();
85+
$redirectUrl = $this->redirect_url;
86+
$invoiceNumber = $this->order_id;
87+
$amount = $this->amount;
88+
$terminalCode = config('larapay.pasargad.terminalId');
89+
$merchantCode = config('larapay.pasargad.merchantId');
90+
$timeStamp = date("Y/m/d H:i:s");
91+
$invoiceDate = date("Y/m/d H:i:s");
92+
$action = 1003; // sell code
93+
94+
$data = "#" . $merchantCode . "#" . $terminalCode . "#" . $invoiceNumber . "#" . $invoiceDate . "#" . $amount . "#" . $redirectUrl . "#" . $action . "#" . $timeStamp . "#";
95+
$data = sha1($data, true);
96+
$data = $processor->sign($data); // امضاي ديجيتال
97+
$sign = base64_encode($data); // base64_encode
98+
99+
return [
100+
'url' => $url,
101+
'redirectUrl' => $redirectUrl,
102+
'invoiceNumber' => $invoiceNumber,
103+
'invoiceDate' => $invoiceDate,
104+
'amount' => $amount,
105+
'terminalCode' => $terminalCode,
106+
'merchantCode' => $merchantCode,
107+
'timeStamp' => $timeStamp,
108+
'action' => $action,
109+
'sign' => $sign,
110+
];
111+
}
112+
70113
// public function inquiryTransaction ()
71114
// {
72115
//

src/Adapter/Payir.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,20 @@ protected function generateForm(): string
8989
]);
9090
}
9191

92+
/**
93+
* @return array
94+
* @throws Exception
95+
* @throws \Tartan\Larapay\Adapter\Exception
96+
*/
97+
public function formParams(): array
98+
{
99+
$authority = $this->requestToken();
100+
101+
return [
102+
'endPoint' => $this->endPointForm . $authority,
103+
];
104+
}
105+
92106
/**
93107
* @return bool
94108
* @throws Exception

0 commit comments

Comments
 (0)