Skip to content

Commit

Permalink
Fix URL
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeholder committed Jun 16, 2020
1 parent b25ea55 commit f5507dd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/Message/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

namespace Omnipay\Paystack\Message;

use Omnipay\Common\Exception\BadMethodCallException;
use Omnipay\Common\Exception\InvalidRequestException;

abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest
{
protected $baseApiEndpoint = 'https://api.paystack.co/';
protected $baseApiEndpoint = 'https://api.paystack.co';

/**
* @return string The URL endpoint for the request
Expand Down
7 changes: 3 additions & 4 deletions src/Message/CompletePurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CompletePurchaseRequest extends AbstractRequest
*/
public function getApiEndpoint()
{
return $this->baseApiEndpoint . 'transaction/verify/' . rawurlencode($this->getTransactionReference());
return '/transaction/verify/' . rawurlencode($this->getTransactionReference());
}

/**
Expand All @@ -28,12 +28,11 @@ public function getData()
public function sendData($data)
{
try {
$response = $this->sendRequest('GET', $this->getApiEndpoint(), json_encode($data));
$response = $this->sendRequest('GET', $this->getApiEndpoint(), $data);
} catch (\Exception $e) {

throw new InvalidRequestException($e->getMessage(), $e->getCode(), $e);
}

return $this->response = new CompletePurchaseResponse($this, $responseData);
return $this->response = new CompletePurchaseResponse($this, $response);
}
}
4 changes: 3 additions & 1 deletion src/Message/PurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class PurchaseRequest extends AbstractRequest
*/
public function getApiEndpoint()
{
return $this->baseApiEndpoint . '/transaction/initialize/';
return '/transaction/initialize';
}

/**
Expand All @@ -26,7 +26,9 @@ public function getData()

return [
'amount' => $amount,
'currency' => $this->getCurrency(),
'email' => $email,
'reference' => $this->getTransactionReference(),
'callback_url' => $this->getReturnUrl(),
'metadata' => $this->getParameter('metadata')
];
Expand Down
13 changes: 6 additions & 7 deletions src/Message/RefundRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,20 @@ class RefundRequest extends AbstractRequest
*/
public function getApiEndpoint()
{
return $this->baseApiEndpoint . '/refund';
return '/refund';
}

/**
* @inheritdoc
*/
public function getData()
{
$amount = $this->getAmountInteger();
$reference = $this->getTransactionReference();
$data = [];
$data['transaction'] = $this->getTransactionReference();
$data['currency'] = $this->getCurrency();

$data = ['transaction' => $reference];

if ($amount) {
$data['amount'] = $amount;
if ($this->getAmountInteger()) {
$data['amount'] = $this->getAmountInteger();
}

return $data;
Expand Down

0 comments on commit f5507dd

Please sign in to comment.