Skip to content
This repository has been archived by the owner on Mar 29, 2022. It is now read-only.

Commit

Permalink
Merge pull request #141 from heidelpay/develop
Browse files Browse the repository at this point in the history
Release 1.2.5.0
  • Loading branch information
Simon Gabriel authored Nov 19, 2019
2 parents 156cd52 + da1c735 commit 4dd38c0
Show file tree
Hide file tree
Showing 151 changed files with 4,200 additions and 638 deletions.
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,32 @@ 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.2.5.0][1.2.5.0]

### Added
* Hire purchase direct debit payment type (FlexiPay Rate) including example implementation.
* Additional parameters from payment type to transactions.
* Facade method to update payment type.
* Property invoiceId to `Payment` class.
* Added card details to `Card` payment type.
* Property `card3ds` to `Paypage`.
* Geolocation to `Customer` resource.
* Property `effectiveInterestRate` to `PayPage` to enable `HirePurchase` payment types.

### Changed
* Refactor invoice guaranteed tests to make them independent from each other.
* Response Code for basket item image extension error has been deprecated since it has been removed from the API.
* Refactored cancellation feature to support FlexiPay Rate cancel.
* Remove trailing slash from routes.
* Float values are now rounded with 4 decimal places when exposed to the API. The value of the local object will be updated as well.

### Removed
* Unused Constants.
* Obsolete/dead code.

### Fixed
* Several minor issues.

## [1.2.4.0][1.2.4.0]

### Added
Expand Down Expand Up @@ -305,3 +331,4 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
[1.2.2.0]: https://github.com/heidelpay/heidelpayPHP/compare/1.2.1.0..1.2.2.0
[1.2.3.0]: https://github.com/heidelpay/heidelpayPHP/compare/1.2.2.0..1.2.3.0
[1.2.4.0]: https://github.com/heidelpay/heidelpayPHP/compare/1.2.3.0..1.2.4.0
[1.2.5.0]: https://github.com/heidelpay/heidelpayPHP/compare/1.2.4.0..1.2.5.0
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ Please refer to the following documentation for installation instructions and us
* SEPA direct debit (guaranteed)
* SOFORT
* EPS
* FlexiPay direct (PIS)
* FlexiPay Direct (PIS)
* Alipay
* WeChat Pay
* Invoice Factoring
* FlexiPay Rate (Hire Purchase Direct Debit)

## Supported features
* Webhooks and event handling
Expand Down
1 change: 0 additions & 1 deletion examples/Alipay/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

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

define('EXAMPLE_PATH', __DIR__);
define('EXAMPLE_URL', EXAMPLE_BASE_FOLDER . 'Alipay');
define('CONTROLLER_URL', EXAMPLE_URL . '/Controller.php');
define('RETURN_CONTROLLER_URL', EXAMPLE_URL . '/ReturnController.php');
1 change: 0 additions & 1 deletion examples/Card/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

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

define('EXAMPLE_PATH', __DIR__);
define('EXAMPLE_URL', EXAMPLE_BASE_FOLDER . 'Card');
define('CONTROLLER_URL', EXAMPLE_URL . '/Controller.php');
define('RETURN_CONTROLLER_URL', EXAMPLE_URL . '/ReturnController.php');
21 changes: 13 additions & 8 deletions examples/Card/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,19 @@ function redirect($url, $merchantMessage = '', $clientMessage = '')
$_SESSION['ShortId'] = $transaction->getShortId();

