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

Commit

Permalink
Release 1.2.7.2 (#179)
Browse files Browse the repository at this point in the history
* [change] (PHPLIB-209) Add traceId to transactions and payment.

* [Change] (PHPLIB-209) Fix several style issues.

* [change] (PHPLIB-209) Add traceId tests.

* [change] (PHPLIB-209) Update unit tests for traceId.

* [change] (PHPLIB-209) Update changelog and version.

* [change] (PHPLIB-209) Update CHANGELOG.md

* [change] (PHPLIB-209) Fix tests.

* Update src/Heidelpay.php

Co-Authored-By: David Owusu <[email protected]>

* Merge remote-tracking branch 'remotes/github/develop' into bugfix/PHPLIB-309/renaming-cc-holder-to-cardHolder (#171)

* [bugfix] (PHPLIB-309) Rename Cards holder to cardHolder.

* [change] (PHPLIB-209) Fix tests add update version and CHANGELOG.md

* [change] (PHPLIB-309) Update test.

* [change] (PHPLIB-309) Update unit test.

* [change] (PHPLIB-309) Add unit tests to verify deprecated getter/setter.

* [change] (PHPLIB-309) Add integration test to verify deprecated getter/setter.

Co-authored-by: sixer1182 <[email protected]>

* [change] (PHPLIB-318) Refactor tests to fit latest API changes. (#176)

Co-authored-by: sixer1182 <[email protected]>

* [change] (PHPLIB-300) Add description. (#172)

Co-authored-by: sixer1182 <[email protected]>

* [change] (PHPLIB-307) Add email field to PayPal example. (#173)

Co-authored-by: sixer1182 <[email protected]>

* change/PHPLIB-187/add-geolocation-to-card (#174)

* [bugfix] (PHPLIB-309) Rename Cards holder to cardHolder.

* [change] (PHPLIB-209) Fix tests add update version and CHANGELOG.md

* [change] (PHPLIB-309) Update test.

* [change] (PHPLIB-309) Update unit test.

* [refactor] (PHPLIB-187) Geolocation: Move geolocation to trait.

* [refactor] (PHPLIB-187) Geolocation: Add geolocation to card class.

* [change] (PHPLIB-187) Fix styles.

* [change] (PHPLIB-187) Update CHANGELOG.md

* [change] (PHPLIB-187) Remove dead "code"

* [change] (PHPLIB-187) Fix examples: Fix ids due to api changes.

* [change] (PHPLIB-187) Fix examples: Fix ids due to api changes.

Co-authored-by: sixer1182 <[email protected]>

* change/PHPLIB-304/update-webhook-support (#175)

* [bugfix] (PHPLIB-309) Rename Cards holder to cardHolder.

* [change] (PHPLIB-209) Fix tests add update version and CHANGELOG.md

* [change] (PHPLIB-309) Update test.

* [change] (PHPLIB-309) Update unit test.

* [change] (PHPLIB-304) Update webhook events.

* [change] (PHPLIB-304) Fix tests: Fix ids due to api changes.

Co-authored-by: sixer1182 <[email protected]>

* change/PHPLIB-323/Update-errorcodes (#177)

* [change] (PHPLIB-323) Update respons codes due to API changes.

* [change] (PHPLIB-323) Update CHANGELOG.md

* [change] (PHPLIB-323) Update respons codes due to API changes.

* [change] (PHPLIB-323) Update respons codes due to API changes.

Co-authored-by: sixer1182 <[email protected]>

* bugfix/PHPLIB-319/auth-has-empty-cancel-obj-when-payment-is-cancelled (#178)

* [change] (PHPLIB-318) Refactor tests to fit latest API changes.

* [change] (PHPLIB-323) Update respons codes due to API changes.

* [change] (PHPLIB-323) Update CHANGELOG.md

* [change] (PHPLIB-323) Update respons codes due to API changes.

* [change] (PHPLIB-323) Update respons codes due to API changes.

* [change] (PHPLIB-319) Do not add cancellation to authorization if it fails.

* [refactor] (PHPLIB-319) Replace type hinting.

* [refactor] (PHPLIB-319) Avoid adding the cancellation object twice.

* [refactor] (PHPLIB-319) Update CHANGELOG.md

* [refactor] (PHPLIB-319) Fix unit test.

* [refactor] (PHPLIB-319) Fix CHANGELOG.md

Co-authored-by: sixer1182 <[email protected]>

Co-authored-by: sixer1182 <[email protected]>
Co-authored-by: David Owusu <[email protected]>
  • Loading branch information
3 people authored May 18, 2020
1 parent 379d1df commit 202da52
Show file tree
Hide file tree
Showing 47 changed files with 519 additions and 142 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@ 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.2][1.2.7.2]

### Fix
* Rename Cards property holder to cardHolder.
* Add cancellation object to authorization only if cancellation has been successful.

### Change
* Fix some minor issues.
* Refactor tests due to API changes.
* Update response codes due to API changes.

### Added
* TraceId property to payment and transactions.
* Email form field to PayPal example.
* Description to zgReferenceId setter/getter.
* Added geolocation to Card resource.
* Payout webhook events.

## [1.2.7.1][1.2.7.1]

### Added
Expand Down Expand Up @@ -394,3 +412,4 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
[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.2.7.1]: https://github.com/heidelpay/heidelpayPHP/compare/1.2.7.0..1.2.7.1
[1.2.7.2]: https://github.com/heidelpay/heidelpayPHP/compare/1.2.7.1..1.2.7.2
6 changes: 3 additions & 3 deletions examples/EmbeddedPayPage/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@
$paypage->setLogoImage('https://dev.heidelpay.com/devHeidelpay_400_180.jpg')
->setShopName('My Test Shop')
->setTagline('Try and stop us from being awesome!')
->setOrderId('OrderNr' . microtime(true))
->setInvoiceId('InvoiceNr' . microtime(true));
->setOrderId('o' . microtime(true))
->setInvoiceId('i' . 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));
$orderId = 'o' . str_replace(['0.', ' '], '', microtime(false));
$basketItem = new BasketItem('Hat', 100.0, 119.0, 1);
$basket = new Basket($orderId, 119.0, 'EUR', [$basketItem]);

Expand Down
2 changes: 1 addition & 1 deletion examples/HirePurchaseDirectDebit/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function redirect($url, $merchantMessage = '', $clientMessage = '')
$heidelpay->setDebugMode(true)->setDebugHandler(new ExampleDebugHandler());

// Use the quote or order id from your shop
$orderId = str_replace(['0.', ' '], '', microtime(false));
$orderId = 'o' . str_replace(['0.', ' '], '', microtime(false));

/** @var HirePurchaseDirectDebit $paymentType */
$paymentType = $heidelpay->fetchPaymentType($paymentTypeId);
Expand Down
4 changes: 2 additions & 2 deletions examples/HostedPayPage/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function redirect($url, $merchantMessage = '', $clientMessage = '')
// These are the mandatory parameters for the payment page ...
$paypage = new Paypage(119.0, 'EUR', RETURN_CONTROLLER_URL);

$orderId = str_replace(['0.', ' '], '', microtime(false));
$orderId = 'o' . str_replace(['0.', ' '], '', microtime(false));

// ... however you can customize the Payment Page using additional parameters.
$paypage->setLogoImage('https://dev.heidelpay.com/devHeidelpay_400_180.jpg')
Expand All @@ -82,7 +82,7 @@ function redirect($url, $merchantMessage = '', $clientMessage = '')
->setImprintUrl('https://www.heidelpay.com/it/')
->setHelpUrl('https://www.heidelpay.com/at/')
->setContactUrl('https://www.heidelpay.com/en/about-us/about-heidelpay/')
->setInvoiceId('InvoiceNr' . microtime(true));
->setInvoiceId('i' . microtime(true));

// ... in order to enable FlexiPay Rate (Hire Purchase) you will need to set the effectiveInterestRate as well.
$paypage->setEffectiveInterestRate(4.99);
Expand Down
2 changes: 1 addition & 1 deletion examples/Invoice/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function redirect($url, $merchantMessage = '', $clientMessage = '')
$invoice = $heidelpay->createPaymentType(new Invoice());

$customer = CustomerFactory::createCustomer('Max', 'Mustermann');
$orderId = str_replace(['0.', ' '], '', microtime(false));
$orderId = 'o' . str_replace(['0.', ' '], '', microtime(false));

$transaction = $invoice->charge(12.99, 'EUR', CONTROLLER_URL, $customer, $orderId);

Expand Down
2 changes: 1 addition & 1 deletion examples/InvoiceFactoring/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function redirect($url, $merchantMessage = '', $clientMessage = '')
->setCountry('DE');
$customer->setBirthDate('2000-02-12')->setBillingAddress($address)->setShippingAddress($address);

$orderId = str_replace(['0.', ' '], '', microtime(false));
$orderId = 'o' . str_replace(['0.', ' '], '', microtime(false));

// A Basket is mandatory for Invoice Factoring payment type
$basketItem = new BasketItem('Hat', 100.0, 119.0, 1);
Expand Down
2 changes: 1 addition & 1 deletion examples/InvoiceGuaranteed/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function redirect($url, $merchantMessage = '', $clientMessage = '')
$heidelpay = new Heidelpay(HEIDELPAY_PHP_PAYMENT_API_PRIVATE_KEY);
$heidelpay->setDebugMode(true)->setDebugHandler(new ExampleDebugHandler());

$orderId = str_replace(['0.', ' '], '', microtime(false));
$orderId = 'o' . str_replace(['0.', ' '], '', microtime(false));

// A Basket is mandatory for Invoice Factoring payment type
$basketItem = new BasketItem('Hat', 100.0, 119.0, 1);
Expand Down
4 changes: 4 additions & 0 deletions examples/PayPal/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
</div>
<!-- This is just for the example - End -->

<div id="container-example-paypal"></div>
<div class="field" id="error-holder" style="color: #9f3a38"> </div>
<button class="heidelpayUI primary button fluid" id="submit-button" type="submit">Pay</button>
</form>
Expand All @@ -84,6 +85,9 @@

// Create an Paypal instance
let Paypal = heidelpayInstance.Paypal();
Paypal.create('email', {
containerId: 'container-example-paypal'
})

// Handle payment form submission
let form = document.getElementById('payment-form');
Expand Down
2 changes: 1 addition & 1 deletion examples/Prepayment/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function redirect($url, $merchantMessage = '', $clientMessage = '')
$prepayment = $heidelpay->createPaymentType(new Prepayment());

$customer = CustomerFactory::createCustomer('Max', 'Mustermann');
$orderId = str_replace(['0.', ' '], '', microtime(false));
$orderId = 'o' . str_replace(['0.', ' '], '', microtime(false));

$transaction = $prepayment->charge(12.99, 'EUR', CONTROLLER_URL, $customer, $orderId);

Expand Down
2 changes: 1 addition & 1 deletion examples/SepaDirectDebitGuaranteed/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function redirect($url, $merchantMessage = '', $clientMessage = '')
$heidelpay = new Heidelpay(HEIDELPAY_PHP_PAYMENT_API_PRIVATE_KEY);
$heidelpay->setDebugMode(true)->setDebugHandler(new ExampleDebugHandler());

$orderId = str_replace(['0.', ' '], '', microtime(false));
$orderId = 'o' . str_replace(['0.', ' '], '', microtime(false));

// A Basket is mandatory for SEPA direct debit guaranteed payment type
$basketItem = new BasketItem('Hat', 100.0, 119.0, 1);
Expand Down
3 changes: 2 additions & 1 deletion src/Adapter/CurlAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
namespace heidelpayPHP\Adapter;

use heidelpayPHP\Heidelpay;
use heidelpayPHP\Services\EnvironmentService;
use function extension_loaded;
use heidelpayPHP\Exceptions\HeidelpayApiException;
Expand Down Expand Up @@ -126,7 +127,7 @@ public function setHeaders(array $headers)
*/
public function setUserAgent($userAgent)
{
$this->setOption(CURLOPT_USERAGENT, 'HeidelpayPHP');
$this->setOption(CURLOPT_USERAGENT, Heidelpay::SDK_TYPE);
}

/**
Expand Down
10 changes: 8 additions & 2 deletions src/Constants/ApiResponseCodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,16 @@ class ApiResponseCodes
const API_ERROR_ADDRESSES_DO_NOT_MATCH = 'API.330.100.106';
const API_ERROR_CURRENCY_IS_NOT_SUPPORTED = 'API.330.100.202';
/**
* API_ERROR_AUTHORIZE_ALREADY_CANCELLED
*
* @deprecated since 1.2.3.0
* @see ApiResponseCodes::API_ERROR_ALREADY_CANCELLED
*/
const API_ERROR_AUTHORIZE_ALREADY_CANCELLED = 'API.340.100.014';
const API_ERROR_ALREADY_CANCELLED = 'API.340.100.014';
/**
* API_ERROR_CHARGE_ALREADY_CHARGED_BACK
*
* @deprecated since 1.2.3.0
* @see ApiResponseCodes::API_ERROR_ALREADY_CHARGED_BACK
*/
Expand All @@ -70,15 +74,17 @@ class ApiResponseCodes
const API_ERROR_CUSTOMER_CAN_NOT_BE_FOUND = 'API.500.100.100';
const API_ERROR_REQUEST_DATA_IS_INVALID = 'API.500.300.999';
const API_ERROR_RECURRING_PAYMENT_NOT_SUPPORTED = 'API.500.550.004';
const API_ERROR_ACTIVATE_RECURRING_VIA_TRANSACTION = 'API.500.550.005';
const API_ERROR_RECURRING_ALREADY_ACTIVE = 'API.500.550.006';
const API_ERROR_WEBHOOK_EVENT_ALREADY_REGISTERED = 'API.510.310.009';
const API_ERROR_WEBHOOK_CAN_NOT_BE_FOUND = 'API.510.310.008';
const API_ERROR_BASKET_ITEM_IMAGE_INVALID_URL = 'API.600.630.004';
/**
* API_ERROR_BASKET_ITEM_IMAGE_INVALID_EXTENSION
*
* @deprecated since 1.2.5.0 Will be removed in next major version.
*/
const API_ERROR_BASKET_ITEM_IMAGE_INVALID_EXTENSION = 'API.600.630.005';
const API_ERROR_ACTIVATE_RECURRING_VIA_TRANSACTION = 'API.640.550.005';
const API_ERROR_RECURRING_ALREADY_ACTIVE = 'API.640.550.006';
const API_ERROR_INVALID_KEY = 'API.710.000.002';
const API_ERROR_INSUFFICIENT_PERMISSION = 'API.710.000.005';
const API_ERROR_WRONG_AUTHENTICATION_METHOD = 'API.710.000.007';
Expand Down
4 changes: 4 additions & 0 deletions src/Constants/WebhookEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class WebhookEvents

// payout events
const PAYOUT = 'payout';
const PAYOUT_SUCCEEDED = 'payout.succeeded';
const PAYOUT_FAILED = 'payout.failed';

// types events
const TYPES = 'types';
Expand Down Expand Up @@ -87,6 +89,8 @@ class WebhookEvents
self::CHARGE_CANCELED,
self::CHARGEBACK,
self::PAYOUT,
self::PAYOUT_SUCCEEDED,
self::PAYOUT_FAILED,
self::TYPES,
self::CUSTOMER,
self::CUSTOMER_CREATED,
Expand Down
14 changes: 7 additions & 7 deletions src/Heidelpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class Heidelpay implements HeidelpayParentInterface, PaymentServiceInterface, Re
{
const BASE_URL = 'api.heidelpay.com';
const API_VERSION = 'v1';
const SDK_TYPE = 'HeidelpayPHP';
const SDK_VERSION = '1.2.7.1';
const SDK_TYPE = 'heidelpayPHP';
const SDK_VERSION = '1.2.7.2';

/** @var string $key */
private $key;
Expand Down Expand Up @@ -172,11 +172,11 @@ public function setLocale($locale): Heidelpay
}

/**
* @param ResourceServiceInterface $resourceService
* @param ResourceService $resourceService
*
* @return Heidelpay
*/
public function setResourceService(ResourceServiceInterface $resourceService): Heidelpay
public function setResourceService(ResourceService $resourceService): Heidelpay
{
$this->resourceService = $resourceService->setHeidelpay($this);
return $this;
Expand All @@ -193,11 +193,11 @@ public function getResourceService(): ResourceService
}

/**
* @param PaymentServiceInterface $paymentService
* @param PaymentService $paymentService
*
* @return Heidelpay
*/
public function setPaymentService(PaymentServiceInterface $paymentService): Heidelpay
public function setPaymentService(PaymentService $paymentService): Heidelpay
{
$this->paymentService = $paymentService->setHeidelpay($this);
return $this;
Expand Down Expand Up @@ -1024,7 +1024,7 @@ public function debugLog($message)
if ($this->isDebugMode()) {
$debugHandler = $this->getDebugHandler();
if ($debugHandler instanceof DebugHandlerInterface) {
$debugHandler->log('(' . (string)(getmypid()) . ') ' . $message);
$debugHandler->log('(' . getmypid() . ') ' . $message);
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/Resources/AbstractHeidelpayResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,17 @@ protected function getResourcePath(): string
public function handleResponse(stdClass $response, $method = HttpAdapterInterface::REQUEST_GET)
{
self::updateValues($this, $response);

// Todo: Workaround to be removed when API sends TraceID in processing-group
if (
isset($response->resources->traceId) &&
is_callable([$this, 'setTraceId']) &&
is_callable([$this, 'getTraceId']) &&
$this->getTraceId() === null
) {
$this->setTraceId($response->resources->traceId);
}
// Todo: Workaround end
}

/**
Expand Down
16 changes: 3 additions & 13 deletions src/Resources/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
use heidelpayPHP\Constants\Salutations;
use heidelpayPHP\Resources\EmbeddedResources\Address;
use heidelpayPHP\Resources\EmbeddedResources\CompanyInfo;
use heidelpayPHP\Resources\EmbeddedResources\GeoLocation;
use heidelpayPHP\Traits\HasGeoLocation;
use stdClass;
use function in_array;

class Customer extends AbstractHeidelpayResource
{
use HasGeoLocation;

/** @var string $firstname */
protected $firstname;

Expand Down Expand Up @@ -70,9 +72,6 @@ class Customer extends AbstractHeidelpayResource
/** @var CompanyInfo $companyInfo */
protected $companyInfo;

/** @var GeoLocation $geoLocation */
private $geoLocation;

/**
* Customer constructor.
*
Expand All @@ -90,7 +89,6 @@ public function __construct(string $firstname = null, string $lastname = null)
$this->lastname = $lastname;
$this->billingAddress = new Address();
$this->shippingAddress = new Address();
$this->geoLocation = new GeoLocation();
}

//<editor-fold desc="Getters/Setters">
Expand Down Expand Up @@ -324,14 +322,6 @@ public function setCompanyInfo(CompanyInfo $companyInfo): Customer
return $this;
}

/**
* @return GeoLocation|null
*/
public function getGeoLocation()
{
return $this->geoLocation;
}

//</editor-fold>

//<editor-fold desc="Resource IF">
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/EmbeddedResources/GeoLocation.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Represents the customers geolocation.
* Represents the geo location of an entity.
*
* Copyright (C) 2019 heidelpay GmbH
*
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
use heidelpayPHP\Traits\HasInvoiceId;
use heidelpayPHP\Traits\HasOrderId;
use heidelpayPHP\Traits\HasPaymentState;
use heidelpayPHP\Traits\HasTraceId;
use RuntimeException;
use stdClass;

Expand All @@ -55,6 +56,7 @@ class Payment extends AbstractHeidelpayResource
use HasPaymentState;
use HasOrderId;
use HasInvoiceId;
use HasTraceId;

/** @var string $redirectUrl */
private $redirectUrl;
Expand Down
Loading

0 comments on commit 202da52

Please sign in to comment.