Skip to content

Commit 4184b40

Browse files
authored
Merge pull request #67 from unzerdev/develop
Develop
2 parents 09a3444 + 22b5637 commit 4184b40

File tree

17 files changed

+194
-32
lines changed

17 files changed

+194
-32
lines changed

CHANGELOG.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,18 @@
22
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).
5+
6+
## [1.1.4.2](https://github.com/unzerdev/php-sdk/compare/1.1.4.1..1.1.4.2)
7+
### Added
8+
* Enable PHP 8.1 compatibility.
9+
### Changed
10+
* Fix an issue that can cause an exception when fetching a payment that contained a "cancel-authorize" transaction even though the payment has no authorization transaction.
11+
* Update broken documentation links in readme.
12+
* Several minor improvements.
13+
514
## [1.1.4.1](https://github.com/unzerdev/php-sdk/compare/1.1.4.0..1.1.4.1)
615
### Added
7-
* Added Apple Pay example.
16+
* Added Apple Pay example.
817

918
### Changed
1019
* Adjust `cancelAmount` logic to work properly with Invoice Secured payments.
@@ -17,9 +26,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
1726
* Enable recurrence type to be set for `charge`, `authorize` and `activateRecurringPayment` methods.
1827

1928
### Changed
20-
* Enable recurring examples (card paypal)to trigger subsequent transaction from success page.
21-
* Enable card recurring example to use recurrence type.
22-
* Several minor improvements.
29+
* Enable recurring examples (card paypal)to trigger subsequent transaction from success page.
30+
* Enable card recurring example to use recurrence type.
31+
* Several minor improvements.
2332

