Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
70 changes: 37 additions & 33 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,56 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
## [1.1.1.1]

### Fix
* Change debug logging of failed tests that depend on another one to work as expected.
* Several minor changes.
* 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.
* Extended testing for Instalment payment type.
* Cards (extended) example using email UI element.

### Changed
* Remove PhpUnit 8 support.
* 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]

### 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
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 . 'Card');
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