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 #163 from heidelpay/develop
Browse files Browse the repository at this point in the history
Release Version 1.2.7.0
  • Loading branch information
Simon Gabriel authored Mar 6, 2020
2 parents 0b3ce33 + 04a70d3 commit 8cf1b76
Show file tree
Hide file tree
Showing 25 changed files with 285 additions and 87 deletions.
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ matrix:
env:
- DEPS=HIGH
- LEVEL=UNIT
- name: "php 7.4 (install) - unit"
php: 7.4
env:
- DEPS=NO
- LEVEL=UNIT
- name: "php 7.4 (update) - unit"
php: 7.4
env:
- DEPS=HIGH
- LEVEL=UNIT
cache:
directories:
- $HOME/.composer/cache
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@ 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.7.0][1.2.7.0]

### Added
* Http headers to debug log.
* PID to debug log.
* PHP7.4 support.
* Handles for automatic testing to examples.

### Changed
* Update example implementation for Hire Purchase direct debit payment type (FlexiPay® Rate).
* Write log messages from examples to examples\log\example.log instead of error.log.
* Several minor changes.

### Fix
* Ensure locale strings comply to standard.

## [1.2.6.0][1.2.6.0]

### Added
Expand Down Expand Up @@ -364,3 +380,4 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
[1.2.5.0]: https://github.com/heidelpay/heidelpayPHP/compare/1.2.4.0..1.2.5.0
[1.2.5.1]: https://github.com/heidelpay/heidelpayPHP/compare/1.2.5.0..1.2.5.1
[1.2.6.0]: https://github.com/heidelpay/heidelpayPHP/compare/1.2.5.1..1.2.6.0
[1.2.7.0]: https://github.com/heidelpay/heidelpayPHP/compare/1.2.6.0..1.2.7.0
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[![PHP 7.1](https://img.shields.io/badge/php-7.1-blue.svg)](http://www.php.net)
[![PHP 7.2](https://img.shields.io/badge/php-7.2-blue.svg)](http://www.php.net)
[![PHP 7.3](https://img.shields.io/badge/php-7.3-blue.svg)](http://www.php.net)
[![PHP 7.4](https://img.shields.io/badge/php-7.4-blue.svg)](http://www.php.net)

![Logo](https://dev.heidelpay.com/devHeidelpay_400_180.jpg)

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
}
],
"require": {
"php": "~7.0.0|~7.1.0|~7.2.0|~7.3.0",
"php": "~7.0.0|~7.1.0|~7.2.0|~7.3.0|~7.4.0",
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": "^6.5",
"phpunit/phpunit": ">6.5 <8.0",
"codacy/coverage": "^1.4",
"friendsofphp/php-cs-fixer": "^2.0"
},
Expand Down
8 changes: 6 additions & 2 deletions examples/ExampleDebugHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@

class ExampleDebugHandler implements DebugHandlerInterface
{
const LOG_TYPE_APPEND_TO_FILE = 3;

/**
* {@inheritDoc}
*
* ATTENTION: Please make sure the destination file is writable.
*/
public function log(string $message)
{
// ATTENTION: Uncomment following line to write debug messages to the error log of your web server.
//error_log($message);
/** @noinspection ForgottenDebugOutputInspection */
error_log($message . "\n", self::LOG_TYPE_APPEND_TO_FILE, __DIR__ . '/log/example.log');
}
}
2 changes: 1 addition & 1 deletion examples/Failure.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<!DOCTYPE html>
<html lang="en">
<body>
<h1>Failure</h1>
<h1 id="result">Failure</h1>
<p>
There has been an error completing the payment.
<?php
Expand Down
1 change: 0 additions & 1 deletion examples/HirePurchaseDirectDebit/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ function redirect($url, $merchantMessage = '', $clientMessage = '')

// You'll need to remember the shortId to show it on the success or failure page
$_SESSION['PaymentId'] = $authorize->getPaymentId();
$_SESSION['PDFLink'] = $authorize->getPDFLink();

// Redirect to the success or failure depending on the state of the transaction
if ($authorize->isSuccess()) {
Expand Down
65 changes: 60 additions & 5 deletions examples/HirePurchaseDirectDebit/confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
* @package heidelpayPHP\examples
*/

use heidelpayPHP\examples\ExampleDebugHandler;
use heidelpayPHP\Exceptions\HeidelpayApiException;
use heidelpayPHP\Heidelpay;
use heidelpayPHP\Resources\PaymentTypes\HirePurchaseDirectDebit;

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

Expand All @@ -33,10 +38,45 @@

session_start();

$externalOrderId = $_SESSION['externalOrderId'] ?? 'no external order id provided';
$zgReferenceId = $_SESSION['zgReferenceId'] ?? 'no reference id provided';
$PDFLink = $_SESSION['PDFLink'] ?? 'no link provided';
$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();
}

$paymentId = $_SESSION['PaymentId'] ?? null;
if ($paymentId === null) {
redirect(FAILURE_URL, 'Payment id is missing!', $clientMessage);
}

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

$payment = $heidelpay->fetchPayment($paymentId);

$PDFLink = $payment->getAuthorization()->getPDFLink();
/** @var HirePurchaseDirectDebit $type */
$type = $payment->getPaymentType();
$totalAmount = $type->getTotalAmount();
$totalPurchaseAmount = $type->getTotalPurchaseAmount();
$totalInterestAmount = $type->getTotalInterestAmount();
$currency = $payment->getAmount()->getCurrency();
} catch (HeidelpayApiException $e) {
$merchantMessage = $e->getMerchantMessage();
$clientMessage = $e->getClientMessage();
redirect(FAILURE_URL, $merchantMessage, $clientMessage);
} catch (RuntimeException $e) {
$merchantMessage = $e->getMessage();
redirect(FAILURE_URL, $merchantMessage, $clientMessage);
}
?>

<!DOCTYPE html>
Expand All @@ -52,7 +92,6 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.1/semantic.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.1/semantic.min.css" />


</head>

<body style="margin: 70px 70px 0;">
Expand All @@ -68,10 +107,26 @@
</div>

<div class="ui container">
<div class="ui attached right aligned segment">
<div class="ui label">
Total Purchase Amount
<div id="total_purchase_amount" class="detail"><?php echo number_format($totalPurchaseAmount, 2) . ' ' . $currency; ?></div>
</div>
<div class="ui hidden fitted divider"></div>
<div class="ui label">
Total Interest Amount
<div id="total_interest_amount" class="detail"><?php echo number_format($totalInterestAmount, 2) . ' ' . $currency; ?></div>
</div>
<div class="ui hidden fitted divider"></div>
<div class="ui label">
Total Amount
<div id="total_amount" class="detail"><?php echo number_format($totalAmount, 2) . ' ' . $currency; ?></div>
</div>
</div>
<div class="ui attached segment">
<strong>Please download your rate plan <a href="<?php echo (string)($PDFLink); ?>">here</a></strong><br/>
</div>
<div class="ui bottom attached primary button" tabindex="0" onclick="location.href='PlaceOrderController.php'">Place order</div>
<div id="place_order" class="ui bottom attached primary button" tabindex="0" onclick="location.href='PlaceOrderController.php'">Place order</div>
</div>

</body>
Expand Down
8 changes: 3 additions & 5 deletions examples/HirePurchaseDirectDebit/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>
Heidelpay UI Examples
</title>
<meta charset="UTF-8"/>
<title>Heidelpay UI Examples</title>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>

<link rel="stylesheet" href="https://static.heidelpay.com/v1/heidelpay.css" />
<link rel="stylesheet" href="https://static.heidelpay.com/v1/heidelpay.css"/>
<script type="text/javascript" src="https://static.heidelpay.com/v1/heidelpay.js"></script>
</head>

Expand Down
2 changes: 1 addition & 1 deletion examples/Pending.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<!DOCTYPE html>
<html lang="en">
<body>
<h1>Pending</h1>
<h1 id="result">Pending</h1>
<p>
The payment transaction has been completed, however the payment is pending.<br>
In some cases (e. g. authorization transaction or invoice payments) this is normal.<br>
Expand Down
2 changes: 1 addition & 1 deletion examples/Success.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<!DOCTYPE html>
<html lang="en">
<body>
<h1>Success</h1>
<h1 id="result">Success</h1>
<p>
The payment has been successfully completed.
<?php
Expand Down
Loading

0 comments on commit 8cf1b76

Please sign in to comment.