Skip to content

Commit

Permalink
new
Browse files Browse the repository at this point in the history
  • Loading branch information
cave committed Sep 28, 2021
1 parent 2cb1285 commit 11c0a25
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 79 deletions.
6 changes: 0 additions & 6 deletions src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,8 @@ public function getDefaultParameters(): array
{
return [
'testMode' => FALSE,
<<<<<<< HEAD
'currency' => 'AED',
'language' => 'en',
=======
>>>>>>> 24428a5b7399bc46a68f08187fb62fe42a45d455
];
}

Expand Down Expand Up @@ -94,7 +91,6 @@ public function refund(array $options = [])
return $this->createRequest(RefundRequest::class, $options);
}

<<<<<<< HEAD
public function setAccessCode($code)
{
return $this->setParameter('access_code', $code);
Expand Down Expand Up @@ -156,8 +152,6 @@ public function setFortId($fort_id)
return $this;
}

=======
>>>>>>> 24428a5b7399bc46a68f08187fb62fe42a45d455
/**
* @param string $requestPhrase
*
Expand Down
23 changes: 1 addition & 22 deletions src/Message/Request/APSAbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,22 @@ public function sendData($data): ResponseInterface
// Sort array by key ascending
ksort($data);

$data['signature'] = $this->_createSignature($data);
echo $data['signature'] = $this->_createSignature($data);

$httpResponse = $this->httpClient->request(
'POST',
$this->getEndpoint(),
[
<<<<<<< HEAD
=======
'Accept' => 'application/json',
>>>>>>> 24428a5b7399bc46a68f08187fb62fe42a45d455
'Content-type' => 'application/json',
],
json_encode($data)
);

<<<<<<< HEAD
if ($httpResponse->getStatusCode() != 200)
{
throw new \Exception($httpResponse->getReasonPhrase(), $httpResponse->getStatusCode());
}

=======
>>>>>>> 24428a5b7399bc46a68f08187fb62fe42a45d455
$json = $httpResponse->getBody()->getContents();

$data = !empty($json) ? json_decode($json, true) : [];
Expand Down Expand Up @@ -77,7 +70,6 @@ protected function getEndpoint(): string
*/
private function _createSignature(array $data): string
{
<<<<<<< HEAD
unset($data['testMode']);
unset($data['Mode']);

Expand All @@ -91,22 +83,12 @@ private function _createSignature(array $data): string
{
if (empty($value)) continue;

=======
$shaType = $this->hasParameter('sha_type') ? $this->hasParameter('sha_type') : self::DEFAULT_SHA_TYPE;

if ( ! $this->hasParameter('request_phrase'))
throw new RequestPhraseException('Request phrase is missing.');

foreach ($data as $key => $value)
{
>>>>>>> 24428a5b7399bc46a68f08187fb62fe42a45d455
$shaString .= "$key=$value";
}

// "Glue" phrase to the both sides of the payload
$shaString = $this->getParameter('request_phrase') . $shaString . $this->getParameter('request_phrase');

<<<<<<< HEAD
return hash_hmac($shaType, $shaString, $this->getParameter('request_phrase'));
}

Expand Down Expand Up @@ -178,8 +160,5 @@ public function setFortId($fort_id)
protected function _is_json_response($string) {
json_decode($string);
return json_last_error() === JSON_ERROR_NONE;
=======
return hash($shaType, $shaString);
>>>>>>> 24428a5b7399bc46a68f08187fb62fe42a45d455
}
}
12 changes: 1 addition & 11 deletions src/Message/Request/AbstractCheckoutRequest.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
<?php namespace Omnipay\APS\Message\Request;

abstract class AbstractCheckoutRequest extends APSAbstractRequest
abstract class AbstractCheckoutRequest extends APSAgit stbstractRequest
{
<<<<<<< HEAD
protected $test_endpoint = 'https://sbcheckout.payfort.com/FortAPI/paymentPage';

protected $live_endpoint = 'https://checkout.payfort.com/FortAPI/paymentPage';

public function validateData()
{
$this->validate('access_code', 'merchant_identifier', 'merchant_reference', 'amount', 'currency', 'language', 'customer_email');
=======
private $test_endpoint = 'https://sbcheckout.payfort.com/FortAPI/paymentPage';

private $live_endpoint = 'https://checkout.payfort.com/FortAPI/paymentPage';

public function validateData()
{
$this->validate('access_code', 'merchant_identifier', 'merchant_reference', 'amount', 'currency', 'language', 'customer_email', 'signature');
>>>>>>> 24428a5b7399bc46a68f08187fb62fe42a45d455
}
}
4 changes: 0 additions & 4 deletions src/Message/Request/AuthorizationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public function getData(): array
$this->validateData();

return [
<<<<<<< HEAD
'command' => self::COMMAND,
'testMode' => $this->getParameter('testMode'),
'access_code' => $this->getParameter('access_code'),
Expand All @@ -25,9 +24,6 @@ public function getData(): array
'language' => $this->getParameter('language'),
'customer_email' => $this->getParameter('customer_email'),
'order_description' => $this->getParameter('order_description'),
=======
'command' => self::COMMAND,
>>>>>>> 24428a5b7399bc46a68f08187fb62fe42a45d455
];
}

