Skip to content

Commit

Permalink
Merge pull request #13 from miladkian/new-version
Browse files Browse the repository at this point in the history
hot-fix json decode
  • Loading branch information
Aboozar Ghaffari authored Dec 29, 2019
2 parents a6f6150 + 8688b48 commit ef46004
Show file tree
Hide file tree
Showing 10 changed files with 500 additions and 305 deletions.
5 changes: 5 additions & 0 deletions src/Adapter/AdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ public function setParameters(array $parameters = []): AdapterInterface;
*/
public function form(): string;

/**
* @return array
*/
public function formParams(): array;

/**
* @return bool
*/
Expand Down
14 changes: 14 additions & 0 deletions src/Adapter/Mellat.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,20 @@ protected function generateForm()
]);
}

/**
* @return array
* @throws Exception
*/
public function formParams(): array
{
$refId = $this->requestToken();

return [
'endPoint' => $this->getEndPoint(),
'refId' => $refId,
];
}

/**
* @return bool
* @throws Exception
Expand Down
15 changes: 15 additions & 0 deletions src/Adapter/Parsian.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,21 @@ protected function generateForm(): string
]);
}

/**
* @return array
* @throws Exception
* @throws \Tartan\Larapay\Adapter\Exception
*/
public function fromParams(): array
{
$authority = $this->requestToken();

return [
'endPoint' => $this->getEndPoint(),
'refId' => $authority,
];
}

/**
* @return bool
* @throws Exception
Expand Down
43 changes: 43 additions & 0 deletions src/Adapter/Pasargad.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,49 @@ protected function generateForm(): string
));
}

/**
* @return array
* @throws Exception
*/
public function formParams(): array
{
$this->checkRequiredParameters([
'amount',
'order_id',
'redirect_url'
]);

$processor = new RSAProcessor(config('larapay.pasargad.certificate_path'), RSAKeyType::XMLFile);

$url = $this->getEndPoint();
$redirectUrl = $this->redirect_url;
$invoiceNumber = $this->order_id;
$amount = $this->amount;
$terminalCode = config('larapay.pasargad.terminalId');
$merchantCode = config('larapay.pasargad.merchantId');
$timeStamp = date("Y/m/d H:i:s");
$invoiceDate = date("Y/m/d H:i:s");
$action = 1003; // sell code

$data = "#" . $merchantCode . "#" . $terminalCode . "#" . $invoiceNumber . "#" . $invoiceDate . "#" . $amount . "#" . $redirectUrl . "#" . $action . "#" . $timeStamp . "#";
$data = sha1($data, true);
$data = $processor->sign($data); // امضاي ديجيتال
$sign = base64_encode($data); // base64_encode

return [
'url' => $url,
'redirectUrl' => $redirectUrl,
'invoiceNumber' => $invoiceNumber,
'invoiceDate' => $invoiceDate,
'amount' => $amount,
'terminalCode' => $terminalCode,
'merchantCode' => $merchantCode,
'timeStamp' => $timeStamp,
'action' => $action,
'sign' => $sign,
];
}

// public function inquiryTransaction ()
// {
//
Expand Down
14 changes: 14 additions & 0 deletions src/Adapter/Payir.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@ protected function generateForm(): string
]);
}

/**
* @return array
* @throws Exception
* @throws \Tartan\Larapay\Adapter\Exception
*/
public function formParams(): array
{
$authority = $this->requestToken();

return [
'endPoint' => $this->endPointForm . $authority,
];
}

/**
* @return bool
* @throws Exception
Expand Down
Loading

0 comments on commit ef46004

Please sign in to comment.