2433
## [1.1.3.0](https://github.com/unzerdev/php-sdk/compare/1.1.2.0..1.1.3.0)
2534
### Added
@@ -70,9 +79,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
7079
* Rebranding of the SDK.
7180
* Removed payment type string from URL when fetching a payment type resource.
7281
* Replace payment methods guaranteed/factoring by secured payment methods, i.e.:
73-
* `InvoiceGuaranteed` and `InvoiceFactoring` replaced by `InvoiceSecured`
74-
* `SepaDirectDebitGuaranteed` replaced by `SepaDirectDebitSecured`
75-
* `HirePurchaseDirectDebit` replaced by `InstallmentSecured`
82+
* `InvoiceGuaranteed` and `InvoiceFactoring` replaced by `InvoiceSecured`.
83+
* `SepaDirectDebitGuaranteed` replaced by `SepaDirectDebitSecured`.
84+
* `HirePurchaseDirectDebit` replaced by `InstallmentSecured`.
7685
* Basket is now mandatory for all those payment types above.
7786
* Added mapping of old payment type ids to the new payment type resources.
7887
* Constant in `\UnzerSDK\Constants\ApiResponseCodes` got renamed:

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@
44
[![PHP 7.3](https://img.shields.io/badge/php-7.3-blue.svg)](http://www.php.net)
55
[![PHP 7.4](https://img.shields.io/badge/php-7.4-blue.svg)](http://www.php.net)
66
[![PHP 8.0](https://img.shields.io/badge/php-8.0-blue.svg)](http://www.php.net)
7+
[![PHP 8.1](https://img.shields.io/badge/php-8.1-blue.svg)](http://www.php.net)
78

8-
![Logo](https://dev.unzer.com/wp-content/uploads/2020/09/Unzer__PrimaryLogo_Raspberry_RGB.png)
9+
![Logo](unzer_logo.svg)
910

1011
# Unzer php-sdk
1112
This SDK provides for an easy way to connect to the Unzer Rest API.
1213

1314
Please refer to the following documentation for installation instructions and usage information.
1415

15-
* [API Documentation](https://docs.unzer.com/overview)
16-
* [PHP SDK Documentation](https://docs.unzer.com/integrate/php-sdk)
17-
* [How to use the examples](https://docs.unzer.com/integrate/php-sdk/example-implementations)
18-
* [Debugging](https://docs.unzer.com/integrate/php-sdk/logging-and-debugging)
16+
* [API Documentation](https://docs.unzer.com)
17+
* [PHP SDK Documentation](https://docs.unzer.com/server-side-integration/php-sdk-integration)
18+
* [How to use the examples](https://docs.unzer.com/server-side-integration/php-sdk-integration/php-example-implementation)
19+
* [Debugging](https://docs.unzer.com/server-side-integration/php-sdk-integration/php-error-handling/#debug-log)
1920

2021
## Supported payment types
2122
* Alipay
@@ -53,3 +54,6 @@ For any issues or questions please get in touch with our support team.
5354
### Phone
5455
* DE: [+49 6221 43101-00](tel:+4962214310100)
5556
* AT: [+43 1 513 66 33 669](tel:+4315136633669)
57+
58+
### Twitter
59+
[@UnzerTech](https://twitter.com/UnzerTech)

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"minimum-stability": "stable",
55
"license": "Apache-2.0",
66
"require": {
7-
"php": "~7.1.0|~7.2.0|~7.3.0|~7.4.0|~8.0.0",
7+
"php": "~7.1.0|~7.2.0|~7.3.0|~7.4.0|~8.0.0|~8.1.0",
88
"ext-json": "*"
99
},
1010
"require-dev": {

examples/PayPal/index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
<body style="margin: 70px 70px 0;">
4848
<h3>Example data:</h3>
4949
<ul>
50-
<li>Username: paypal-[email protected]</li>
51-
<li>Password: heidelpay</li>
50+
<li>Username: paypal-[email protected]</li>
51+
<li>Password: unzer1234</li>
5252
</ul>
5353
<strong>Attention:</strong> We recommend to create your own PayPal test account <a href="https://developer.paypal.com" target="_blank">here</a>.
5454

examples/PayPalRecurring/index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
<body style="margin: 70px 70px 0;">
4848
<h3>Example data:</h3>
4949
<ul>
50-
<li>Username: paypal-[email protected]</li>
51-
<li>Password: heidelpay</li>
50+
<li>Username: paypal-[email protected]</li>
51+
<li>Password: unzer1234</li>
5252
</ul>
5353
<strong>Attention:</strong> We recommend to create your own PayPal test account <a href="https://developer.paypal.com" target="_blank">here</a>.
5454

src/Resources/Payment.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -851,15 +851,15 @@ private function updateChargeTransaction($transaction): void
851851
private function updateReversalTransaction($transaction): void
852852
{
853853
$transactionId = IdService::getResourceIdFromUrl($transaction->url, IdStrings::CANCEL);
854-
$authorization = $this->getAuthorization(true);
855-
if (!$authorization instanceof Authorization) {
856-
throw new RuntimeException('The Authorization object can not be found.');
854+
$initialTransaction = $this->getInitialTransaction(true);
855+
if (!$initialTransaction instanceof Authorization && !$initialTransaction instanceof Charge) {
856+
throw new RuntimeException('The initial transaction object (Authorize or Charge) can not be found.');
857857
}
858858

859-
$cancellation = $authorization->getCancellation($transactionId, true);
859+
$cancellation = $initialTransaction->getCancellation($transactionId, true);
860860
if (!$cancellation instanceof Cancellation) {
861861
$cancellation = (new Cancellation())->setPayment($this)->setId($transactionId);
862-
$authorization->addCancellation($cancellation);
862+
$initialTransaction->addCancellation($cancellation);
863863
}
864864

865865
$cancellation->handleResponse($transaction);

src/Resources/Recurring.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525
namespace UnzerSDK\Resources;
2626

27+
use UnzerSDK\Adapter\HttpAdapterInterface;
2728
use UnzerSDK\Traits\HasAdditionalTransactionData;
2829
use UnzerSDK\Traits\HasCustomerMessage;
2930
use UnzerSDK\Traits\HasDate;

src/Resources/TransactionTypes/Shipment.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525
namespace UnzerSDK\Resources\TransactionTypes;
2626

27+
use UnzerSDK\Adapter\HttpAdapterInterface;
2728
use UnzerSDK\Traits\HasInvoiceId;
2829

2930
class Shipment extends AbstractTransactionType

src/Resources/Webhook.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
*/
2525
namespace UnzerSDK\Resources;
2626

27+
use UnzerSDK\Adapter\HttpAdapterInterface;
28+
2729
class Webhook extends AbstractUnzerResource
2830
{
2931
/** @var string $url */

src/Services/HttpService.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,16 @@ public function debugLog(
218218
$authHeader[1] = ValueService::maskValue($authHeader[1]);
219219
$headers['Authorization'] = implode(' ', $authHeader);
220220

221+
// log request
221222
$unzerObj->debugLog($httpMethod . ': ' . $url);
222223
$writingOperations = [HttpAdapterInterface::REQUEST_POST, HttpAdapterInterface::REQUEST_PUT];
223224
$unzerObj->debugLog('Headers: ' . json_encode($headers, JSON_UNESCAPED_SLASHES));
224225
if (in_array($httpMethod, $writingOperations, true)) {
225226
$unzerObj->debugLog('Request: ' . $payload);
226227
}
228+
229+
// log response
230+
$response = $response ?? '';
227231
$unzerObj->debugLog(
228232
'Response: (' . $responseCode . ') ' .
229233
json_encode(json_decode($response, false), JSON_UNESCAPED_SLASHES)

0 commit comments

Comments
 (0)