Skip to content

Commit

Permalink
APIv1 support implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Dec 18, 2015
1 parent b2fc919 commit 8dc2fcc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 37 deletions.
5 changes: 1 addition & 4 deletions src/Message/CompletePurchaseResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ public function __construct(RequestInterface $request, $data)
{
parent::__construct($request, $data);

$sign = $this->getSign();
$calc = $this->request->calculateSign($this->data);

if ($this->getSign() !== $this->request->calculateSign($this->data)) {
throw new InvalidResponseException('Failed to validate sign');
}
Expand Down Expand Up @@ -120,7 +117,7 @@ public function getCurrency()
*/
public function getTime()
{
return $this->data['ik_inv_prc'];
return strtotime($this->data['ik_inv_prc'] . ' Europe/Moscow');
}

/**
Expand Down
40 changes: 7 additions & 33 deletions src/Message/OldCompletePurchaseResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,40 +22,14 @@
*/
class OldCompletePurchaseResponse extends CompletePurchaseResponse
{
/**
* {@inheritdoc}
*/
public function __construct(RequestInterface $request, $data)
{
parent::__construct($request, $data);

if ($this->getSign() !== $this->request->calculateSign($this->data)) {
throw new InvalidResponseException('Failed to validate sign');
}

if ($this->getState() !== 'success') {
throw new InvalidResponseException('Failed to validate sign');
}
}

/**
* Whether the payment is successful
*
* @return boolean
*/
public function isSuccessful()
{
return $this->getState() === 'success';
}

/**
* The checkout ID
*
* @return string
*/
public function getCheckoutId()
{
return $this->data['ik_co_id'];
return $this->data['ik_shop_id'];
}

/**
Expand All @@ -73,15 +47,15 @@ public function getSign()
*/
public function getTransactionId()
{
return $this->data['ik_inv_id'];
return $this->data['ik_trans_id'];
}

/**
* {@inheritdoc}
*/
public function getTransactionReference()
{
return $this->data['ik_trn_id'];
return $this->data['ik_payment_id'];
}

/**
Expand All @@ -91,17 +65,17 @@ public function getTransactionReference()
*/
public function getAmount()
{
return $this->data['ik_am'];
return $this->data['ik_payment_amount'];
}

/**
* The currency of the payment
*
* @return string
* @return null currency is set
*/
public function getCurrency()
{
return strtoupper($this->data['ik_cur']);
return null;
}

/**
Expand All @@ -111,7 +85,7 @@ public function getCurrency()
*/
public function getTime()
{
return $this->data['ik_inv_prc'];
return strtotime($this->data['ik_payment_timestamp'] . ' Europe/Moscow');
}

/**
Expand Down

0 comments on commit 8dc2fcc

Please sign in to comment.