Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d8d0638
[fix] (UMCS-56)
Ryouzanpaku Jan 11, 2021
fec06c5
[fix] (UMCS-56)
Ryouzanpaku Jan 18, 2021
20c414c
[fix] (UMCS-56)
Ryouzanpaku Jan 18, 2021
383aacf
Merge pull request #21 from unzerdev/UMCS-56/fix/test-logging
Ryouzanpaku Feb 1, 2021
763526d
[fix] (UMCS-70)
Ryouzanpaku Feb 17, 2021
a542883
Merge pull request #23 from unzerdev/UMCS-70/fix/paypal-recurring-exa…
Ryouzanpaku Feb 22, 2021
713ef00
Add integration tests for instalment cancel after shipment.
sixer1182 Feb 22, 2021
76cadcc
Merge remote-tracking branch 'origin/develop' into change_add_tests_f…
sixer1182 Feb 22, 2021
01e3b50
Add integration tests for instalment cancel after shipment.
sixer1182 Feb 22, 2021
a1f706b
Merge pull request #24 from unzerdev/change_add_tests_for_instalment_…
Ryouzanpaku Feb 22, 2021
ce13e5d
- run cs-fixer.
Ryouzanpaku Mar 1, 2021
396f3c6
Merge pull request #25 from unzerdev/change_add_tests_for_instalment_…
Ryouzanpaku Mar 1, 2021
5c05b37
[chang](UMCS-49)
Ryouzanpaku Mar 1, 2021
dedfdc7
[change] (UMCS-49)
Ryouzanpaku Mar 2, 2021
cf22a4e
[change] (UMCS-49)
Ryouzanpaku Mar 2, 2021
de42ce7
[change] (UMCS-49)
Ryouzanpaku Mar 2, 2021
466e35e
[change] (UMCS-49)
Ryouzanpaku Mar 2, 2021
c9bea0e
[change] (UMCS-49)
Ryouzanpaku Mar 2, 2021
30620e8
Update examples/CardExtended/Constants.php
Ryouzanpaku Mar 3, 2021
a5c191d
Update examples/CardExtended/Controller.php
Ryouzanpaku Mar 3, 2021
cf72d51
Merge pull request #26 from unzerdev/UMCS-49/add-email-field-to-example
Ryouzanpaku Mar 3, 2021
744b072
[change] (UMCS-49)
Ryouzanpaku Mar 5, 2021
dc4a742
Merge pull request #27 from unzerdev/UMCS-49/add-email-field-to-example
Ryouzanpaku Mar 8, 2021
3a8b7ce
[change] (UMCS-49) update version 1.1.1.1
Ryouzanpaku Mar 11, 2021
9dc4404
Merge pull request #28 from unzerdev/UMCS-49/add-email-field-to-example
Ryouzanpaku Mar 11, 2021
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
79 changes: 48 additions & 31 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,60 @@ 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).

## [1.1.1.0][1.1.1.0]
## [1.1.1.1]

### Fix
* Change debug logging of failed tests that depend on another one to work as expected.
* PayPal recurring example: Response handling changed to check the recurring status of the payment type.

### Added
* Extended testing for Instalment payment type.
* Cards (extended) example using email UI element.

### Changed
* Remove PhpUnit 8 support.
* Card recurring example using email UI element.
* Card example and paypage examples use a dummy customer-email to ensure they work with 3ds2.
* Several minor changes.

## [1.1.1.0]

### Changed
* Add email property to payment type `card` to meet 3Ds2.x regulations.
* Several minor changes.
* Add email property to payment type `card` to meet 3Ds2.x regulations.
* Several minor changes.

## [1.1.0.0][1.1.0.0]
## [1.1.0.0]

