Skip to content

Commit

Permalink
Merged in corrections (pull request #4)
Browse files Browse the repository at this point in the history
Corrections
  • Loading branch information
Anders Jenbo authored and Bushra committed Sep 29, 2020
2 parents 7feda0b + c443932 commit 739f9d0
Show file tree
Hide file tree
Showing 33 changed files with 147 additions and 95 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
"symfony/options-resolver": "^2.6 || ^3.0 || ^4.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8 || ^5.3",
"friendsofphp/php-cs-fixer": "^2.0",
"fzaninotto/faker": "^1.6"
"fzaninotto/faker": "^1.6",
"phpstan/phpstan": "^0.12.44",
"phpunit/phpunit": "^4.8 || ^5.3"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 4 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
paths:
- ./src
level: 2
14 changes: 11 additions & 3 deletions src/AbstractApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ protected function validateResponse($response)
}
}

if (property_exists($response, 'CardHolderMessageMustBeShown')) {
if (property_exists($response, 'CardHolderErrorMessage') && property_exists($response, 'CardHolderMessageMustBeShown')) {
if ($response->CardHolderMessageMustBeShown) {
throw new Exceptions\ResponseMessageException($response->CardHolderErrorMessage);
}
Expand Down Expand Up @@ -302,7 +302,7 @@ protected function parseUrl()
/**
* Build url
*
* @param array $options
* @param array<string, string> $options
*
* @return bool|string
*/
Expand All @@ -328,7 +328,7 @@ protected function authRequired()
/**
* Set the headers to the API call
*
* @return array
* @return array<string, string>
*/
protected function getBasicHeaders()
{
Expand Down Expand Up @@ -358,6 +358,7 @@ protected function getClient()
* Resolve transaction
*
* @param OptionsResolver $resolver
* @return void
*/
protected function setTransactionResolver(OptionsResolver $resolver)
{
Expand All @@ -367,6 +368,7 @@ protected function setTransactionResolver(OptionsResolver $resolver)
* Resolve orderlines
*
* @param OptionsResolver $resolver
* @return void
*/
protected function setOrderLinesResolver(OptionsResolver $resolver)
{
Expand All @@ -376,6 +378,7 @@ protected function setOrderLinesResolver(OptionsResolver $resolver)
* Resolve amount option
*
* @param OptionsResolver $resolver
* @return void
*/
protected function setAmountResolver(OptionsResolver $resolver)
{
Expand All @@ -385,6 +388,7 @@ protected function setAmountResolver(OptionsResolver $resolver)
* Resolve terminal option
*
* @param OptionsResolver $resolver
* @return void
*/
protected function setTerminalResolver(OptionsResolver $resolver)
{
Expand All @@ -394,6 +398,7 @@ protected function setTerminalResolver(OptionsResolver $resolver)
* Resolve currency option
*
* @param OptionsResolver $resolver
* @return void
*/
protected function setCurrencyResolver(OptionsResolver $resolver)
{
Expand All @@ -403,6 +408,7 @@ protected function setCurrencyResolver(OptionsResolver $resolver)
* Resolve shop order id
*
* @param OptionsResolver $resolver
* @return void
*/
protected function setShopOrderIdResolver(OptionsResolver $resolver)
{
Expand All @@ -412,6 +418,7 @@ protected function setShopOrderIdResolver(OptionsResolver $resolver)
* Resolve transaction info option
*
* @param OptionsResolver $resolver
* @return void
*/
protected function setTransactionInfoResolver(OptionsResolver $resolver)
{
Expand All @@ -421,6 +428,7 @@ protected function setTransactionInfoResolver(OptionsResolver $resolver)
* Resolve amount option
*
* @param OptionsResolver $resolver
* @return void
*/
protected function setCustomerInfoResolver(OptionsResolver $resolver)
{
Expand Down
3 changes: 2 additions & 1 deletion src/Api/Ecommerce/Callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@
*/
class Callback
{
/** @var array<string, string> */
private $postedData;

/**
* Callback constructor.
*
* @param $postedData
* @param array<string, string> $postedData
*/
public function __construct($postedData)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Api/Ecommerce/PaymentRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
namespace Altapay\Api\Ecommerce;

use Altapay\AbstractApi;
use Altapay\Exceptions;
use Altapay\Request\Config;
use Altapay\Response\PaymentRequestResponse;
use Altapay\Serializer\ResponseSerializer;
use Altapay\Traits;
use Altapay\Types;
use GuzzleHttp\Exception\ClientException as GuzzleHttpClientException;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use Symfony\Component\OptionsResolver\Options;
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Ecommerce/ResponseInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function __construct($postedData)
}

/**
* @return RegisteredAddress
* @return string
*/
public function getRegisteredAddress()
{
Expand Down
4 changes: 3 additions & 1 deletion src/Api/Payments/CaptureReservation.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
namespace Altapay\Api\Payments;

use Altapay\AbstractApi;
use Altapay\Exceptions;
use Altapay\Response\CaptureReservationResponse;
use Altapay\Serializer\ResponseSerializer;
use Altapay\Traits\AmountTrait;
use Altapay\Traits\OrderlinesTrait;
use Altapay\Traits\TransactionsTrait;
use GuzzleHttp\Exception\ClientException as GuzzleHttpClientException;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use Symfony\Component\OptionsResolver\OptionsResolver;
Expand Down Expand Up @@ -96,7 +98,7 @@ public function setSalesTax($salesTax)
* The shipping tracking info is used if you want to send the shipping tracking info
* with invoice.
*
* @param $shippingTrackingInfo
* @param string $shippingTrackingInfo
*
* @return $this
*/
Expand Down
2 changes: 2 additions & 0 deletions src/Api/Payments/RefundCapturedReservation.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
namespace Altapay\Api\Payments;

use Altapay\AbstractApi;
use Altapay\Exceptions;
use Altapay\Response\RefundResponse;
use Altapay\Serializer\ResponseSerializer;
use Altapay\Traits;
use GuzzleHttp\Exception\ClientException as GuzzleHttpClientException;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use Symfony\Component\OptionsResolver\OptionsResolver;
Expand Down
7 changes: 5 additions & 2 deletions src/Api/Payments/ReleaseReservation.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
namespace Altapay\Api\Payments;

use Altapay\AbstractApi;
use Altapay\Exceptions;
use Altapay\Response\ReleaseReservationResponse;
use Altapay\Response\PaymentRequestResponse;
use Altapay\Serializer\ResponseSerializer;
use Altapay\Traits\TransactionsTrait;
use GuzzleHttp\Exception\ClientException as GuzzleHttpClientException;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use Symfony\Component\OptionsResolver\OptionsResolver;
Expand Down Expand Up @@ -111,7 +114,7 @@ protected function getHttpMethod()
}

/**
* @return \Altapay\Response\AbstractResponse|PaymentRequestResponse|bool|void
* @return \Altapay\Response\AbstractResponse|PaymentRequestResponse|bool
* @throws \Altapay\Exceptions\ResponseHeaderException
* @throws \Altapay\Exceptions\ResponseMessageException
* @throws \GuzzleHttp\Exception\GuzzleException
Expand Down Expand Up @@ -146,6 +149,6 @@ protected function getPostOptions()
{
$options = $this->options;

return http_build_query($options, null, '&');
return http_build_query($options, '', '&');
}
}
2 changes: 1 addition & 1 deletion src/Api/Payments/ReservationOfFixedAmount.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ protected function handleResponse(Request $request, Response $response)
/**
* Url to api call
*
* @param array $options Resolved options
* @param array<string, string> $options Resolved options
*
* @return string
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Request/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Card
/**
* Card security code
*
* @var int
* @var int|null
*/
private $cvc;

Expand Down
14 changes: 7 additions & 7 deletions src/Request/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ public function setClientIP($clientIP)
/**
* Set Client Accept Language
*
* @param $clientAcceptLanguage
* @param string $clientAcceptLanguage
*
* @return Customer
*/
Expand All @@ -523,7 +523,7 @@ public function setClientAcceptLanguage($clientAcceptLanguage)
/**
* Set Client Accept Language
*
* @param $httpUserAgent
* @param string $httpUserAgent
*
* @return Customer
*/
Expand All @@ -537,7 +537,7 @@ public function setHttpUserAgent($httpUserAgent)
/**
* Set Client Accept Language
*
* @param $httpXForwardedFor
* @param string $httpXForwardedFor
*
* @return Customer
*/
Expand All @@ -551,7 +551,7 @@ public function setHttpXForwardedFor($httpXForwardedFor)
/**
* Set Client Session ID
*
* @param $clientSessionID
* @param string $clientSessionID
*
* @return Customer
*/
Expand Down Expand Up @@ -666,9 +666,9 @@ public function serialize()
}

/**
* @param array $output
* @param $key
* @param Address $object
* @param array<string, string> $output
* @param string $key
* @param Address $object
*/
private static function setAddress(array &$output, $key, Address $object)
{
Expand Down
9 changes: 7 additions & 2 deletions src/Response/AbstractResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ abstract class AbstractResponse
/**
* Header of the result
*
* @var Header;
* @var Header
*/
public $Header;

Expand All @@ -46,6 +46,9 @@ abstract class AbstractResponse
*/
protected $childs = [];

/**
* @return void
*/
public function headerSetter(\SimpleXMLElement $xml = null)
{
if ($xml) {
Expand Down Expand Up @@ -95,13 +98,14 @@ public function deserialize(\SimpleXMLElement $xml = null)
*
* @param object $object
* @param \SimpleXMLElement $element
* @return void
*/
private function attributeSetter($object, \SimpleXMLElement $element)
{
if ($element) {
/** @var \SimpleXMLElement $attribute */
foreach ($element->attributes() as $attribute) {
if (isset($attribute) && $attribute) {
if ($attribute) {
if (!$this->set($object, (string)$attribute, $attribute)) {
throw new \InvalidArgumentException(
sprintf(
Expand All @@ -123,6 +127,7 @@ private function attributeSetter($object, \SimpleXMLElement $element)
* @param object $object
* @param mixed $data
* @param \SimpleXMLElement $element
* @return void
*/
private function elementSetter($object, $data, \SimpleXMLElement $element)
{
Expand Down
20 changes: 10 additions & 10 deletions src/Response/Embeds/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
class Address extends AbstractResponse
{
/**
* @var Firstname
* @var string
*/
public $Firstname;

/**
* @var Lastname
* @var string
*/
public $Lastname;

Expand All @@ -43,17 +43,17 @@ class Address extends AbstractResponse
public $Address;

/**
* @var City
* @var string
*/
public $City;

/**
* @var PostalCode
* @var string
*/
public $PostalCode;

/**
* @var Region
* @var string
*/
public $Region;

Expand All @@ -63,27 +63,27 @@ class Address extends AbstractResponse
public $Country;

/**
* @var billingAddress
* @var string
*/
public $billingAddress;

/**
* @var paymentMethod
* @var string
*/
public $paymentMethod;

/**
* @var currency
* @var string
*/
public $currency;

/**
* @var orderAmount
* @var string
*/
public $orderAmount;

/**
* @param $FirstName
* @param string $FirstName
*
* @return $this
*/
Expand Down
Loading

0 comments on commit 739f9d0

Please sign in to comment.