NAME
Stancer::Config - API configuration
VERSION
version 1.0.1
SYNOPSIS
Handle configuration, connection and credential to API.
use Stancer::Config;
Stancer::Config->init($secret_key);
my $payment = Stancer::Payment->new();
$payment->send();
ATTRIBUTES
calls
Read-only list of Stancer::Core::Request::Call
.
This list is only available in debug mode.
debug
Read/Write boolean.
Indicate if we are in debug mode.
In debug mode we will register every request made to the API.
Debug mode is enabled by default in test mode and disabled by default in live mode.
default_timezone
Read/Write instance of DateTime::TimeZone
.
Will be used as default time zone for every DateTime
object created by the API.
If none provided, we will let DateTime default mechanism do the work.
You may pass a string, it will be used to create a new DateTime::TimeZone
instance.
host
Read/Write string, default to "api.stancer.com".
API host
keychain
Read/Write array reference of API keys.
API keychain.
lwp
Read/Write instance of LWP::UserAgent
.
If none provided, it will instanciate a new instance. This allow you to provide your own configured LWP::UserAgent.
mode
Read/Write, must be 'test' or 'live', default depends on key.
You better use `Stancer::Config::TEST` or `Stancer::Config::LIVE` constants.
API mode
port
Read/Write integer.
API HTTP port
pprod
Read/Write 30 characters string.
Public production authentication key.
public_key
Read-only 30 characters string.
Public authentication key. Will return pprod
or ptest
key depending on configured mode
.
ptest
Read/Write 30 characters string.
Public development authentication key.
secret_key
Read-only 30 characters string.
Secret authentication key. Will return sprod
or stest
key depending on configured mode
.
sprod
Read/Write 30 characters string.
Secret production authentication key.
stest
Read/Write 30 characters string.
Secret development authentication key.
timeout
Read/Write integer.
Timeout for every API call
uri
Read-only string.
Complete location for the API.
user_agent
Read-only default user agent.
version
Read/Write integer.
API version
METHODS
Stancer::Config->new(%args) : self
This method create a new configuration object. %args
can have any attribute listed in current documentation.
We may also see "init" method.
Config::init($token) : self
Config::init(%args) : self
Config::init() : self
Get an instance with only a token. It may also accept the same hash used in `new` method.
Will act as a singleton if called without argument.
$config->is_live_mode() : bool
$config->is_test_mode() : bool
$config->is_not_live_mode() : bool
$config->is_not_test_mode() : bool
Indicate if we are running or not is live mode or test mode.
$config->last_call() : Stancer::Core::Request::Call
Return the last call to the API.
USAGE
Logging
We use the Log::Any framework for logging events. You may tell where it should log using any available Log::Any::Adapter module.
For example, to log everything to a file you just have to add a line to your script, like this: #! /usr/bin/env perl use Log::Any::Adapter (File => '/var/log/payment.log'); use Stancer::Config;
You must import Log::Any::Adapter
before our libraries, to initialize the logger instance before use.
You can choose your log level on import directly: use Log::Any::Adapter (File => '/var/log/payment.log', log_level => 'info');
Read the Log::Any documentation to know what other options you have.
SECURITY
Never, never, NEVER register a card or a bank account number in your database.
Always uses HTTPS in card/SEPA in communication.
Our API will never give you a complete card/SEPA number, only the last four digits. If you need to keep track, use these last four digit.
BUGS
Please report any bugs or feature requests on the bugtracker website https://gitlab.com/wearestancer/library/lib-perl/-/issues or by email to bug-stancer@rt.cpan.org.
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
AUTHOR
Joel Da Silva <jdasilva@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2018-2024 by Stancer / Iliad78.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)