Migrate to Unzer PHP SDK

Migrate from the old heidelpay PHP SDK to the new Unzer PHP SDK.

About the migration

The new Unzer PHP SDK works the same as the old heidelpay PHP SDK, except for changes in:

  • Class names
  • Method names
  • Payment type names
  • Deprecated code
  • UI components

Migrate to Unzer PHP SDK

To migrate to the new Unzer PHP SDK, you need to update the code in your project.

All migration changes
To see all PHP SDK migration changes, go here.

To migrate from the latest version of the old heidelpay PHP SDK to the new Unzer PHP SDK, implement the following changes (in any order).

Update your composer.json file

In your composer.json file:

  • Change heidelpay/heidelpay-php to unzerdev/php-sdk.

Replace class and method names

In your project, replace the names of classes and methods.

This table shows examples of changes that you need to make:

All migration changes
To see all PHP SDK migration changes, go here.
Element Old New
Namespace root for all classes heidelpayPHP UnzerSDK
Class names Heidelpay
HeidelpayApiException
Unzer
UnzerApiException
Method names getHeidelpay
getHeidelpayObject
getUnzer
getUnzerObject
Environment service ...\EnvironmentService::getMgwEnvironment ...\EnvironmentService::getPAPIEnvironment
Environment variables HEIDELPAY_MGW
HEIDELPAY_MGW_ENV
UNZER_PAPI
UNZER_PAPI_ENV
fetchDirectDebitInstalmentPlans fetchDirectDebitInstalmentPlans fetchInstallmentPlans
Constants in \UnzerSDK\Constants\ApiResponseCodes API_ERROR_IVF_REQUIRES_CUSTOMER
API_ERROR_IVF_REQUIRES_BASKET
API_ERROR_FACTORING_REQUIRES_CUSTOMER
API_ERROR_FACTORING_REQUIRES_BASKET

This example shows how these changes apply to your payment integration:

$heidelpay = new \heidelpayPHP\Heidelpay('s-priv-xxxxxxxxxx');

$paypal = new \heidelpayPHP\Resources\PaymentTypes\Paypal();
$paypal = $heidelpay->createPaymentType($paypal);
$unzer = new \UnzerSDK\Unzer('s-priv-xxxxxxxxxx');

$paypal = new \UnzerSDK\Resources\PaymentTypes\Paypal();
$paypal = $unzer->createPaymentType($paypal);

Replace payment type names

Replace the following payment type names:

Old New
InvoiceGuaranteed InvoiceSecured
InvoiceFactoring InvoiceSecured
SepaDirectDebitGuaranteed SepaDirectDebitSecured
HirePurchaseDirectDebit InstallmentSecured
Basket
To implement basket, use the \UnzerSDK\Resources\Basket class.

Replace deprecated code

In your project, replace any code marked as deprecated in the heidelpay PHP SDK.

The below list is based on the latest version of the old heidelpay PHP SDK:

Old method New method
heidelpayPHP\Resources\Basket
::getAmountTotal
...\Basket
::getAmountTotalGross
heidelpayPHP\Resources\Basket
::setAmountTotal
...\Basket
::setAmountTotalGross
heidelpayPHP\Resources\PaymentTypes\Card
::getHolder
...\Card
::getCardHolder
heidelpayPHP\Resources\PaymentTypes\Card
::setHolder
...\Card
::setCardHolder
heidelpayPHP\Resources\Customer
::\_\_construct
Use CustomerFactory instead:

heidelpayPHP\Resources\CustomerFactory
::createCustomer
::createNotRegisteredB2bCustomer
::createRegisteredB2bCustomer
heidelpayPHP\Resources\Payment
::cancel
::cancelAllCharges
::cancelAuthorization
...\Payment
::cancelAmount
heidelpayPHP\heidelpay
::getResource
Use ResourceService instead:

heidelpayPHP\Resources\ResourceService
::getResource
heidelpayPHP\heidelpay
::fetchResource
Use ResourceService instead:

heidelpayPHP\Resources\ResourceService
::fetchResource
Old constant New constant
heidelpayPHP\Constants\ApiResponseCodes
::API_ERROR_AUTHORIZE_ALREADY_CANCELLED
API_ERROR_ALREADY_CANCELLED
heidelpayPHP\Constants\ApiResponseCodes
::API_ERROR_CHARGE_ALREADY_CHARGED_BACK
API_ERROR_ALREADY_CHARGED_BACK
heidelpayPHP\Constants\ApiResponseCodes
::API_ERROR_BASKET_ITEM_IMAGE_INVALID_EXTENSION
Removed
heidelpayPHP\Services\EnvironmentService
::ENV_VAR_NAME_DISABLE_TEST_LOGGING
ENV_VAR_NAME_VERBOSE_TEST_LOGGING

This has the opposite effect of: ENV_VAR_NAME_DISABLE_TEST_LOGGING.

Update your UI components

To update your UI components, go here.