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

feat: upgrade minimum php version #285

Merged
merged 51 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
cf443a0
chore: drop support for php under 8.2
gasspper Jun 19, 2024
e691190
docs: update readme with new version of php
gasspper Jun 19, 2024
8e922bd
feat: variables are typed
gasspper Jun 19, 2024
072260b
refactor: functions are improved to make it more readable
gasspper Jun 19, 2024
98ec3c1
feat: typed default message
gasspper Jun 19, 2024
54fa7d3
refactor: add type in contracts files
gasspper Jul 1, 2024
997f409
refactor: add type in patpass comercio files
gasspper Jul 1, 2024
fbd0937
refactor: add type in patpass comercio responses files
gasspper Jul 1, 2024
e530862
refactor: add type in utils files
gasspper Jul 1, 2024
a4d8352
refactor: add type in webpay files
gasspper Jul 1, 2024
c91df70
refactor: add type in webpay exceptions files
gasspper Jul 1, 2024
e166427
refactor: add type in oneclick files
gasspper Jul 1, 2024
09afc76
refactor: add type in oneclick responses files
gasspper Jul 1, 2024
0b5d995
refactor: add type in transaccion completa files
gasspper Jul 1, 2024
cfa576c
refactor: add type in transaccion completa responses files
gasspper Jul 1, 2024
d40fb2e
refactor: add type in webpay plus files
gasspper Jul 1, 2024
ce8637e
refactor: add type in webpay plus responses files
gasspper Jul 1, 2024
aeb6dc6
chore: update PHP version to 8.2 in CI workflow
gasspper Jul 1, 2024
ab7b626
refactor: add null type to installmentsAmount
gasspper Jul 1, 2024
1bcb6f3
feat: add the return type of the request
gasspper Jul 2, 2024
eb013d5
feat: add last response and request in requestservice interface
gasspper Jul 2, 2024
c008cfc
refactor: add type in request for httpclient class
gasspper Jul 2, 2024
1e03a1b
refactor: add type in mallinscription
gasspper Jul 2, 2024
02d43f7
refactor: add null type in inscription finish props
gasspper Jul 2, 2024
53894bc
refactor: add type in get status function return of patpass inscription
gasspper Jul 2, 2024
88a02d9
refactor: add null type in patpass comercio
gasspper Jul 2, 2024
b5d0756
refactor: add null type in utils files
gasspper Jul 2, 2024
1fb3ddd
refactor: add null type in webpay options file
gasspper Jul 2, 2024
badef99
refactor: add null type in oneclick responses files
gasspper Jul 2, 2024
434c17b
refactor: add null type in transaccion completa responses files
gasspper Jul 2, 2024
0dd1804
refactor: add null type in webpay plus responses files
gasspper Jul 2, 2024
53c40a1
refactor: add return type in build function for inscription class
gasspper Jul 3, 2024
65fbd24
refactor: delete unnecesary patpass comerce props
gasspper Jul 3, 2024
74c02f9
refactor: change nullable string type by union types
gasspper Jul 3, 2024
7c3ff89
refactor: change nullable array type by union types
gasspper Jul 3, 2024
00f7f54
refactor: change nullable int type by union types
gasspper Jul 3, 2024
0f2574a
refactor: change nullable float type by union types
gasspper Jul 3, 2024
f80f1c3
refactor: change nullable ResponseInterface type by union types
gasspper Jul 3, 2024
8f37497
refactor: change nullable TransbankApiRequest type by union types
gasspper Jul 3, 2024
ea6048a
refactor: change nullable HttpClientInterface type by union types
gasspper Jul 3, 2024
56fd2ce
refactor: change nullable RequestService type by union types
gasspper Jul 3, 2024
e018657
refactor: change nullable Throwable type by union types
gasspper Jul 3, 2024
a3d1069
refactor: change nullable Exception type by union types
gasspper Jul 3, 2024
9d7ae69
refactor: change nullable bool type by union types
gasspper Jul 3, 2024
4996225
refactor: change nullable TransactionDetail type by union types
gasspper Jul 3, 2024
c2e581f
refactor: change int type to float in prepaid balance
gasspper Jul 3, 2024
bbaa77a
refactor: change int type by string in docphp for webpayplus transact…
gasspper Jul 3, 2024
e785b00
refactor: change casting type for captureAmount
gasspper Jul 3, 2024
3333db2
refactor: change nullable float by int flot and null type
gasspper Jul 3, 2024
448d385
refactor: delete capture amount casting
gasspper Jul 3, 2024
76ea663
refactor: change float type by int and float
gasspper Jul 3, 2024
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 .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [7.4]
php-versions: [8.2]
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

