Skip to content

Commit 39d4317

Browse files
authored
Merge pull request #29 from unzerdev/develop
Release 1.1.1.1
2 parents 309f63b + 9dc4404 commit 39d4317

File tree

19 files changed

+583
-44
lines changed

19 files changed

+583
-44
lines changed

CHANGELOG.md

Lines changed: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,60 @@ All notable changes to this project will be documented in this file.
33

44
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).
55

6-
## [1.1.1.0][1.1.1.0]
6+
## [1.1.1.1]
7+
8+
### Fix
9+
* Change debug logging of failed tests that depend on another one to work as expected.
10+
* PayPal recurring example: Response handling changed to check the recurring status of the payment type.
11+
12+
### Added
13+
* Extended testing for Instalment payment type.
14+
* Cards (extended) example using email UI element.
15+
16+
### Changed
17+
* Remove PhpUnit 8 support.
18+
* Card recurring example using email UI element.
19+
* Card example and paypage examples use a dummy customer-email to ensure they work with 3ds2.
20+
* Several minor changes.
21+
22+
## [1.1.1.0]
723

824
### Changed
9-
* Add email property to payment type `card` to meet 3Ds2.x regulations.
10-
* Several minor changes.
25+
* Add email property to payment type `card` to meet 3Ds2.x regulations.
26+
* Several minor changes.
1127

12-
## [1.1.0.0][1.1.0.0]
28+
## [1.1.0.0]
1329

1430
### Changed
15-
* Rebranding of the SDK.
16-
* Removed payment type string from URL when fetching a payment type resource.
17-
* Replace payment methods guaranteed/factoring by secured payment methods, i.e.:
18-
* `InvoiceGuaranteed` and `InvoiceFactoring` replaced by `InvoiceSecured`
19-
* `SepaDirectDebitGuaranteed` replaced by `SepaDirectDebitSecured`
20-
* `HirePurchaseDirectDebit` replaced by `InstallmentSecured`
21-
* Basket is now mandatory for all those payment types above.
22-
* Added mapping of old payment type ids to the new payment type resources.
23-
* Constant in `\UnzerSDK\Constants\ApiResponseCodes` got renamed:
24-
* `API_ERROR_IVF_REQUIRES_CUSTOMER` renamed to `API_ERROR_FACTORING_REQUIRES_CUSTOMER`.
25-
* `API_ERROR_IVF_REQUIRES_BASKET` renamed to `API_ERROR_FACTORING_REQUIRES_BASKET`.
26-
* Several minor changes.
31+
* Rebranding of the SDK.
32+
* Removed payment type string from URL when fetching a payment type resource.
33+
* Replace payment methods guaranteed/factoring by secured payment methods, i.e.:
34+
* `InvoiceGuaranteed` and `InvoiceFactoring` replaced by `InvoiceSecured`
35+
* `SepaDirectDebitGuaranteed` replaced by `SepaDirectDebitSecured`
36+
* `HirePurchaseDirectDebit` replaced by `InstallmentSecured`
37+
* Basket is now mandatory for all those payment types above.
38+
* Added mapping of old payment type ids to the new payment type resources.
39+
* Constant in `\UnzerSDK\Constants\ApiResponseCodes` got renamed:
40+
* `API_ERROR_IVF_REQUIRES_CUSTOMER` renamed to `API_ERROR_FACTORING_REQUIRES_CUSTOMER`.
41+
* `API_ERROR_IVF_REQUIRES_BASKET` renamed to `API_ERROR_FACTORING_REQUIRES_BASKET`.
42+
* Several minor changes.
2743
### Remove
28-
* Remove deprecated methods:
29-
* getAmountTotal
30-
* setAmountTotal
31-
* getCardHolder
32-
* setHolder
33-
* cancel
34-
* cancelAllCharges
35-
* cancelAuthorization
36-
* getResource
37-
* fetchResource
38-
* Remove deprecated constants:
39-
* API_ERROR_AUTHORIZE_ALREADY_CANCELLED
40-
* API_ERROR_CHARGE_ALREADY_CHARGED_BACK
41-
* API_ERROR_BASKET_ITEM_IMAGE_INVALID_EXTENSION
42-
* ENV_VAR_NAME_DISABLE_TEST_LOGGING
44+
* Remove deprecated methods:
45+
* getAmountTotal
46+
* setAmountTotal
47+
* getCardHolder
48+
* setHolder
49+
* cancel
50+
* cancelAllCharges
51+
* cancelAuthorization
52+
* getResource
53+
* fetchResource
54+
* Remove deprecated constants:
55+
* API_ERROR_AUTHORIZE_ALREADY_CANCELLED
56+
* API_ERROR_CHARGE_ALREADY_CHARGED_BACK
57+
* API_ERROR_BASKET_ITEM_IMAGE_INVALID_EXTENSION
58+
* ENV_VAR_NAME_DISABLE_TEST_LOGGING
4359

