SBanken
The SBanken integration is made to connect with the SBanken public API (https://sbanken.no)
You can read more about the APIs in use here:
Accounts API
Customers API
Note: This API is in current development and BETA. Bugs can occur.
Getting started
To start using this integration you will need to initate a class object that will be used later to connect to the different APIs. To start with this, you will need to create a ClientID
and a ClientSecret
at SBanken (only available in Norwegian)
When this has been created, you can initiate an instance of the SBanken class using one of the following examples:
use Teskon\PSD2PHP\PSD2PHP;
require 'vendor/autoload.php';
$SBanken = new PSD2PHP("SBanken", "ClientID", "ClientSecret");
use Teskon\PSD2PHP\Banks\SBanken\SBanken;
require 'vendor/autoload.php';
$SBanken = new SBanken("ClientID", "ClientSecret");
Note: All examples listed below will use the SBanken class initiated above.
Configuration
We allow you to change the configuration values on each bank before sending the API requests.
Available configuration values
You can change the following configuration values:
Type | Key | Description | Default |
---|---|---|---|
int | max | Maximum number of allowed redirects. | 5 |
bool | strict | Set to true to use strict redirects. Strict RFC compliant redirects mean that POST redirect requests are sent as POST requests vs. doing what most browsers do which is redirect POST requests with GET requests. | false |
bool | referer | Set to true to enable adding the Referer header when redirecting. | false |
array | protocols | Specified which protocols are allowed for redirect requests. | ['http', 'https'] |
callable | on_redirect | PHP callable that is invoked when a redirect is encountered. The callable is invoked with the original request and the redirect response that was received. Any return value from the on_redirect function is ignored. | null |
bool | track_redirects | When set to true, each redirected URI and status code encountered will be tracked in the X-Guzzle-Redirect-History and X-Guzzle-Redirect-Status-History headers respectively. All URIs and status codes will be stored in the order which the redirects were encountered. | false |
Overwrite default configuration
If you want to overwrite the default configuration values when initiating the SBanken class you can pass an array
as a parameter to the class with the values you want to change.
use Teskon\PSD2PHP\PSD2PHP;
require 'vendor/autoload.php';
$SBanken = new PSD2PHP("SBanken", "ClientID", "ClientSecret", [
'max' => 3
]);
use Teskon\PSD2PHP\Banks\SBanken\SBanken;
require 'vendor/autoload.php';
$SBanken = new SBanken("ClientID", "ClientSecret", [
'max' => 3
]);
The example above will create an instance of the SBanken class with a maximum number of allowed redirects of 3.
In this version there is no option to change the configuration values for each request. This has since been added in version 1.0.1
Available requests
Note: No required parameters has a default value.
Get Customer information
You can get the customer information by running the getCustomer
method.
$customerID = '12345678910';
$customer = $SBanken->getCustomer($customerID);
Parameters:
Parameter | Type | Description |
---|---|---|
$customerID required | string | Your social security numbers (11 characters long). |
Get Accounts
You can get the accounts owned by a customer by running the getAccounts
method.
$customerID = '12345678910';
$accounts = $SBanken->getAccounts($customerID);
Parameters:
Parameter | Type | Description |
---|---|---|
$customerID required | string | Your social security numbers (11 characters long). |
Get Account
You can get a specific account owned by a customer by running the getAccount
method.
$customerID = '12345678910';
$accountID = 'abc';
$account = $SBanken->getAccount($customerID, $accountID);
Parameters:
Parameter | Type | Description |
---|---|---|
$customerID required | string | Your social security numbers (11 characters long). |
$accountID required | string | Account ID retrieved from getAccounts |
Get Transactions
You can get transactions beloning to an account by running the getTransactions
method.
$customerID = '12345678910';
$accountID = 'abc';
$index = 0;
$length = 100;
$startDate = '2018-01-01';
$endDate = '2018-01-31';
$transactions = $SBanken->getTransactions($customerID, $accountID, $index, $length, $startDate, $endDate);
Parameters:
Parameter | Type | Description |
---|---|---|
$customerID required | string | Your social security numbers (11 characters long). |
$accountID required | string | Account ID retrieved from getAccounts |
$index | int | Starting index of retrieved results Default: 0 |
$length | int | Result limit. Minimum value is 1. Maximum value is 1000. Default: 100 |
$startDate | string | Date to start retrieving transactions from. Minimum date is 2000-01-01. Maximum date is current date + 1 day. Default: current date - 30 days |
$endDate | string | Date to stop retrieving transactions from. Minimum date is $startDate. Maximum date is current date + 1 day. Default: current date |
Get Electronic Invoices
You can get electronic invoices belonging to a customer by running the getEInvoices
method.
$customerID = '12345678910';
$status = 'ALL';
$index = 0;
$length = 100;
$startDate = '2018-01-01';
$endDate = '2018-01-31';
$eInvoices = $SBanken->getEInvoices($customerID, $status, $index, $length, $startDate, $endDate);
Parameters:
Parameter | Type | Description |
---|---|---|
$customerID required | string | Your social security numbers (11 characters long). |
$status | string | Current status of e-invoices you want returned. Possible values: ALL , NEW , PROCESSED and DELETED |
$index | int | Starting index of retrieved results Default: 0 |
$length | int | Result limit. Minimum value is 1. Maximum value is 1000. Default: 100 |
$startDate | string | Date to start retrieving transactions from. Minimum date is 2000-01-01. Maximum date is current date + 60 day. Default: current date - 60 days |
$endDate | string | Date to stop retrieving transactions from. Minimum date is $startDate. Maximum date is current date + 60 days. Default: current date + 60 days |
Get Electronic Invoice
You can get specific e-invoices belonging to a customer by running the getEInvoice
method
$customerID = '12345678910';
$eInvoiceID = 'abc';
$eInvoice = $SBanken->getEInvoice($customerID, $eInvoiceID);
Parameters:
Parameter | Type | Description |
---|---|---|
$customerID required | string | Your social security numbers (11 characters long). |
$eInvoiceID required | string | ID of specified E-Invoice retrieved from getEInvoices |
Planned features
This integration is not complete, and we're constantly working on making it better. We're currently planning to add these features in an upcoming update:
- Transfer money between owned accounts
- Pay E-Invoices.
Make it possible to change configuration variables for each request(added in version 1.0.1)