diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 0937d477..21431622 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -1,15 +1,15 @@ in(__DIR__.'/src') - ->in(__DIR__.'/test'); + ->in(__DIR__ . '/src') + ->in(__DIR__ . '/test'); $config = new PhpCsFixer\Config(); return $config ->setUsingCache(false) ->setRules( array( - '@PSR2' => true, + '@PSR12' => true, 'no_blank_lines_after_phpdoc' => true, 'phpdoc_add_missing_param_annotation' => true, 'native_function_casing' => true, @@ -21,11 +21,11 @@ 'multiline_whitespace_before_semicolons' => true, 'no_singleline_whitespace_before_semicolons' => true, 'no_spaces_around_offset' => true, - 'no_trailing_comma_in_singleline_array' => true, + 'no_trailing_comma_in_singleline' => true, 'no_unused_imports' => true, 'normalize_index_brace' => true, 'phpdoc_align' => true, 'phpdoc_separation' => true, ) ) - ->setFinder($finder); \ No newline at end of file + ->setFinder($finder); diff --git a/CHANGELOG.md b/CHANGELOG.md index fa002924..a6b61392 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [3.3.0](https://github.com/unzerdev/php-sdk/compare/3.2.0..3.3.0) +### Added +* Chargeback transaction type. + * Add class `\UnzerSDK\Resources\TransactionTypes\Chargeback`. + * Add methods `\UnzerSDK\Unzer::fetchChargeback` and `\UnzerSDK\Unzer::fetchChargebackById` to fetch chargeback information. +* Add `\UnzerSDK\Resources\PaymentTypes\PayU` payment type. +* Add example for PayU payment type. + ## [3.2.0](https://github.com/unzerdev/php-sdk/compare/3.1.0..3.2.0) ### Added diff --git a/examples/PayU/Constants.php b/examples/PayU/Constants.php new file mode 100644 index 00000000..9fd1ff03 --- /dev/null +++ b/examples/PayU/Constants.php @@ -0,0 +1,28 @@ +setDebugMode(true)->setDebugHandler(new ExampleDebugHandler()); + + // Create a charge transaction to get the redirectUrl. + $transaction = new \UnzerSDK\Resources\TransactionTypes\Charge(12.32, 'PLN', RETURN_CONTROLLER_URL); + $unzer->performCharge($transaction, $paymentTypeId); + + // You'll need to remember the paymentId for later in the ReturnController + $_SESSION['PaymentId'] = $transaction->getPaymentId(); + $_SESSION['ShortId'] = $transaction->getShortId(); + + // Redirect to the PayU page + if (!$transaction->isError() && $transaction->getRedirectUrl() !== null) { + redirect($transaction->getRedirectUrl()); + } + + // Check the result message of the charge to find out what went wrong. + $merchantMessage = $transaction->getMessage()->getCustomer(); +} catch (UnzerApiException $e) { + $merchantMessage = $e->getMerchantMessage(); + $clientMessage = $e->getClientMessage(); +} catch (RuntimeException $e) { + $merchantMessage = $e->getMessage(); +} +redirect(FAILURE_URL, $merchantMessage, $clientMessage); diff --git a/examples/PayU/index.php b/examples/PayU/index.php new file mode 100644 index 00000000..ec92b301 --- /dev/null +++ b/examples/PayU/index.php @@ -0,0 +1,87 @@ + + + + +
+ +Click here to open our test data in new tab.
+ + + + + + diff --git a/examples/index.php b/examples/index.php index 8022e363..da0dfd20 100755 --- a/examples/index.php +++ b/examples/index.php @@ -295,6 +295,18 @@ function printMessage($type, $title, $text) Try +