Skip to content

Commit

Permalink
php 81 (#28)
Browse files Browse the repository at this point in the history
* php 81

* php 8

* csfixer

* add allow plugins

* remove deprecated paypal and saferpaylegacy

* add 8.3, ensure model is found

* latest headless version

* changelog, drop legacy phpdocs
  • Loading branch information
nadar authored Sep 13, 2023
1 parent 3f6eec3 commit 93bce97
Show file tree
Hide file tree
Showing 54 changed files with 291 additions and 897 deletions.
20 changes: 9 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Tests
on: [push, pull_request]

env:
DEFAULT_COMPOSER_FLAGS: "--prefer-dist --no-interaction"
PHPUNIT_EXCLUDE_GROUP: mssql,oci,wincache,xcache,zenddata,cubrid
CC_TEST_REPORTER_ID: a9ab6de7fbc8f532a9f829091d3994223dfbef5542c42f5c6d5e3ec877eebc74
jobs:
phpunit:
Expand All @@ -14,40 +12,40 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: ['7.0', '7.1', '7.2', '7.3', '7.4']
php: ['8.0', '8.1', '8.2', '8.3']

steps:
## checkout the repoistory
- name: Checkout Repo
uses: actions/checkout@v2
uses: actions/checkout@v3

## Install(?) php
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: apc, curl, dom, imagick, intl, mbstring, mcrypt, memcached, mysql, pdo, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, sqlite
ini-values: date.timezone='UTC'
extensions: curl, dom, intl, mbstring, mcrypt, mysql, pdo, pdo_mysql, pdo_pgsql, pdo_sqlite, sqlite
ini-values: date.timezone='UTC',error_reporting=E_ALL,display_errors=On

## install composer
- name: Install dependencies
run: composer install $DEFAULT_COMPOSER_FLAGS
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader

## run unit tests
- name: PHP Unit tests for PHP
run: vendor/bin/phpunit --verbose --configuration actions.phpunit.xml
if: matrix.php == '8.0' || matrix.php == '7.4' || matrix.php == '7.3' || matrix.php == '7.2' || matrix.php == '7.0'
if: matrix.php == '8.3' || matrix.php == '8.2' || matrix.php == '8.1'

## unit test with coverage
- name: PHP Unit tests for PHP 7.1
- name: PHP Unit tests for PHP 8.0
run: vendor/bin/phpunit --verbose --coverage-clover=clover.xml --configuration actions.phpunit.xml
if: matrix.php == '7.1'
if: matrix.php == '8.0'

## coverage
- name: Code coverage
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter after-build -t clover
if: matrix.php == '7.1'
if: matrix.php == '8.0'
continue-on-error: true # if is fork
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
/.buildpath
/vendor/
/luya
composer.lock
composer.lock
.tmp
1 change: 1 addition & 0 deletions .php-cs-fixer.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"php":"8.2.10","version":"3.26.1:v3.26.1#d023ba6684055f6ea1da1352d8a02baca0426983","indent":" ","lineEnding":"\n","rules":{"binary_operator_spaces":{"default":"at_least_single_space"},"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_typehint":true,"curly_braces_position":{"allow_single_line_empty_anonymous_classes":true},"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"sort_algorithm":"alpha"},"return_type_declaration":true,"short_scalar_cast":true,"single_import_per_statement":{"group_to_single_imports":false},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"no_unused_imports":true},"hashes":{"src\/frontend\/messages\/it\/paymentfrontend.php":"8092a0a280e1e2e22b4dbd47ad907a51","src\/frontend\/messages\/en\/paymentfrontend.php":"d0b1777a2bbc98a0619f28a3d61915f1","src\/frontend\/messages\/de\/paymentfrontend.php":"d7a51433497f10f7f9edfc7336fd27c0","src\/frontend\/Module.php":"03530bc8303b9703e41cb6e2234c86fe","src\/frontend\/controllers\/DefaultController.php":"c3b878232e3b1b2aecc9f02a27652e61","src\/frontend\/controllers\/TestController.php":"52c4ebfdee18956dd4143b9b8fdf6307","src\/frontend\/stripe\/transaction.php":"efd3d97d7ddd78c133985331f23961d0","src\/frontend\/stripe\/layout.php":"acc021c792dd074265c91f5057a406a7","src\/Pay.php":"b5f2304c91cd8fa6cb1982d0c9d50c22","src\/models\/ProcessTrace.php":"b6805c9563e3309d12bc510474c076f4","src\/models\/ProcessItem.php":"46640258dba57f2e0b494889496a27df","src\/models\/Process.php":"f26462488556e1110b1cc5940537cd19","src\/PaymentException.php":"452ee7284cad4c39d89266fb4f95eb88","src\/providers\/SaferPayProvider.php":"0a7ed583b3f625b1b73d87aa09e8169f","src\/providers\/PayPalProvider.php":"1c166cae0fb56d91c5190044ea2e6480","src\/providers\/SaferPayLegacyProvider.php":"c430644229fb84fd0315420df488be15","src\/providers\/StripeProvider.php":"8febe1325997d67f53a42067ab9ad935","src\/helpers\/OrderHelper.php":"7607a0013357ecb2edee13695d41048a","src\/integrators\/DatabaseIntegrator.php":"cda377ffeeecc8941f3c9d2d5eb69947","src\/integrators\/HeadlessIntegrator.php":"1d527a17e2d372452d96d0a3b7da2cd3","src\/integrators\/headless\/ApiPaymentProcessTrace.php":"d50dd7f162b519aafeb3001dee3d26cb","src\/integrators\/headless\/ApiPaymentProcess.php":"d4540e885a61e3cf6b9dd9c727911439","src\/base\/ProviderInterface.php":"e81a8ab818df382b773923a1c0492080","src\/base\/PayItemModel.php":"7bc1840512d9538cc19cc9925b5529b7","src\/base\/IntegratorInterface.php":"d5ae361af2cc47ec1f5a55b9aa2fac6f","src\/base\/Transaction.php":"2c58c2ac43555a3475238621c4b5cfb6","src\/base\/Provider.php":"26bf694a9df53507078123c07b033864","src\/base\/PayModel.php":"0fd0ccdd88ec8435b558aa3f8f41e58d","src\/base\/OrderInterface.php":"a5672c1ca5796fd218e1a1e053636726","src\/widgets\/SubmitFormButtonWidget.php":"cf050a62be739bb44b8a77c0c70432a4","src\/transactions\/SaferPayTransaction.php":"ed6316686c033346cf6a6b563bc75785","src\/transactions\/PayPalTransaction.php":"f696c230f17b23a85bbc041f6d92eb88","src\/transactions\/SaferPayLegacyTransaction.php":"3b902f7acc67fcb50bff4047336b7fd6","src\/transactions\/StripeTransaction.php":"a5b9d7908aa8268acf9f152f36c7ad93","src\/admin\/Module.php":"973c4df3e4d59cb41c9427a69ee3f517","src\/admin\/apis\/ProcessItemController.php":"489069a50e2d18a3e92e73383c497183","src\/admin\/apis\/ProcessController.php":"f88ba4cbf35d2132bc19ce63506abcfc","src\/admin\/apis\/ProcessTraceController.php":"9b1ad622c0c9ed2df228c544c18bce37","src\/admin\/controllers\/ProcessItemController.php":"49adb30bfb300965582161a42894aaf1","src\/admin\/controllers\/ProcessController.php":"132c21c553c92deb0be9d7181bc95dae","src\/admin\/controllers\/ProcessTraceController.php":"defeed5d6671002a78ab94a51d743097","src\/admin\/migrations\/m181010_091426_order_fields_process_timestamp.php":"c8aaeda4704c0e2ed03303daae28996d","src\/admin\/migrations\/m181015_091426_order_state.php":"418b84a8aade7ff2bbb1bd45d294da82","src\/admin\/migrations\/m160303_090454_paymentprocess.php":"4026abbb550535b05e7f00aeb71a2526","src\/admin\/migrations\/m201405_101926_provider_infos.php":"8e2c172a2e254e197e44d4278de0108a","src\/admin\/migrations\/m180425_193943_drop_process_fields.php":"8e492968ba4c8b827252b1379a586a9f","tests\/src\/providers\/StripeProviderTest.php":"9e34dbecb8872a5782f661c1126d06bd","tests\/src\/providers\/SaferPayProviderTest.php":"00022b2033757a89f46953d552e238f4","tests\/src\/PayTest.php":"8ab1211743663fc566ad01e65b421954","tests\/src\/helpers\/OrderHelperTest.php":"513988bfe8290d6e53ddae238ae6f6ce","tests\/src\/integrators\/HeadlessIntegratorTest.php":"cce124780ba9dbe2d6f25c7168824276","tests\/src\/integrators\/DatabaseIntegratorTest.php":"e3276ef88bf5ece7d815633de48a585a","tests\/src\/PaymentProcessTest.php":"f7df5b2494a588f956bfebb0d65a5e81","tests\/src\/transaction\/GenericTransactionTest.php":"4ceb1e9eef1eb8998945621fc1a381b7","tests\/src\/transaction\/PayPalTransactionTest.php":"48801107cfffa954ad4017bdedb24b40","tests\/src\/transaction\/SaferPayTransactionTest.php":"38471ca10d73dcae368e23ccc7325ad8","tests\/src\/transaction\/SaferPayLegacyTransactionTest.php":"ffc9882a0f48825212a09266ede51141","tests\/src\/transaction\/StripeTransactionTest.php":"f84c27e95fed911012326b59c7332098","tests\/src\/controllers\/DefaultControllerTest.php":"3fd12440a4890140d4f5ca373b127c5f","tests\/src\/GenericTest.php":"8a02240924aecf2aeed7a968b878d8ed","tests\/src\/widgets\/SubmitFormButtonWidgetTest.php":"9bc69c33721773dd402e018145dc244f","tests\/data\/DummyIntegrator.php":"76dc65091dbffc176d075bae3aed7cd6","tests\/data\/DummyTransaction.php":"8b569a2bfe7ff3b51a8144b17c095096","tests\/data\/DummyProvider.php":"68ab873a578bcfafe625f7c1f6793f66","tests\/BasePaymentTestCase.php":"e5bcb33b708806e0ea6ee5d399c8308b"}}
15 changes: 15 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
;

$config = new PhpCsFixer\Config();
return $config->setRules([
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,
])
->setFinder($finder)
;
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
In order to read more about upgrading and BC breaks have a look at the [UPGRADE Document](UPGRADE.md).

## 4.0.0 (13. Septmeber 2023)

+ [#28](https://github.com/luyadev/luya-module-payment/pull/28) Removed PayPal support from built in providers due to not upgraded composer SDK.
+ [#28](https://github.com/luyadev/luya-module-payment/pull/28) Removed SaferPayLegacy Provider
+ [#28](https://github.com/luyadev/luya-module-payment/pull/28) Dropped support for PHP 7.x versions

## 3.0.4 (8. February 2022)

+ Upgrade stripe php sdk to allow php 8 compatibility
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Its even possible to define an `integrator` which allows you to add the module c

Currently supported payment providers:

+ [paypal.com](https://paypal.com)
+ [saferpay.com](https://www.saferpay.com)
+ [stripe.com](https://stripe.com)

Expand Down
6 changes: 6 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Upgrade

## 3.x to 4.0

+ Removed the `SaferPayLegacy` provider, no replacment.
+ Removed `PayPal` provider, no replacment.
+ Dropped support for PHP 7.x versions

## 2.x to 3.0

+ [#22](https://github.com/luyadev/luya-module-payment/pull/22) The SaferPay Transaction has been replaced with the new JSON API and therefore the old HTTPS interface SaferPay Transaction class has been renamed to `SaferPayLegacyTransaction` while the new `SaferPayTransaction` contains the new code to work with the JSON API. Therefore the class parameters which are required has been changed. The new configuration looks as followed:
Expand Down
76 changes: 49 additions & 27 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,67 @@
{
"name" : "luyadev/luya-module-payment",
"description" : "LUYA Payment allows you to integrate payments in a safe and fast way. The module take care of all the provider required steps (call, create, success, abort, etc.) and provides all the informations for your store.",
"type" : "luya-module",
"keywords" : ["php", "luya", "module", "yii2", "payment", "estore", "saferpay", "paypal", "luya-module", "stripe"],
"name": "luyadev/luya-module-payment",
"description": "LUYA Payment allows you to integrate payments in a safe and fast way. The module take care of all the provider required steps (call, create, success, abort, etc.) and provides all the informations for your store.",
"type": "luya-module",
"keywords": [
"php",
"luya",
"module",
"yii2",
"payment",
"estore",
"saferpay",
"luya-module",
"stripe"
],
"license": "MIT",
"homepage" : "https://luya.io",
"authors" : [
"homepage": "https://luya.io",
"authors": [
{
"name" : "Basil",
"email" : "git@nadar.io",
"homepage" : "https://github.com/nadar"
"name": "Basil",
"email": "git@nadar.io",
"homepage": "https://github.com/nadar"
}
],
"support" : {
"issues" : "https://github.com/luyadev/luya-module-payment/issues"
"support": {
"issues": "https://github.com/luyadev/luya-module-payment/issues"
},
"require" : {
"luyadev/luya-module-admin" : ">=2.0",
"luyadev/luya-headless" : "*",
"stripe/stripe-php": "^7.1",
"paypal/rest-api-sdk-php" : "^1.0"
"require": {
"php": ">=8.0",
"luyadev/luya-module-admin": "^4.9.1",
"luyadev/luya-headless": "^2.10.1",
"stripe/stripe-php": "^7.1"
},
"require-dev" : {
"unglue/client" : "^1.0",
"luyadev/luya-testsuite" : "^2.0"
"require-dev": {
"unglue/client": "^1.0",
"luyadev/luya-testsuite": "^3.0",
"friendsofphp/php-cs-fixer": "^3.2",
"phpstan/phpstan": "^1.7",
"rector/rector": "^0.14.2"
},
"autoload" : {
"psr-4" : {
"luya\\payment\\" : "src/",
"luya\\payment\\tests\\" : "tests/"
"autoload": {
"psr-4": {
"luya\\payment\\": "src/",
"luya\\payment\\tests\\": "tests/"
}
},
"config": {
"fxp-asset": {
"enabled": false
"platform": {
"php": "8.0"
},
"allow-plugins": {
"yiisoft/yii2-composer": true,
"luyadev/luya-composer": true
}
},
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
]
}
],
"scripts": {
"phpstan": "vendor/bin/phpstan -v",
"phpcsfixer": "vendor/bin/php-cs-fixer fix",
"rector": "vendor/bin/rector"
}
}
19 changes: 0 additions & 19 deletions guide/providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,6 @@ The [Stripe](https://stripe.com) transaction integration config:

[See all cards](https://stripe.com/docs/testing#regulatory-cards)

## PayPal Transaction

The [PayPal](https://paypal.com) transaction integration config:

```php
'payment' => [
'class' => 'luya\payment\frontend\Module',
'transaction' => [
'class' => 'luya\payment\transactions\PayPalTransaction',
'clientId' => '<CLIENT_ID>',
'clientSecret' => '<CLIENT_SECRET>',
]
]
```

+ `clientId`: The client id from the paypal website.
+ `clientSecret`: The client secret from the paypal website.
+ `mode`: The mode `live` or `sandbox` values are available.

## SaferPay Transaction

The [SaferPay](https://saferpay.com) transaction API integration config:
Expand Down
6 changes: 0 additions & 6 deletions guide/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ Configure the payment module in your config with the transaction payment provide
'payment' => [
'class' => 'luya\payment\frontend\Module',
'transaction' => [
// Paypal Example
// 'class' => 'luya\payment\transactions\PayPalTransaction',
// 'clientId' => 'ClientIdFromPayPalApplication',
// 'clientSecret' => 'ClientSecretFromPayPalApplication',
// 'productDescription' => 'MyOnlineStore Order',

// SaferPay Example
// 'terminalId' => '12345678',
// 'customerId' => '123456',
Expand Down
7 changes: 7 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parameters:
level: 0
paths:
- src
bootstrapFiles:
- vendor/yiisoft/yii2/Yii.php
tmpDir: .tmp
26 changes: 12 additions & 14 deletions src/Pay.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

namespace luya\payment;

use Yii;
use luya\helpers\Url;
use luya\web\Controller;
use luya\payment\frontend\Module;
use luya\payment\base\PayItemModel;
use luya\payment\base\PayModel;
use luya\payment\models\ProcessItem;
use luya\payment\base\PayItemModel;// Rename to PayArticle?
use luya\payment\frontend\Module;
use luya\web\Controller;// Rename to PayArticle?
use yii\base\InvalidConfigException;

/**
Expand All @@ -19,13 +17,13 @@
*/
class Pay
{
const STATE_PENDING = 0;
public const STATE_PENDING = 0;

public const STATE_SUCCESS = 1;

public const STATE_ERROR = 2;

const STATE_SUCCESS = 1;

const STATE_ERROR = 2;

const STATE_ABORT = 3;
public const STATE_ABORT = 3;

private $_totalAmount;

Expand Down Expand Up @@ -53,7 +51,7 @@ public function setCurrency($currency)
if (strlen($currency) !== 3) {
throw new InvalidConfigException("The currency must be a 3-letter ISO 4217 code.");
}

$this->_currency = $currency;
}

Expand Down Expand Up @@ -204,7 +202,7 @@ public function getAuthToken()
{
return $this->getCreateModel()->getAuthToken();
}

/**
* Dispatch the current controller to the getTransactionGatewayCreat link.
*
Expand All @@ -214,7 +212,7 @@ public function getAuthToken()
public function dispatch(Controller $controller)
{
$url = $this->getCreateModel()->getTransactionGatewayCreateLink();

return $controller->redirect($url);
}

Expand Down
2 changes: 1 addition & 1 deletion src/admin/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Module extends \luya\admin\base\Module
'api-payment-processitem' => 'luya\payment\admin\apis\ProcessItemController',

];

public function getMenu()
{
return (new \luya\admin\components\AdminMenuBuilder($this))
Expand Down
2 changes: 1 addition & 1 deletion src/admin/migrations/m160303_090454_paymentprocess.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function safeUp()
'close_state' => $this->integer(11)->defaultValue(0),
'is_closed' => $this->boolean()->defaultValue(false),
]);

$this->createTable('payment_process_trace', [
'id' => $this->primaryKey(),
'process_id' => $this->integer(11)->notNull(),
Expand Down
4 changes: 1 addition & 3 deletions src/base/IntegratorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace luya\payment\base;

use luya\web\Controller;

/**
* Integrator Interface.
*
Expand Down Expand Up @@ -86,5 +84,5 @@ public function saveProviderData(PayModel $model, array $data);
* @return array
* @since 3.0.0
*/
public function getProviderData(PayModel $model) : array;
public function getProviderData(PayModel $model): array;
}
3 changes: 1 addition & 2 deletions src/base/PayItemModel.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace luya\payment\base;

use yii\base\Model;
Expand All @@ -20,7 +19,7 @@ class PayItemModel extends Model
public $amount;
public $is_shipping;
public $is_tax;

/**
* @inheritdoc
*/
Expand Down
Loading

0 comments on commit 93bce97

Please sign in to comment.