4460
[1.1.0.0]: https://github.com/unzerdev/php-sdk/compare/1260b8314af1ac461e33f0cfb382ffcd0e87c105..1.1.0.0
4561
[1.1.1.0]: https://github.com/unzerdev/php-sdk/compare/1.1.0.0..1.1.1.0
62+
[1.1.1.1]: https://github.com/unzerdev/php-sdk/compare/1.1.1.0..1.1.1.1

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"ext-json": "*"
99
},
1010
"require-dev": {
11-
"phpunit/phpunit": ">6.5 <9.0",
11+
"phpunit/phpunit": ">6.5 <8.0",
1212
"friendsofphp/php-cs-fixer": "^2.0"
1313
},
1414
"suggest": {

examples/Card/Controller.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ function redirect($url, $merchantMessage = '', $clientMessage = '')
7070
// The 3D secured flag can be used to switch between 3ds and non-3ds.
7171
// If your merchant is only configured for one of those you can omit the flag.
7272
$customer = CustomerFactory::createCustomer('Max', 'Mustermann');
73+
$customer->setEmail('[email protected]');
74+
7375
switch ($transactionType) {
7476
case 'charge':
7577
$transaction = $unzer->charge(12.99, 'EUR', $paymentTypeId, RETURN_CONTROLLER_URL, $customer, null, null, null, $use3Ds);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* This file defines the constants needed for the card extended example.
4+
*
5+
* Copyright (C) 2021 - today Unzer E-Com GmbH
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*
19+
* @link https://docs.unzer.com/
20+
*
21+
* @author Simon Gabriel <[email protected]>
22+
*
23+
* @package UnzerSDK\examples
24+
*/
25+
26+
require_once __DIR__ . '/../Constants.php';
27+
28+
define('EXAMPLE_URL', EXAMPLE_BASE_FOLDER . 'CardExtended');
29+
define('CONTROLLER_URL', EXAMPLE_URL . '/Controller.php');
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<?php
2+
/**
3+
* This is the controller for the Card extended example.
4+
* It is called when the pay button on the index page is clicked.
5+
*
6+
* Copyright (C) 2021 - today Unzer E-Com GmbH
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*
20+
* @link https://docs.unzer.com/
21+
*
22+
* @author Simon Gabriel <[email protected]>
23+
*
24+
* @package UnzerSDK\examples
25+
*/
26+
27+
/** Require the constants of this example */
28+
require_once __DIR__ . '/Constants.php';
29+
30+
/** @noinspection PhpIncludeInspection */
31+
/** Require the composer autoloader file */
32+
require_once __DIR__ . '/../../../../autoload.php';
33+
34+
use UnzerSDK\examples\ExampleDebugHandler;
35+
use UnzerSDK\Exceptions\UnzerApiException;
36+
use UnzerSDK\Unzer;
37+
use UnzerSDK\Resources\CustomerFactory;
38+
39+
session_start();
40+
session_unset();
41+
42+
$clientMessage = 'Something went wrong. Please try again later.';
43+
$merchantMessage = 'Something went wrong. Please try again later.';
44+
45+
function redirect($url, $merchantMessage = '', $clientMessage = '')
46+
{
47+
$_SESSION['merchantMessage'] = $merchantMessage;
48+
$_SESSION['clientMessage'] = $clientMessage;
49+
header('Location: ' . $url);
50+
die();
51+
}
52+
53+
// You will need the id of the payment type created in the frontend (index.php)
54+
if (!isset($_POST['resourceId'])) {
55+
redirect(FAILURE_URL, 'Resource id is missing!', $clientMessage);
56+
}
57+
$paymentTypeId = $_POST['resourceId'];
58+
59+
// These lines are just for this example
60+
$transactionType = $_POST['transaction_type'] ?? 'authorize';
61+
62+
// Catch API errors, write the message to your log and show the ClientMessage to the client.
63+
try {
64+
// Create an Unzer object using your private key and register a debug handler if you want to.
65+
$unzer = new Unzer(UNZER_PAPI_PRIVATE_KEY);
66+
$unzer->setDebugMode(true)->setDebugHandler(new ExampleDebugHandler());
67+
68+
// Create a charge/authorize transaction
69+
// For 3Ds2 compliance an email need to be set either in card type or in customer resource.
70+
// If your merchant is only configured for one of those you can omit the flag.
71+
$customer = CustomerFactory::createCustomer('Max', 'Mustermann');
72+
switch ($transactionType) {
73+
case 'charge':
74+
$transaction = $unzer->charge(12.99, 'EUR', $paymentTypeId, RETURN_CONTROLLER_URL, $customer, null, null, null, true);
75+
break;
76+
case 'payout':
77+
$transaction = $unzer->payout(12.99, 'EUR', $paymentTypeId, RETURN_CONTROLLER_URL, $customer);
78+
break;
79+
default:
80+
$transaction = $unzer->authorize(12.99, 'EUR', $paymentTypeId, RETURN_CONTROLLER_URL, $customer, null, null, null, true);
81+
break;
82+
}
83+
84+
// You'll need to remember the paymentId for later in the ReturnController (in case of 3ds)
85+
$_SESSION['PaymentId'] = $transaction->getPaymentId();
86+
$_SESSION['ShortId'] = $transaction->getShortId();
87+
88+
// Redirect to the 3ds page or to success depending on the state of the transaction
89+
$payment = $transaction->getPayment();
90+
$redirect = !empty($transaction->getRedirectUrl());
91+
92+
switch (true) {
93+
case (!$redirect && $transaction->isSuccess()):
94+
redirect(SUCCESS_URL);
95+
break;
96+
case (!$redirect && $transaction->isPending()):
97+
redirect(PENDING_URL);
98+
break;
99+
case ($redirect && $transaction->isPending()):
100+
redirect($transaction->getRedirectUrl());
101+
break;
102+
}
103+
104+
// Check the result message of the transaction to find out what went wrong.
105+
$merchantMessage = $transaction->getMessage()->getCustomer();
106+
} catch (UnzerApiException $e) {
107+
$merchantMessage = $e->getMerchantMessage();
108+
$clientMessage = $e->getClientMessage();
109+
} catch (RuntimeException $e) {
110+
$merchantMessage = $e->getMessage();
111+
}
112+
redirect(FAILURE_URL, $merchantMessage, $clientMessage);

0 commit comments

Comments
 (0)