Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix return value #3

Merged
merged 3 commits into from
Apr 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function purchase(array $parameters = [])
* @param array $parameters
* @return CompletePurchaseRequest|\Omnipay\Common\Message\AbstractRequest
*/
public function getPurchaseStatus(array $parameters = [])
public function completePurchase(array $parameters = [])
{
return $this->createRequest(CompletePurchaseRequest::class, $parameters);
}
Expand Down
45 changes: 43 additions & 2 deletions src/Message/CompletePurchaseResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function isRedirect()
* Get order status
* @return string
*/
public function getOrderStatus()
public function getTransactionStatus()
{
return $this->data['status'];
}
Expand All @@ -49,6 +49,47 @@ public function getOrderStatus()
*/
public function isPaid()
{
return $this->getOrderStatus() === 'paid';
return $this->getTransactionStatus() === 'paid';
}

/**
* {@inheritdoc}
* @return string
*/
public function getAmount()
{
return $this->data['price_amount'] ?? null;
}

/**
* Get payment time.
*
* @return string
*/
public function getTime()
{
$time = new \DateTime($this->data['created_at'], new \DateTimeZone('UTC'));

return $time->format('c');
}

/**
* Get payment currency.
*
* @return string
*/
public function getCurrency()
{
return $this->data['price_currency'];
}

/**
* Get payer info - name, username and id.
*
* @return string
*/
public function getPayer()
{
return $this->data['order_id'];
}
}
3 changes: 2 additions & 1 deletion src/Message/PurchaseResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ public function getMessage()
}

/**
* {@inheritdoc}
* @return string
*/
public function getTransactionReference()
{
if (isset($this->data['id'])) {
return $this->data['id'];
return (string) $this->data['id'];
}
}
}