### Changed
* Rebranding of the SDK.
* Removed payment type string from URL when fetching a payment type resource.
* Replace payment methods guaranteed/factoring by secured payment methods, i.e.:
* `InvoiceGuaranteed` and `InvoiceFactoring` replaced by `InvoiceSecured`
* `SepaDirectDebitGuaranteed` replaced by `SepaDirectDebitSecured`
* `HirePurchaseDirectDebit` replaced by `InstallmentSecured`
* Basket is now mandatory for all those payment types above.
* Added mapping of old payment type ids to the new payment type resources.
* Constant in `\UnzerSDK\Constants\ApiResponseCodes` got renamed:
* `API_ERROR_IVF_REQUIRES_CUSTOMER` renamed to `API_ERROR_FACTORING_REQUIRES_CUSTOMER`.
* `API_ERROR_IVF_REQUIRES_BASKET` renamed to `API_ERROR_FACTORING_REQUIRES_BASKET`.
* Several minor changes.
* Rebranding of the SDK.
* Removed payment type string from URL when fetching a payment type resource.
* Replace payment methods guaranteed/factoring by secured payment methods, i.e.:
* `InvoiceGuaranteed` and `InvoiceFactoring` replaced by `InvoiceSecured`
* `SepaDirectDebitGuaranteed` replaced by `SepaDirectDebitSecured`
* `HirePurchaseDirectDebit` replaced by `InstallmentSecured`
* Basket is now mandatory for all those payment types above.
* Added mapping of old payment type ids to the new payment type resources.
* Constant in `\UnzerSDK\Constants\ApiResponseCodes` got renamed:
* `API_ERROR_IVF_REQUIRES_CUSTOMER` renamed to `API_ERROR_FACTORING_REQUIRES_CUSTOMER`.
* `API_ERROR_IVF_REQUIRES_BASKET` renamed to `API_ERROR_FACTORING_REQUIRES_BASKET`.
* Several minor changes.
### Remove
* Remove deprecated methods:
* getAmountTotal
* setAmountTotal
* getCardHolder
* setHolder
* cancel
* cancelAllCharges
* cancelAuthorization
* getResource
* fetchResource
* Remove deprecated constants:
* API_ERROR_AUTHORIZE_ALREADY_CANCELLED
* API_ERROR_CHARGE_ALREADY_CHARGED_BACK
* API_ERROR_BASKET_ITEM_IMAGE_INVALID_EXTENSION
* ENV_VAR_NAME_DISABLE_TEST_LOGGING
* Remove deprecated methods:
* getAmountTotal
* setAmountTotal
* getCardHolder
* setHolder
* cancel
* cancelAllCharges
* cancelAuthorization
* getResource
* fetchResource
* Remove deprecated constants:
* API_ERROR_AUTHORIZE_ALREADY_CANCELLED
* API_ERROR_CHARGE_ALREADY_CHARGED_BACK
* API_ERROR_BASKET_ITEM_IMAGE_INVALID_EXTENSION
* ENV_VAR_NAME_DISABLE_TEST_LOGGING

