Skip to content

Drop support for PHP 7.2 and 7.3 #51

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

Open
wants to merge 13 commits into
base: 3.x
Choose a base branch
from
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -2,10 +2,10 @@ name: Test
on:
push:
branches:
- 2.x
- 3.x
pull_request:
branches:
- 2.x
- 3.x

jobs:
test:
@@ -18,10 +18,10 @@ jobs:
fail-fast: false
matrix:
php-version:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
- "8.2"
composer-version:
- "2"
steps:
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -4,7 +4,8 @@
"type": "library",
"keywords": ["payment"],
"require": {
"php": "^7.2 || ^8.0",
"php": "^7.4 || ^8.0",
"ext-json": "*",
"psr/http-message": "^1.0",
"psr/http-client-implementation": "^1.0",
"php-http/message": "^1.6",
6 changes: 6 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -4,6 +4,12 @@ parameters:
- src
- test
ignoreErrors:
# Ignore Call to an undefined static method zaporylie\Vipps\Resource\HttpMethod::POST().
- '#Call to an undefined static method zaporylie\\Vipps\\Resource\\HttpMethod::POST\(\)#'
- '#Call to an undefined static method zaporylie\\Vipps\\Resource\\HttpMethod::PUT\(\)#'
- '#Call to an undefined static method zaporylie\\Vipps\\Resource\\HttpMethod::PATCH\(\)#'
- '#Call to an undefined static method zaporylie\\Vipps\\Resource\\HttpMethod::DELETE\(\)#'
- '#Call to an undefined static method zaporylie\\Vipps\\Resource\\HttpMethod::GET\(\)#'

includes:
- phpstan-baseline.neon
10 changes: 5 additions & 5 deletions src/Api/ApiBase.php
Original file line number Diff line number Diff line change
@@ -11,20 +11,20 @@ abstract class ApiBase
/**
* @var \zaporylie\Vipps\VippsInterface
*/
protected $app;
protected VippsInterface $app;

/**
* @var string
*/
protected $subscriptionKey;
protected string $subscriptionKey;

/**
* ApiBase constructor.
*
* @param \zaporylie\Vipps\VippsInterface $app
* @param string $subscription_key
*/
public function __construct(VippsInterface $app, $subscription_key)
public function __construct(VippsInterface $app, string $subscription_key)
{
$this->app = $app;
$this->subscriptionKey = $subscription_key;
@@ -35,7 +35,7 @@ public function __construct(VippsInterface $app, $subscription_key)
*
* @return string
*/
public function getSubscriptionKey()
public function getSubscriptionKey(): string
{
if (empty($this->subscriptionKey)) {
throw new InvalidArgumentException('Missing subscription key');
@@ -50,7 +50,7 @@ public function getSubscriptionKey()
*
* @return $this
*/
public function setSubscriptionKey($subscriptionKey)
public function setSubscriptionKey(string $subscriptionKey): self
{
$this->subscriptionKey = $subscriptionKey;
return $this;
5 changes: 2 additions & 3 deletions src/Api/Authorization.php
Original file line number Diff line number Diff line change
@@ -2,17 +2,16 @@

namespace zaporylie\Vipps\Api;

use zaporylie\Vipps\Model\Authorization\ResponseGetToken;
use zaporylie\Vipps\Resource\Authorization\GetToken;

class Authorization extends ApiBase implements AuthorizationInterface
{

/**
* {@inheritdoc}
*
* @return \zaporylie\Vipps\Model\Authorization\ResponseGetToken
*/
public function getToken($client_secret)
public function getToken($client_secret): ResponseGetToken
{
// Initiate GetToken resource.
$resource = new GetToken($this->app, $this->getSubscriptionKey(), $client_secret);
4 changes: 3 additions & 1 deletion src/Api/AuthorizationInterface.php
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@

namespace zaporylie\Vipps\Api;

use zaporylie\Vipps\Model\Authorization\ResponseGetToken;

interface AuthorizationInterface
{

@@ -16,5 +18,5 @@ interface AuthorizationInterface
*
* @return \zaporylie\Vipps\Model\Authorization\ResponseGetToken
*/
public function getToken($client_secret);
public function getToken(string $client_secret): ResponseGetToken;
}
45 changes: 26 additions & 19 deletions src/Api/Payment.php
Original file line number Diff line number Diff line change
@@ -2,13 +2,20 @@

namespace zaporylie\Vipps\Api;

use http\Env\Response;
use zaporylie\Vipps\Exceptions\Api\InvalidArgumentException;
use zaporylie\Vipps\Model\Payment\CustomerInfo;
use zaporylie\Vipps\Model\Payment\MerchantInfo;
use zaporylie\Vipps\Model\Payment\RequestCancelPayment;
use zaporylie\Vipps\Model\Payment\RequestCapturePayment;
use zaporylie\Vipps\Model\Payment\RequestInitiatePayment;
use zaporylie\Vipps\Model\Payment\RequestRefundPayment;
use zaporylie\Vipps\Model\Payment\ResponseCancelPayment;
use zaporylie\Vipps\Model\Payment\ResponseCapturePayment;
use zaporylie\Vipps\Model\Payment\ResponseGetOrderStatus;
use zaporylie\Vipps\Model\Payment\ResponseGetPaymentDetails;
use zaporylie\Vipps\Model\Payment\ResponseInitiatePayment;
use zaporylie\Vipps\Model\Payment\ResponseRefundPayment;
use zaporylie\Vipps\Model\Payment\Transaction;
use zaporylie\Vipps\Resource\Payment\CancelPayment;
use zaporylie\Vipps\Resource\Payment\CapturePayment;
@@ -29,19 +36,19 @@ class Payment extends ApiBase implements PaymentInterface
/**
* @var string
*/
protected $merchantSerialNumber;
protected string $merchantSerialNumber;

/**
* @var string
*/
protected $customPath;
protected string $customPath;

/**
* Gets merchantSerialNumber value.
*
* @return string
*/
public function getMerchantSerialNumber()
public function getMerchantSerialNumber(): string
{
if (empty($this->merchantSerialNumber)) {
throw new InvalidArgumentException('Missing merchant serial number');
@@ -52,7 +59,7 @@ public function getMerchantSerialNumber()
/**
* @return string
*/
public function getCustomPath()
public function getCustomPath(): string
{
return $this->customPath;
}
@@ -69,9 +76,9 @@ public function getCustomPath()
*/
public function __construct(
VippsInterface $app,
$subscription_key,
$merchant_serial_number,
$custom_path = 'ecomm'
string $subscription_key,
string $merchant_serial_number,
string $custom_path = 'ecomm'
) {
parent::__construct($app, $subscription_key);
$this->merchantSerialNumber = $merchant_serial_number;
@@ -81,7 +88,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
public function cancelPayment($order_id, $text)
public function cancelPayment(string $order_id, string $text): ResponseCancelPayment
{
// Build request object from data passed to method.
$request = (new RequestCancelPayment())
@@ -103,7 +110,7 @@ public function cancelPayment($order_id, $text)
/**
* {@inheritdoc}
*/
public function capturePayment($order_id, $text, $amount = 0)
public function capturePayment(string $order_id, string $text, int $amount = 0): ResponseCapturePayment
{
// Build request object from data passed to method.
$request = (new RequestCapturePayment())
@@ -129,7 +136,7 @@ public function capturePayment($order_id, $text, $amount = 0)
/**
* {@inheritdoc}
*/
public function getOrderStatus($order_id)
public function getOrderStatus(string $order_id): ResponseGetOrderStatus
{
// Get order status.
// this is GET request so no need to create request object.
@@ -147,7 +154,7 @@ public function getOrderStatus($order_id)
/**
* {@inheritdoc}
*/
public function getPaymentDetails($order_id)
public function getPaymentDetails(string $order_id): ResponseGetPaymentDetails
{
// Get payment details.
// this is GET request so no need to create request object.
@@ -166,13 +173,13 @@ public function getPaymentDetails($order_id)
* {@inheritdoc}
*/
public function initiatePayment(
$order_id,
$amount,
$text,
$callbackPrefix,
$fallback,
$options = []
) {
string $order_id,
int $amount,
string $text,
string $callbackPrefix,
string $fallback,
array $options = []
): ResponseInitiatePayment {
// Create Request object based on data passed to this method.
$request = (new RequestInitiatePayment())
->setCustomerInfo(
@@ -232,7 +239,7 @@ public function initiatePayment(
/**
* {@inheritdoc}
*/
public function refundPayment($order_id, $text, $amount = 0)
public function refundPayment(string $order_id, string $text, int $amount = 0): ResponseRefundPayment
{
// Prepare request object based on data passed to method.
$request = (new RequestRefundPayment())
21 changes: 14 additions & 7 deletions src/Api/PaymentInterface.php
Original file line number Diff line number Diff line change
@@ -2,6 +2,13 @@

namespace zaporylie\Vipps\Api;

use zaporylie\Vipps\Model\Payment\ResponseCancelPayment;
use zaporylie\Vipps\Model\Payment\ResponseCapturePayment;
use zaporylie\Vipps\Model\Payment\ResponseGetOrderStatus;
use zaporylie\Vipps\Model\Payment\ResponseGetPaymentDetails;
use zaporylie\Vipps\Model\Payment\ResponseInitiatePayment;
use zaporylie\Vipps\Model\Payment\ResponseRefundPayment;

/**
* Interface PaymentInterface
*
@@ -16,7 +23,7 @@ interface PaymentInterface
*
* @return \zaporylie\Vipps\Model\Payment\ResponseCancelPayment
*/
public function cancelPayment($order_id, $text);
public function cancelPayment(string $order_id, string $text): ResponseCancelPayment;

/**
* @param string $order_id
@@ -25,7 +32,7 @@ public function cancelPayment($order_id, $text);
*
* @return \zaporylie\Vipps\Model\Payment\ResponseCapturePayment
*/
public function capturePayment($order_id, $text, $amount = 0);
public function capturePayment(string $order_id, string $text, int $amount = 0): ResponseCapturePayment;

/**
* @param string $order_id
@@ -35,29 +42,29 @@ public function capturePayment($order_id, $text, $amount = 0);
* @deprecated Get order status was deprecated and can be removed in version 3.0.
* @see \zaporylie\Vipps\Resource\Payment\GetOrderStatus
*/
public function getOrderStatus($order_id);
public function getOrderStatus(string $order_id): ResponseGetOrderStatus;

/**
* @param string $order_id
*
* @return \zaporylie\Vipps\Model\Payment\ResponseGetPaymentDetails
*/
public function getPaymentDetails($order_id);
public function getPaymentDetails(string $order_id): ResponseGetPaymentDetails;

/**
* @param string $order_id
* @param int $amount
* @param string $text
* @param string $callbackPrefix
* @param string $fallback
* @param $options array
* @param array $options
* Optional values.
*
* @return \zaporylie\Vipps\Model\Payment\ResponseInitiatePayment
*
* @see https://vippsas.github.io/vipps-ecom-api/#/Vipps_eCom_API/initiatePaymentV3UsingPOST
*/
public function initiatePayment($order_id, $amount, $text, $callbackPrefix, $fallback, $options = []);
public function initiatePayment(string $order_id, int $amount, string $text, string $callbackPrefix, string $fallback, array $options = []): ResponseInitiatePayment;

/**
* @param string $order_id
@@ -66,5 +73,5 @@ public function initiatePayment($order_id, $amount, $text, $callbackPrefix, $fal
*
* @return \zaporylie\Vipps\Model\Payment\ResponseRefundPayment
*/
public function refundPayment($order_id, $text, $amount = 0);
public function refundPayment(string $order_id, string $text, int $amount = 0): ResponseRefundPayment;
}
Loading