// Redirect to the 3ds page or to success depending on the state of the transaction
$payment = $transaction->getPayment();
$noRedirect = empty($transaction->getRedirectUrl());
if ($noRedirect && $payment->isCompleted()) {
redirect(SUCCESS_URL);
} elseif ($noRedirect && $payment->isPending()) {
redirect(PENDING_URL);
} elseif (!$noRedirect && $payment->isPending()) {
redirect($transaction->getRedirectUrl());
$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.
Expand Down
1 change: 0 additions & 1 deletion examples/CardRecurring/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

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

define('EXAMPLE_PATH', __DIR__);
define('EXAMPLE_URL', EXAMPLE_BASE_FOLDER . 'CardRecurring');
define('CONTROLLER_URL', EXAMPLE_URL . '/Controller.php');
define('RETURN_CONTROLLER_URL', EXAMPLE_URL . '/ReturnController.php');
5 changes: 3 additions & 2 deletions examples/CardRecurring/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ function redirect($url, $merchantMessage = '', $clientMessage = '')
$_SESSION['ShortId'] = $recurring->getShortId();

// Redirect to the 3ds page or to success depending on the state of the transaction
if (empty($recurring->getRedirectUrl()) && $recurring->isSuccess()) {
$redirect = !empty($recurring->getRedirectUrl());
if (!$redirect && $recurring->isSuccess()) {
redirect(SUCCESS_URL);
} elseif (!empty($recurring->getRedirectUrl()) && $recurring->isPending()) {
} elseif ($redirect && $recurring->isPending()) {
redirect($recurring->getRedirectUrl());
}

Expand Down
10 changes: 8 additions & 2 deletions examples/CardRecurring/ReturnController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,17 @@ function redirect($url, $merchantMessage = '', $clientMessage = '')
$heidelpay->setDebugMode(true)->setDebugHandler(new ExampleDebugHandler());

// Redirect to success if the payment has been successfully completed or is still in handled.
/** @var Card $paymentType */
$paymentType = $heidelpay->fetchPaymentType($paymentTypeId);

if ($paymentType instanceof Card && $paymentType->isRecurring()) {
redirect(SUCCESS_URL);
switch (true) {
case $paymentType->isRecurring():
redirect(SUCCESS_URL);
break;
default:
break;
}

} catch (HeidelpayApiException $e) {
$merchantMessage = $e->getMerchantMessage();
$clientMessage = $e->getClientMessage();
Expand Down
3 changes: 0 additions & 3 deletions examples/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,3 @@
define('SUCCESS_URL', EXAMPLE_BASE_FOLDER . 'Success.php');
define('PENDING_URL', EXAMPLE_BASE_FOLDER . 'Pending.php');
define('FAILURE_URL', EXAMPLE_BASE_FOLDER . 'Failure.php');
define('WEBHOOK_CONTROLLER_URL', EXAMPLE_BASE_FOLDER . 'Webhooks/WebhookController.php');
define('DEFAULT_PRIVATE_KEY', 's-priv-2a102ZMq3gV4I3zJ888J7RR6u75oqK3n');
define('DEFAULT_PUBLIC_KEY', 's-pub-2a10ifVINFAjpQJ9qW8jBe5OJPBx6Gxa');
1 change: 0 additions & 1 deletion examples/EPSCharge/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

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

define('EXAMPLE_PATH', __DIR__);
define('EXAMPLE_URL', EXAMPLE_BASE_FOLDER . 'EPSCharge');
define('CONTROLLER_URL', EXAMPLE_URL . '/Controller.php');
define('RETURN_CONTROLLER_URL', EXAMPLE_URL . '/ReturnController.php');
1 change: 0 additions & 1 deletion examples/EmbeddedPayPage/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

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

define('EXAMPLE_PATH', __DIR__);
define('EXAMPLE_URL', EXAMPLE_BASE_FOLDER . 'EmbeddedPayPage');
define('CONTROLLER_URL', EXAMPLE_URL . '/Controller.php');
define('RETURN_CONTROLLER_URL', EXAMPLE_URL . '/ReturnController.php');
24 changes: 13 additions & 11 deletions examples/EmbeddedPayPage/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
use heidelpayPHP\examples\ExampleDebugHandler;
use heidelpayPHP\Exceptions\HeidelpayApiException;
use heidelpayPHP\Heidelpay;
use heidelpayPHP\Resources\Basket;
use heidelpayPHP\Resources\CustomerFactory;
use heidelpayPHP\Resources\EmbeddedResources\BasketItem;
use heidelpayPHP\Resources\PaymentTypes\Paypage;

// start new session for this example and remove all parameters
Expand All @@ -46,14 +48,6 @@
$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();
}

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

Expand All @@ -67,7 +61,7 @@ function redirect($url, $merchantMessage = '', $clientMessage = '')
$customer = CustomerFactory::createCustomer('Max', 'Mustermann');

// These are the mandatory parameters for the payment page ...
$paypage = new Paypage(12.99, 'EUR', RETURN_CONTROLLER_URL);
$paypage = new Paypage(119.00, 'EUR', RETURN_CONTROLLER_URL);

// ... however you can customize the Payment Page using additional parameters.
$paypage->setLogoImage('https://dev.heidelpay.com/devHeidelpay_400_180.jpg')
Expand All @@ -76,10 +70,18 @@ function redirect($url, $merchantMessage = '', $clientMessage = '')
->setOrderId('OrderNr' . microtime(true))
->setInvoiceId('InvoiceNr' . microtime(true));

// ... in order to enable FlexiPay Rate (Hire Purchase) you will need to set the effectiveInterestRate as well.
$paypage->setEffectiveInterestRate(4.99);

// ... a Basket is mandatory for HirePurchase
$orderId = str_replace(['0.', ' '], '', microtime(false));
$basketItem = new BasketItem('Hat', 100.0, 119.0, 1);
$basket = new Basket($orderId, 119.0, 'EUR', [$basketItem]);

if ($transactionType === 'charge') {
$heidelpay->initPayPageCharge($paypage, $customer);
$heidelpay->initPayPageCharge($paypage, $customer, $basket);
} else {
$heidelpay->initPayPageAuthorize($paypage, $customer);
$heidelpay->initPayPageAuthorize($paypage, $customer, $basket);
}

$_SESSION['PaymentId'] = $paypage->getPaymentId();
Expand Down
3 changes: 3 additions & 0 deletions examples/Failure.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
if (isset($_SESSION['ShortId']) && !empty($_SESSION['ShortId'])) {
echo '<p>Please look for ShortId ' . $_SESSION['ShortId'] . ' in hIP (heidelpay Intelligence Platform) to see the transaction.</p>';
}
if (isset($_SESSION['PaymentId']) && !empty($_SESSION['PaymentId'])) {
echo '<p>The PaymentId of your transaction is \'' . $_SESSION['PaymentId'] . '\'.</p>';
}
?>
</p>
<p><a href=".">start again</a></p>
Expand Down
1 change: 0 additions & 1 deletion examples/FlexiPayDirect/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

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

define('EXAMPLE_PATH', __DIR__);
define('EXAMPLE_URL', EXAMPLE_BASE_FOLDER . 'FlexiPayDirect');
define('CONTROLLER_URL', EXAMPLE_URL . '/Controller.php');
define('RETURN_CONTROLLER_URL', EXAMPLE_URL . '/ReturnController.php');
4 changes: 2 additions & 2 deletions examples/FlexiPayDirect/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@
// Create a heidelpay instance with your public key
let heidelpayInstance = new heidelpay('<?php echo HEIDELPAY_PHP_PAYMENT_API_PUBLIC_KEY; ?>');

// Create an Flexipay instance
// Create an FlexiPay Direct instance
let flexiPayDirect = heidelpayInstance.FlexiPayDirect();

// Handle payment form submission
let form = document.getElementById('payment-form');
form.addEventListener('submit', function(event) {
event.preventDefault();
// Creating a Flexipay resource
// Creating a FlexiPay Direct resource
flexiPayDirect.createResource()
.then(function(result) {
let hiddenInput = document.createElement('input');
Expand Down
1 change: 0 additions & 1 deletion examples/Giropay/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

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

define('EXAMPLE_PATH', __DIR__);
define('EXAMPLE_URL', EXAMPLE_BASE_FOLDER . 'Giropay');
define('CONTROLLER_URL', EXAMPLE_URL . '/Controller.php');
define('RETURN_CONTROLLER_URL', EXAMPLE_URL . '/ReturnController.php');
30 changes: 30 additions & 0 deletions examples/HirePurchaseDirectDebit/Constants.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* This file defines the constants needed for the hire purchase direct debit example.
*
* Copyright (C) 2019 heidelpay 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.heidelpay.com/
*
* @author Simon Gabriel <development@heidelpay.com>
*
* @package heidelpayPHP/examples
*/

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

define('EXAMPLE_URL', EXAMPLE_BASE_FOLDER . 'HirePurchaseDirectDebit');
define('CONTROLLER_URL', EXAMPLE_URL . '/Controller.php');
define('CONFIRM_URL', EXAMPLE_URL . '/confirm.php');
Loading

0 comments on commit 4dd38c0

Please sign in to comment.