Skip to content

Commit

Permalink
Merge pull request #5 from andchir/master
Browse files Browse the repository at this point in the history
WIP: Receipt parameter (not required). Add OutSumCurrency parameter, rename currency label parameter
  • Loading branch information
SilverFire authored May 13, 2019
2 parents 57a52d2 + 6c37eb5 commit dc60f95
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 4 deletions.
46 changes: 46 additions & 0 deletions src/Message/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,52 @@ public function setClient($value)
return $this->setParameter('client', $value);
}

/**
* @return string
*/
public function getReceipt()
{
return rawurlencode($this->getParameter('receipt'));
}

/**
* @param $value
* @return \Omnipay\Common\Message\AbstractRequest
*/
public function setReceipt($value)
{
return $this->setParameter('receipt', $value);
}

public function getCurrency()
{
$currency = $this->getParameter('currency');
if ($currency === 'RUB') {
return '';
}

return $currency;
}

/**
* Get the payment currency label.
*
* @return string
*/
public function getCurrencyLabel()
{
return $this->getParameter('currencyLabel');
}

/**
* @param string $value
* @return AbstractRequest
*/
public function setCurrencyLabel($value)
{
return $this->setParameter('currencyLabel', $value);
}

/**
* Get the secret key.
*
Expand Down
16 changes: 12 additions & 4 deletions src/Message/PurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ public function getData()
'MrchLogin' => $this->getPurse(),
'OutSum' => $this->getAmount(),
'Desc' => $this->getDescription(),
'IncCurrLabel' => $this->getCurrency(),
'IncCurrLabel' => $this->getCurrencyLabel(),
'OutSumCurrency' => $this->getCurrency(),
'SignatureValue' => $this->generateSignature(),
'IsTest' => (int)$this->getTestMode(),
'IsTest' => (int) $this->getTestMode(),
'Receipt' => $this->getReceipt(),
] + $this->getCustomFields();
}

Expand All @@ -34,9 +36,15 @@ public function generateSignature()
$params = [
$this->getPurse(),
$this->getAmount(),
$this->getInvId(),
$this->getSecretKey()
$this->getInvId()
];
if ($this->getCurrency()) {
$params[] = $this->getCurrency();
}
if ($this->getReceipt()) {
$params[] = $this->getReceipt();
}
$params[] = $this->getSecretKey();

foreach ($this->getCustomFields() as $field => $value) {
$params[] = "$field=$value";
Expand Down

0 comments on commit dc60f95

Please sign in to comment.