Skip to content

Commit

Permalink
Merge branch 'php72'
Browse files Browse the repository at this point in the history
  • Loading branch information
stymiee committed Dec 19, 2020
2 parents c0eeb32 + 68f7fc1 commit 2610735
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PHP Composer
name: Build

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion examples/webhooks/createWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
require '../../config.inc.php';

try {
$request = AuthnetApiFactory::getJsonApiHandler(
$request = AuthnetApiFactory::getWebhooksHandler(
AUTHNET_LOGIN,
AUTHNET_TRANSKEY,
AuthnetApiFactory::USE_DEVELOPMENT_SERVER
Expand Down
2 changes: 1 addition & 1 deletion examples/webhooks/deleteWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
require '../../config.inc.php';

try {
$request = AuthnetApiFactory::getJsonApiHandler(
$request = AuthnetApiFactory::getWebhooksHandler(
AUTHNET_LOGIN,
AUTHNET_TRANSKEY,
AuthnetApiFactory::USE_DEVELOPMENT_SERVER
Expand Down
2 changes: 1 addition & 1 deletion examples/webhooks/getEventTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
require '../../config.inc.php';

try {
$request = AuthnetApiFactory::getJsonApiHandler(
$request = AuthnetApiFactory::getWebhooksHandler(
AUTHNET_LOGIN,
AUTHNET_TRANSKEY,
AuthnetApiFactory::USE_DEVELOPMENT_SERVER
Expand Down
2 changes: 1 addition & 1 deletion examples/webhooks/getWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
require '../../config.inc.php';

try {
$request = AuthnetApiFactory::getJsonApiHandler(
$request = AuthnetApiFactory::getWebhooksHandler(
AUTHNET_LOGIN,
AUTHNET_TRANSKEY,
AuthnetApiFactory::USE_DEVELOPMENT_SERVER
Expand Down
9 changes: 4 additions & 5 deletions examples/webhooks/listWebhooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
require '../../config.inc.php';

try {
$request = AuthnetApiFactory::getJsonApiHandler(
$request = AuthnetApiFactory::getWebhooksHandler(
AUTHNET_LOGIN,
AUTHNET_TRANSKEY,
AuthnetApiFactory::USE_DEVELOPMENT_SERVER
Expand Down Expand Up @@ -114,11 +114,11 @@
<table>
<tr>
<th>Successful</th>
<td><?= ($successful) ? 'Yes' : 'No';?></td>
<td><?= ($successful) ? 'Yes' : 'No' ?></td>
</tr>
<?php
if ($successful) {
foreach($response->getWebhooks() as $webhook) {
foreach ($response->getWebhooks() as $webhook) {
?>
<tr>
<td colspan="2">
Expand Down Expand Up @@ -149,8 +149,7 @@
</tr>
<?php
}
}
elseif ($error) {
} elseif ($error) {
?>
<tr>
<th>Error message</th>
Expand Down
2 changes: 1 addition & 1 deletion examples/webhooks/notificationHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
require '../../config.inc.php';

try {
$request = AuthnetApiFactory::getJsonApiHandler(
$request = AuthnetApiFactory::getWebhooksHandler(
AUTHNET_LOGIN,
AUTHNET_TRANSKEY,
AuthnetApiFactory::USE_DEVELOPMENT_SERVER
Expand Down
2 changes: 1 addition & 1 deletion examples/webhooks/ping.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
require '../../config.inc.php';

try {
$request = AuthnetApiFactory::getJsonApiHandler(
$request = AuthnetApiFactory::getWebhooksHandler(
AUTHNET_LOGIN,
AUTHNET_TRANSKEY,
AuthnetApiFactory::USE_DEVELOPMENT_SERVER
Expand Down
2 changes: 1 addition & 1 deletion examples/webhooks/updateWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
require '../../config.inc.php';

try {
$request = AuthnetApiFactory::getJsonApiHandler(
$request = AuthnetApiFactory::getWebhooksHandler(
AUTHNET_LOGIN,
AUTHNET_TRANSKEY,
AuthnetApiFactory::USE_DEVELOPMENT_SERVER
Expand Down
16 changes: 9 additions & 7 deletions src/Authnetjson/AuthnetJsonRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use Authnetjson\Exception\AuthnetCannotSetParamsException;
use Authnetjson\Exception\AuthnetCurlException;
use Authnetjson\Exception\AuthnetInvalidJsonException;
use \Curl\Curl;

/**
Expand Down Expand Up @@ -145,11 +146,11 @@ public function __toString()
/**
* The __set() method should never be used as all values to be made in the API call must be passed as an array
*
* @param string $name unused
* @param mixed $value unused
* @param string $name unused
* @param mixed $value unused
* @throws AuthnetCannotSetParamsException
*/
public function __set($name, $value)
public function __set(string $name, $value)
{
throw new AuthnetCannotSetParamsException(sprintf('You cannot set parameters directly in %s.', __CLASS__));
}
Expand All @@ -158,12 +159,13 @@ public function __set($name, $value)
* Magic method that dynamically creates our API call based on the name of the method in the client code and
* the array passed as its parameter.
*
* @param string $api_call name of the API call to be made
* @param array $args the array to be passed to the API
* @param string $api_call name of the API call to be made
* @param array $args the array to be passed to the API
* @return AuthnetJsonResponse
* @throws AuthnetInvalidJsonException
* @throws AuthnetCurlException
*/
public function __call($api_call, array $args)
public function __call(string $api_call, array $args)
{
$authentication = [
'merchantAuthentication' => [
Expand Down Expand Up @@ -225,7 +227,7 @@ private function process(): string
*
* @param Curl $processor
*/
public function setProcessHandler($processor): void
public function setProcessHandler(Curl $processor): void
{
$this->processor = $processor;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Authnetjson/AuthnetJsonResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@ protected function checkTransactionStatus(int $status): bool
* Gets the transaction response field for AIM and CIM transactions.
*
* @param mixed $field Name or key of the transaction field to be retrieved
* @return string Transaction field to be retrieved
* @return null|string Transaction field to be retrieved
* @throws AuthnetTransactionResponseCallException
*/
public function getTransactionResponseField($field): string
public function getTransactionResponseField($field): ?string
{
if ($this->transactionInfo instanceof TransactionResponse) {
return $this->transactionInfo->getTransactionResponseField($field);
Expand Down
8 changes: 4 additions & 4 deletions src/Authnetjson/AuthnetSim.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ class AuthnetSim
* Creates a SIM wrapper by setting the Authorize.Net credentials and URL of the endpoint to be used
* for the API call
*
* @param string $login Authorize.Net API login ID
* @param string $signature Authorize.Net API Transaction Key
* @param string $api_url URL endpoint for processing a transaction
* @param string $login Authorize.Net API login ID
* @param string $signature Authorize.Net API Transaction Key
* @param string $api_url URL endpoint for processing a transaction
* @throws Exception
*/
public function __construct($login, $signature, $api_url)
public function __construct(string $login, string $signature, string $api_url)
{
$this->login = $login;
$this->signature = $signature;
Expand Down
6 changes: 3 additions & 3 deletions src/Authnetjson/AuthnetWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ public function __toString()
/**
* Gets a response variable from the Webhook notification
*
* @param string $var
* @param string $var
* @return string requested variable from the API call response
*/
public function __get($var)
public function __get(string $var)
{
return $this->webhook->{$var};
}
Expand Down Expand Up @@ -146,6 +146,6 @@ protected function getAllHeaders(): array
}
}
}
return $headers;
return $headers ?: [];
}
}
5 changes: 3 additions & 2 deletions src/Authnetjson/AuthnetWebhooksRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Authnetjson;

use Authnetjson\Exception\AuthnetCurlException;
use Authnetjson\Exception\AuthnetInvalidJsonException;
use Curl\Curl;

/**
Expand Down Expand Up @@ -54,7 +55,7 @@ class AuthnetWebhooksRequest
*
* @param string $api_url URL endpoint for processing a transaction
*/
public function __construct($api_url)
public function __construct(string $api_url)
{
$this->url = $api_url;
}
Expand All @@ -64,7 +65,7 @@ public function __construct($api_url)
*
* @return string HTML table containing debugging information
*/
public function __toString()
public function __toString(): string
{
$output = '<table id="authnet-request">'."\n";
$output .= '<caption>Authorize.Net Request</caption>'."\n";
Expand Down
2 changes: 1 addition & 1 deletion src/Authnetjson/AuthnetWebhooksResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __construct(string $responseJson)
*
* @return string HTML table containing debugging information
*/
public function __toString()
public function __toString(): string
{
$output = '<table id="authnet-response">'."\n";
$output .= '<caption>Authorize.Net Webhook Response</caption>'."\n";
Expand Down
2 changes: 1 addition & 1 deletion tests/Authnetjson/AuthnetWebhooksRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ public function testHandleResponseWithErrorMessageNoMessage(): void
*/
public function testProcessorIsInstanceOfCurlWrapper(): void
{
$request = new AuthnetWebhooksRequest(null, null, $this->server);
$request = new AuthnetWebhooksRequest('');
$request->setProcessHandler(new Curl());

$reflectionOfRequest = new \ReflectionObject($request);
Expand Down

0 comments on commit 2610735

Please sign in to comment.