## Requisitos:

- PHP 7.0+
- PHP 8.2+

## Dependencias
Para utilizar este SDK, debes tener las siguientes extensiones de PHP instaladas:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Transbank SDK",
"keywords": ["payments", "transbank", "api", "sdk"],
"require": {
"php": ">=7.0",
"php": ">=8.2",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
Expand Down
20 changes: 19 additions & 1 deletion src/Contracts/HttpClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,25 @@

namespace Transbank\Contracts;

use Psr\Http\Message\ResponseInterface;
use GuzzleHttp\Exception\GuzzleException;

interface HttpClientInterface
{
public function request($method, $url, $payload = [], $options = null);
/**
* @param string $method
* @param string $url
* @param array|null $payload
* @param array|null $options
*
* @throws GuzzleException
*
* @return ResponseInterface
*/
public function request(
string $method,
string $url,
array|null $payload = [],
array|null $options = null
): ResponseInterface;
}
20 changes: 15 additions & 5 deletions src/Contracts/RequestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,28 @@
namespace Transbank\Contracts;

use Transbank\Webpay\Options;
use Transbank\Webpay\Exceptions\WebpayRequestException;
use Psr\Http\Message\ResponseInterface;
use Transbank\Webpay\Exceptions\TransbankApiRequest;

interface RequestService
{
/**
* @param $method
* @param $endpoint
* @param $payload
* @param string $method
* @param string $endpoint
* @param array $payload
* @param Options $options
*
* @throws Transbank\Webpay\Exceptions\WebpayRequestException
* @throws WebpayRequestException
*
* @return array Response from the API as json.
*/
public function request($method, $endpoint, $payload, Options $options);
public function request(
string $method,
string $endpoint,
array $payload,
Options $options
): array;
public function getLastResponse(): ResponseInterface|null;
public function getLastRequest(): TransbankApiRequest|null;
}
109 changes: 55 additions & 54 deletions src/PatpassComercio/Inscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Transbank\Utils\RequestServiceTrait;
use Transbank\Contracts\RequestService;
use Transbank\PatpassComercio\Options;
use GuzzleHttp\Exception\GuzzleException;

class Inscription
{
Expand All @@ -27,63 +28,62 @@ class Inscription
/**
* @var Options
*/
protected $options;
protected Options $options;

/**
* Transaction constructor.
*
* @param Options $options
* @param RequestService |null $requestService
* @param Options $options
* @param RequestService|null $requestService
*/
public function __construct(
Options $options,
RequestService $requestService = null
RequestService|null $requestService = null
) {
$this->options = $options;

$this->setRequestService($requestService !== null ? $requestService :
new HttpClientRequestService());
}

/**
* @param $url
* @param $name
* @param $lastName
* @param $secondLastName
* @param $rut
* @param $serviceId
* @param $finalUrl
* @param $maxAmount
* @param $phone
* @param $cellPhone
* @param $patpassName
* @param $personEmail
* @param $commerceEmail
* @param $address
* @param $city
* @param string $url
* @param string $name
* @param string $lastName
* @param string $secondLastName
* @param string $rut
* @param string $serviceId
* @param string $finalUrl
* @param string $maxAmount
* @param string $phone
* @param string $cellPhone
* @param string $patpassName
* @param string $personEmail
* @param string $commerceEmail
* @param string $address
* @param string $city
*
* @throws InscriptionStartException
* @throws GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
*
* @return InscriptionStartResponse
*/
public function start(
$url,
$name,
$lastName,
$secondLastName,
$rut,
$serviceId,
$finalUrl,
$maxAmount,
$phone,
$cellPhone,
$patpassName,
$personEmail,
$commerceEmail,
$address,
$city
) {
string $url,
string $name,
string $lastName,
string $secondLastName,
string $rut,
string $serviceId,
string $finalUrl,
string $maxAmount,
string $phone,
string $cellPhone,
string $patpassName,
string $personEmail,
string $commerceEmail,
string $address,
string $city
): InscriptionStartResponse {
$payload = [
'url' => $url,
'nombre' => $name,
Expand Down Expand Up @@ -120,15 +120,14 @@ public function start(
}

/**
* @param $token
* @param null $options
* @param string $token
*
* @throws InscriptionStatusException
* @throws GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
*
* @return InscriptionStatusResponse
*/
public function status($token)
public function status(string $token): InscriptionStatusResponse
{
$payload = [
'token' => $token,
Expand All @@ -154,46 +153,48 @@ public function status($token)
/**
* @return Options
*/
public function getOptions()
public function getOptions(): Options
{
return $this->options;
}

/**
* @param Options $options
*
* @return void
*/
public function setOptions(Options $options)
public function setOptions(Options $options): void
{
$this->options = $options;
}

/**
* @return string
*/
protected function getBaseUrl()
protected function getBaseUrl(): string
{
return $this->getOptions()->getApiBaseUrl();
}

/**
* @param $commerceCode
* @param $apiKey
* @param string $commerceCode
* @param string $apiKey
*
* @return $this
* @return self
*/
public static function buildForIntegration($commerceCode, $apiKey)
public static function buildForIntegration(string $commerceCode, string $apiKey): self
{
return new static(new Options($apiKey, $commerceCode, Options::ENVIRONMENT_INTEGRATION));
return new self(new Options($apiKey, $commerceCode, Options::ENVIRONMENT_INTEGRATION));
}

/**
* @param $commerceCode
* @param $apiKey
* @param string $commerceCode
* @param string $apiKey
*
* @return $this
* @return self
*/
public static function buildForProduction($commerceCode, $apiKey)
public static function buildForProduction(string $commerceCode, string $apiKey): self
{
return new static(new Options($apiKey, $commerceCode, Options::ENVIRONMENT_PRODUCTION));
return new self(new Options($apiKey, $commerceCode, Options::ENVIRONMENT_PRODUCTION));
}
}
6 changes: 4 additions & 2 deletions src/PatpassComercio/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

namespace Transbank\PatpassComercio;

use Transbank\Webpay\Options as WebpayOptions;

/**
* Class Options.
*/
class Options extends \Transbank\Webpay\Options
class Options extends WebpayOptions
{
const BASE_URL_PRODUCTION = 'https://www.pagoautomaticocontarjetas.cl/';
const BASE_URL_INTEGRATION = 'https://pagoautomaticocontarjetasint.transbank.cl/';

/**
* @return array
*/
public function getHeaders()
public function getHeaders(): array
{
return [
'commercecode' => $this->getCommerceCode(),
Expand Down
6 changes: 3 additions & 3 deletions src/PatpassComercio/PatpassComercio.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
* @category
*/

namespace Transbank\PatpassComercio;
namespace Transbank\PatpassComercio;


class PatpassComercio
{
const INTEGRATION_API_KEY = 'cxxXQgGD9vrVe4M41FIt';
const INTEGRATION_COMMERCE_CODE = '28299257';
public const INTEGRATION_API_KEY = 'cxxXQgGD9vrVe4M41FIt';
public const INTEGRATION_COMMERCE_CODE = '28299257';
}
16 changes: 8 additions & 8 deletions src/PatpassComercio/Responses/InscriptionFinishResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@

class InscriptionFinishResponse
{
public $status;
public $code;
public string|null $status;
public int $code;

public function __construct($httpCode)
public function __construct(int $httpCode)
{
$this->code = $httpCode;
$this->status = null;

if ($httpCode == 204) {
$this->status = 'OK';
Expand All @@ -26,19 +27,18 @@ public function __construct($httpCode)
}

/**
* @return mixed
* @return string|null
*/
public function getStatus()
public function getStatus(): string|null
{
return $this->status;
}

/**
* @return mixed
* @return int
*/
public function getCode()
public function getCode(): int
{
return $this->code;
}

}
17 changes: 8 additions & 9 deletions src/PatpassComercio/Responses/InscriptionStartResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,33 @@

class InscriptionStartResponse
{
public $token;
public $urlWebpay;
public string|null $token;
public string|null $urlWebpay;

/**
* InscriptionStartResponse constructor.
*
* @param $token
* @param array $json
*/
public function __construct($json)
public function __construct(array $json)
{
$this->token = Utils::returnValueIfExists($json, 'token');
$this->urlWebpay = Utils::returnValueIfExists($json, 'url');
}

/**
* @return mixed
* @return string|null
*/
public function getToken()
public function getToken(): string|null
{
return $this->token;
}

/**
* @return mixed
* @return string|null
*/
public function getUrlWebpay()
public function getUrlWebpay(): string|null
{
return $this->urlWebpay;
}

}
Loading
Loading