[1.1.0.0]: https://github.com/unzerdev/php-sdk/compare/1260b8314af1ac461e33f0cfb382ffcd0e87c105..1.1.0.0
[1.1.1.0]: https://github.com/unzerdev/php-sdk/compare/1.1.0.0..1.1.1.0
[1.1.1.1]: https://github.com/unzerdev/php-sdk/compare/1.1.1.0..1.1.1.1
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": ">6.5 <9.0",
"phpunit/phpunit": ">6.5 <8.0",
"friendsofphp/php-cs-fixer": "^2.0"
},
"suggest": {
Expand Down
2 changes: 2 additions & 0 deletions examples/Card/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ function redirect($url, $merchantMessage = '', $clientMessage = '')
// The 3D secured flag can be used to switch between 3ds and non-3ds.
// If your merchant is only configured for one of those you can omit the flag.
$customer = CustomerFactory::createCustomer('Max', 'Mustermann');
$customer->setEmail('test@test.com');

switch ($transactionType) {
case 'charge':
$transaction = $unzer->charge(12.99, 'EUR', $paymentTypeId, RETURN_CONTROLLER_URL, $customer, null, null, null, $use3Ds);
Expand Down
29 changes: 29 additions & 0 deletions examples/CardExtended/Constants.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* This file defines the constants needed for the card extended example.
*
* Copyright (C) 2021 - today Unzer E-Com GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link https://docs.unzer.com/
*
* @author Simon Gabriel <development@unzer.com>
*
* @package UnzerSDK\examples
*/

require_once __DIR__ . '/../Constants.php';

define('EXAMPLE_URL', EXAMPLE_BASE_FOLDER . 'CardExtended');
define('CONTROLLER_URL', EXAMPLE_URL . '/Controller.php');
112 changes: 112 additions & 0 deletions examples/CardExtended/Controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?php
/**
* This is the controller for the Card extended example.
* It is called when the pay button on the index page is clicked.
*
* Copyright (C) 2021 - today Unzer E-Com GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link https://docs.unzer.com/
*
* @author Simon Gabriel <development@unzer.com>
*
* @package UnzerSDK\examples
*/

/** Require the constants of this example */
require_once __DIR__ . '/Constants.php';

/** @noinspection PhpIncludeInspection */
/** Require the composer autoloader file */
require_once __DIR__ . '/../../../../autoload.php';

use UnzerSDK\examples\ExampleDebugHandler;
use UnzerSDK\Exceptions\UnzerApiException;
use UnzerSDK\Unzer;
use UnzerSDK\Resources\CustomerFactory;

session_start();
session_unset();

$clientMessage = 'Something went wrong. Please try again later.';
$merchantMessage = 'Something went wrong. Please try again later.';

function redirect($url, $merchantMessage = '', $clientMessage = '')
{
$_SESSION['merchantMessage'] = $merchantMessage;
$_SESSION['clientMessage'] = $clientMessage;
header('Location: ' . $url);
die();
}

// You will need the id of the payment type created in the frontend (index.php)
if (!isset($_POST['resourceId'])) {
redirect(FAILURE_URL, 'Resource id is missing!', $clientMessage);
}
$paymentTypeId = $_POST['resourceId'];

// These lines are just for this example
$transactionType = $_POST['transaction_type'] ?? 'authorize';

// Catch API errors, write the message to your log and show the ClientMessage to the client.
try {
// Create an Unzer object using your private key and register a debug handler if you want to.
$unzer = new Unzer(UNZER_PAPI_PRIVATE_KEY);
$unzer->setDebugMode(true)->setDebugHandler(new ExampleDebugHandler());

// Create a charge/authorize transaction
// For 3Ds2 compliance an email need to be set either in card type or in customer resource.
// If your merchant is only configured for one of those you can omit the flag.
$customer = CustomerFactory::createCustomer('Max', 'Mustermann');
switch ($transactionType) {
case 'charge':
$transaction = $unzer->charge(12.99, 'EUR', $paymentTypeId, RETURN_CONTROLLER_URL, $customer, null, null, null, true);
break;
case 'payout':
$transaction = $unzer->payout(12.99, 'EUR', $paymentTypeId, RETURN_CONTROLLER_URL, $customer);
break;
default:
$transaction = $unzer->authorize(12.99, 'EUR', $paymentTypeId, RETURN_CONTROLLER_URL, $customer, null, null, null, true);
break;
}

// You'll need to remember the paymentId for later in the ReturnController (in case of 3ds)
$_SESSION['PaymentId'] = $transaction->getPaymentId();
$_SESSION['ShortId'] = $transaction->getShortId();

// Redirect to the 3ds page or to success depending on the state of the transaction
$payment = $transaction->getPayment();
$redirect = !empty($transaction->getRedirectUrl());

switch (true) {
case (!$redirect && $transaction->isSuccess()):
redirect(SUCCESS_URL);
break;
case (!$redirect && $transaction->isPending()):
redirect(PENDING_URL);
break;
case ($redirect && $transaction->isPending()):
redirect($transaction->getRedirectUrl());
break;
}

// Check the result message of the transaction 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);
Loading