heidelpay / php-customer-messages
A libary for heidelpay messages.
Installs: 13 437
Dependents: 0
Suggesters: 1
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: ^5.6.0|^7.0.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.0
- heidelpay/phpdocumentor: ^2.9.1
- phpunit/phpunit: ~5.7
- satooshi/php-coveralls: 1.0
This package is auto-updated.
Last update: 2019-02-20 19:44:59 UTC
README
heidelpay Customer Messages
ATTENTION: This package is abandoned and replaced by heidelpay/php-message-code-mapper.
This library provides user-friendly output of (error)-messages coming from the heidelpay API.
1. Installation
Composer
composer require heidelpay/php-customer-messages
manual Installation
Download the latest release from github and unpack it into a folder of your choice inside your project.
2. Implementation
Composer
require_once 'path/to/autoload.php;
use Heidelpay\CustomerMessages\CustomerMessage;
manual Installation
require_once 'path/to/php-customer-messages/lib/CustomerMessage.php';
Of course, the path needs to match the path from step 1.
3. Usage
Assuming you have received an error code from one of our modules or the
heidelpay PHP API and stored it in a variable called $errorcode
.
To get a message from that code, create a CustomerMessage
instance:
$instance = new \Heidelpay\CustomerMessages\CustomerMessage('de_DE');
The constructor takes two (optional) arguments:
- The locale (e.g. 'en_US', 'de_DE')
- The path to the locales path (for example you want to use your own locale files) containing the .csv files with the codes and messages.
We provide 'de_DE' and 'en_US' locale files with this package. You can find them in the lib/locales folder. If you want to use one of these, the path doesn't need to be provided in the constructor.
By default, 'en_US' is used as the locale.
Now you can return or print out the message by calling the getNessage()
method:
return $instance->getMessage($errorcode);
echo $instance->getMessage($errorcode);
Error codes are accepted in either the 'XXX.XXX.XXX' or 'HP-Error-XXX.XXX.XXX' format.