Expand Down
13 changes: 0 additions & 13 deletions src/Message/Request/CaptureRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,16 @@ class CaptureRequest extends APSAbstractRequest
{
const COMMAND = 'CAPTURE';

<<<<<<< HEAD
protected $test_endpoint = 'https://sbpaymentservices.payfort.com/FortAPI/paymentApi';

protected $live_endpoint = 'https://paymentservices.payfort.com/FortAPI/paymentApi';
=======
private $test_endpoint = 'https://sbpaymentservices.payfort.com/FortAPI/paymentApi';

private $live_endpoint = 'https://paymentservices.payfort.com/FortAPI/paymentApi';
>>>>>>> 24428a5b7399bc46a68f08187fb62fe42a45d455

/**
* @return mixed
* @throws InvalidRequestException
*/
public function getData(): array
{
<<<<<<< HEAD
$this->validate('access_code', 'merchant_identifier', 'merchant_reference', 'amount', 'currency', 'language');

return [
Expand All @@ -37,12 +30,6 @@ public function getData(): array
'language' => $this->getParameter('language'),
'order_description' => $this->getParameter('order_description'),
'fort_id' => $this->getParameter('fort_id'),
=======
$this->validate('access_code', 'merchant_identifier', 'merchant_reference', 'amount', 'currency', 'language', 'signature');

return [
'command' => self::COMMAND,
>>>>>>> 24428a5b7399bc46a68f08187fb62fe42a45d455
];
}

Expand Down
10 changes: 0 additions & 10 deletions src/Message/Request/PurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public function getData(): array

return [
'command' => self::COMMAND,
<<<<<<< HEAD
'testMode' => $this->getParameter('testMode'),
'access_code' => $this->getParameter('access_code'),
'merchant_identifier' => $this->getParameter('merchant_identifier'),
Expand All @@ -25,26 +24,17 @@ public function getData(): array
'language' => $this->getParameter('language'),
'customer_email' => $this->getParameter('customer_email'),
'order_description' => $this->getParameter('order_description'),
=======
>>>>>>> 24428a5b7399bc46a68f08187fb62fe42a45d455
];
}

/**
* @param array $data
<<<<<<< HEAD
=======
*
>>>>>>> 24428a5b7399bc46a68f08187fb62fe42a45d455
* @return PurchaseResponse
* @throws \Omnipay\Common\Exception\InvalidResponseException
*/
protected function createResponse(array $data): PurchaseResponse
{
return new PurchaseResponse($this, $data);
}
<<<<<<< HEAD

=======
>>>>>>> 24428a5b7399bc46a68f08187fb62fe42a45d455
}
13 changes: 0 additions & 13 deletions src/Message/Request/RefundRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,9 @@ class RefundRequest extends APSAbstractRequest
{
const COMMAND = 'REFUND';

<<<<<<< HEAD
protected $test_endpoint = 'https://sbpaymentservices.payfort.com/FortAPI/paymentApi';

protected $live_endpoint = 'https://paymentservices.payfort.com/FortAPI/paymentApi';
=======
private $test_endpoint = 'https://sbpaymentservices.payfort.com/FortAPI/paymentApi';

private $live_endpoint = 'https://paymentservices.payfort.com/FortAPI/paymentApi';
>>>>>>> 24428a5b7399bc46a68f08187fb62fe42a45d455

/**
* @return mixed
Expand All @@ -24,7 +18,6 @@ class RefundRequest extends APSAbstractRequest
*/
public function getData(): array
{
<<<<<<< HEAD
$this->validate('access_code', 'merchant_identifier', 'merchant_reference', 'amount', 'currency', 'language');

return [
Expand All @@ -38,12 +31,6 @@ public function getData(): array
'language' => $this->getParameter('language'),
'order_description' => $this->getParameter('order_description'),
'fort_id' => $this->getParameter('fort_id'),
=======
$this->validate('access_code', 'merchant_identifier', 'merchant_reference', 'amount', 'currency', 'language', 'signature');

return [
'command' => self::COMMAND,
>>>>>>> 24428a5b7399bc46a68f08187fb62fe42a45d455
];
}

Expand Down

0 comments on commit 11c0a25

Please sign in to comment.