Code setup
When you've finsihed the installation guide, there are two main ways to get started coding with PSD2PHP.
You can either call the PSD2PHP class with the Bank name as a string, or you can call the Bank's class directly. Both versions will give you the same functionality and will return the same class to you. What you choose to do is completely up to you, as both methods will be supported by us. The first method is the easiest to use if you're connecting to multiple banks and have the bank name stored as a string, but it is entirely possible to use the second method as well.
Note: This is just a guide to get you started with the banking class. For more details about the bank you're going to use, please refer to the specific guide of said bank to see possibilities available for that bank.
Note: The examples we've listed below is using the default configuration setup of the banking integration used by PSD2PHP. This might not work for all banks, as the
ClientID
andClientSecret
might be implemented differently based on how the banking API works. Please refer to the guide of your bank to see which parameters it requires.
PSD2PHP class
If you have the bank stored in a string this is the best way to setup PSD2PHP, sending a parameter to the PSD2PHP
class.
use Teskon\PSD2PHP\PSD2PHP;
require 'vendor/autoload.php';
$bank = new PSD2PHP("Bank", "ClientID", "ClientSecret");
Direct integration with banking class
If you would rather open a connection with the class of the bank you're working on directly, you can do so.
Note: The example below is using our first integration (SBanken). Check the documentation of your bank before setting up the connection.
use Teskon\PSD2PHP\Banks\SBanken\SBanken;
require 'vendor/autoload.php';
$bank = new SBanken("ClientID", "ClientSecret");
If you have the bank stored as a string you can still do so if you want to. Here is an example on how to do it.
Note: Initiating a class from a string in PHP requires the full namespace in the string. We don't recommend doing this if you want clean code. If you need to initiate the banking class from a string, we recommend using the
PSD2PHP
class above.
require 'vendor/autoload.php';
$bank = "Teskon\PSD2PHP\Banks\SBanken\SBanken";
$bank = new $bank("ClientID", "ClientSecret")