Download the PHP package swedbank-spp/swedbank-payment-portal without Composer

On this page you can find all versions of the php package swedbank-spp/swedbank-payment-portal. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package swedbank-payment-portal

Swedbank Payment Portal

About

Swedbank developed and maintaining API library to help and speed up merchant integrations in to e-shop.

Benefit to merchant

Usually Swedbank Payment Portal integration is done using technical specification (API documentation). Developers need to analyse it, prepare specific software architecture, logic to send and receive payment request messages towards Swedbank Payment Portal. By having library developer can save lot of development time and just reuse code and logic already created by us. This greatly speed up integration process on Merchant side and of course substantially saving the integration costs.

This library supports Swedbank payment types:

Requirements

Minimum PHP version required 7.1 and above.

Installation Instruction

Projects with composer installed

This is recommended way of installation. Add dependency in your composer.json:

and run "composer update" in command prompt or shell.

Alternative you can execute "composer require swedbank-spp/swedbank-payment-portal" from your command prompt or shell.

Projects which doesn`t have composer installed

Integration

Credentials

To be able to test Swedbank payment system you will need to get credentials for development and production environment. Only to test is enouth test credentials.

Banklink integration

Here is a sequence diagram which illustrates full banklink process. You can see that for Banklink integration you’ll need to call only three methods in a library “initPayment()”, “handlePendingTransaction()” and “checkPendingTransactions()”.

alt tag

Notification

Notification is used by banks to inform merchants about transaction statuses. Event notifications are communicated via a POST to a pre-configured merchant event URL. This URL must be different from the success and failure URL’s specified in the purchase setup requests. Multiple event notification URL’s can be configured on your Payment Gateway account, should the merchant require these messages to be delivered to a number of locations. The format of these event notifications is XML. Upon successful delivery of an event notification to an event URL, the merchant application must acknowledge receipt of such notification with an OK post back response to the Payment Gateway. The event notification mechanism is utilised to notify merchants of payment event statuses throughout the lifecycle of a transaction. For Banklink purchase transactions, the following event notifications could be delivered: AUTHORISED, REQUIRES_INVESTIGATION, CANCELLED. When a merchant receives the above event notifications, they are expected to respond with the following XML:

OK

In the event that the Payment Gateway does not receive a confirmation of receipt, the gateway will retry multiple times to send the notification. Using SPP library you need to call BankLinkService.handleNotification($xmlData) method to handle notification. “handleNotification” will parse XML and updates appropriate transaction status in the system. Also callback which was given in “initPayment” will be called if transaction resolves. Security note: Notification URL must be known and be accessible only from SPP server IP address. Configure your server to deny all other requests to that URL.

Usage example:

Payment Card (HPS) integration

Payment Card HPS integration is the same as Banklink.

alt tag

PayPal integration (Express Checkout)

PayPal integration is also the same as HPS and banklink.

alt tag

Cron job operations

System should call “checkPendingTransactions” operation on each minute. This will trigger status checking of transactions which are in PENDING state. Status checking operation time for each transaction is not related to cron job calling interval. Each transaction is queried in 30 minutes intervals. These settings can be changed in a library. One exception is for Banklink payment of Nordea: The first status querying of Nordea transaction is done only after 1 minute when user hits success URL, and later querying (if needed) after 30 minutes. These pending transaction checking is done only for Banklink and Payment Card HPS pending transactions as these transactions in some circumstances cannot be directly resolved (e.g. user didn’t get redirected to success url due internet problems).

Testing

Test transactions can be performed by using the test data in this section to process test transactions. The response received from the Payment Gateway will depend on the card number used. The responses are simulated and are intended to allow testing of common scenarios when processing Credit and Debit cards.

It is recommended that the following scenarios are tested as a minimum:

Each merchant must ensure the interaction between the Payment Gateway and their own e-commerce system is behaving as expected.

Below are card numbers that are behaving on a predefined way. They are an excellent help when integrating and in testing/debugging of various scenarios.

Please note – magic cards are provided for Accreditation only and NOT intended for use in the Production Environment.

MasterCard Test Data

Test Card Number Return Code Description Sample Message
5573470000000001 1 Authorised with random auth code AUTH CODE
5573470000000027 14 Test Server Response Payment Gateway Busy Please Retry
5573470000000035 440 Test Server Response Payment Gateway Busy
5573470000000050 661 Test Server Response Unknown Error
5573470000000068 653 Test Server Response Failure at Bank

Maestro Test Data

Test Card Number Return Code Description Sample Message
5001630100011248 1 Authorised with random auth code AUTH CODE
5001630100011255 7 Test Server Response DECLINED
5001630100011263 7 Test Server Response DECLINED

Visa Test Data

Test Card Number Return Code Description Sample Message
4929498311405001 1 Authorised with random auth code AUTH CODE
4978056100000019 7 Decline the transaction DECLINED

Test Data for 3-D Secure

Any of the magic card numbers can be used while integrating 3-D Secure. The response will be determined first by the 3-D Secure configuration on your account, and then by the expiry month of the test card number.

In order to generate specific responses, please use the card expiry month shown below:

Test card expiry month Test system response
01 Card is enrolled
02 Card is not enrolled
03 No result received from the directory server
04 3DS Invalid VERes from DS - Failed to parse VERes
05 3DS Invalid VERes from DS - invalid protocol value 'SET'
06 3DS invalid VEReq
07 Unable to verify
08 Card is enrolled
any other value Unable to verify

All library is under “SwedbankPaymentPortal” namespace. Main entry point for a library is “SwedbankPaymentPortal” class.

Here is a short example how to initialize a library:

After that you can retrieve all payment services which are needed.

Next step is to retrieve your needed payment service by calling one of a methods of “SwedbankPaymentPortal” object.

Example:

Whatever service you’ll retrieve all services contains a method “initPayment” which is a main payment initialization point.

Update:

To help other which projects do not have any dependency containers we’ve added couple static methods in a library which helps for global library initialization.

Please use these methods if your system do not have any dependency container to simplify process.

Success / Failure URL Handling

Whatever payment method you’ll use there is a need to specify success/failure URL for each “initPayment” call.

Success or Failure URL should be your custom page with appropriate message to user. Swedbank Payment Portal will redirect a customer to that URL in case of success or failure of purchase operation. Swedbank Payment Portal library is using additional server to server verification of success or failure of operation so you must call one of methods which finalizes a payment inside a library:

(please look at sequence diagrams above to see what library methods must be called on each step)

Finalization will trigger a callbacks which you’ve been given in “initPayment” method calls.

So, to fully complete a transaction you must know what payment method was used and what is an order ID of that payment and that information must be included in your success/failure URL. E.g: http://yoururl.com/success.html?payment=banklink&orderid={order_id}

Warning: entering to success URL doesn’t mean that purchase was 100% completed. Never do any order completion logic inside success url action! That logic must go in Callbacks.

Callback setup

The main idea is that purchase process is fully asynchronous and you’ll be notified some time in future by callback method which you’ve had given during payment initialization(“initPayment”). Here is a short description about what is a callback.

Callback is an object which has implemented CallbackInterface. CallbackInterface contains one method

and it will be called when transaction resolves (success or failure).

$transactionResult can be one of these values TransactionResult::success(), TransactionResult::failure(), TransactionResult::unfinished().

$transactionFrame - contains a request and a response of a last request which determined success/failure.

$paymentCardTransactionData - contains payment card information (expiry date, pan, authorization code). This parameter is optional and will be available only on HPS or HCC payment methods.

Because transactions is asynchronous that callback will be called some time in future on the different process so callback must be a PHP serializable object and must implement serialize() and unserialize() methods.

When a library calls a “handleFinishedTransaction” it will unserialize a callback to it’s previous state (time when had called “initPayment”).

If you need some additional information inside “handleFinishedTransaction” call the best way is to pass that information in callback constructor and implement serialize which persists that data.

For example it can be invoice id, order id, user id and other information which is required for your operations after transaction completion.

Update:

We have included default implementation of CallbackInterface called `UrlCallback` which now on you can use as Callback in “initPayment” (for all payment methods).

Example:

UrlCallback will call the given url using HTTP POST operation, with these POST fields: “status” one of these: SUCCESS or FAIL or UNFINISHED.

Security note: Thsi link should be secret and not accessable from outside. To improve security you need to add IP filtration for CalbackURL. The only IP allowed to call this URL should be 127.0.0.1

E-Receipt for Payment Card transactions

After payment card transaction completion the third argument of “handleFinishedTransaction” method will be set. Third argument will contain object of PaymentCardTransactionData.

“PaymentCardTransactionData” consists of:

This information must be included in e-receipt which must be generated after purchase using payment cards.

Banklink payments

Here is a table of available banks and what serviceType and paymentMethod you need to specify in purchase request:

Bank serviceType paymentMethod
SWEDBANK AB (SWEDEN) ServiceType::swdBank() PaymentMethod::swedbank()
NORDEA BANK AB (SWEDEN) ServiceType::nrdSwd() PaymentMethod::nordea()
SVENSKA HANDELSBANKEN AB (SWEDEN) ServiceType::undefined() PaymentMethod::svenska()
SKANDINAVISKA ENSKILDA BANKEN AB (SWEDEN) ServiceType::sebSwd() PaymentMethod::seb()
SWEDBANK AS (ESTONIA) ServiceType::estBank() PaymentMethod::swedbank()
SEB AS Pank (ESTONIA) ServiceType::sebEst() PaymentMethod::seb()
Nordea Bank AB Estonia Branch (ESTONIA) ServiceType::nrdEst() PaymentMethod::nordea()
SWEDBANK AS (LATVIA) ServiceType::ltvBank() PaymentMethod::swedbank()
SEB AS banka (LATVIA) ServiceType::sebLtv() PaymentMethod::seb()
AS CITADELE BANKA (LATVIA) ServiceType::undefined() PaymentMethod::citadele()
SWEDBANK AB (LITHUANIA) ServiceType::litBank() PaymentMethod::swedbank()
SEB AB bankas (LITHUANIA) ServiceType::sebLit() PaymentMethod::seb()
AB DNB BANKAS (LITHUANIA) ServiceType::undefined() PaymentMethod::dnb()
NORDEA BANK AB LITHUANIA BRANCH (LITHUANIA) ServiceType::nrdLit() PaymentMethod::nordea()
DANSKE BANK AS LITHUANIA BRANCH (LITHUANIA) ServiceType::undefined() PaymentMethod::danske()

Example how to initiate banklink payment:

HPS Example using calback

Replace sppdemoshop.eu to your shop address.

callback.php This is example of callback. Callback function need be available in setup call and final process.

hps.php This is setup script

hps_confirm.php This is final payment process

HPS Example using UrlCalback

Replace sppdemoshop.eu to your shop address. Use this only if you can't use above example.

hps_url_calback_hps.php

confirm.php

secretprocesor.php This file newer will be loaded in browser. This will be called by cron job.

Bank link

Replace sppdemoshop.eu to your shop address.

banklink_setup.php

callback.php

banklink_confirm.php

Paypal example

Replace sppdemoshop.eu to your shop address.

paypal_setup.php

paypal_confirm.php

Debugging / logging xml

To log xml needed to modify code.

Add logger object to ServiceOptions

swedbank_logger.php

Query card payment

query_example.php

Cancel or Refund card payment

cancel_example.php

Refund card payment

refund.php


All versions of swedbank-payment-portal with dependencies

PHP Build Version
Package Version
Requires symfony/yaml Version ~2.8|~3.0|~4.0|~5.0
symfony/dependency-injection Version ^2.8|^3.0|^4.0|^5.0
symfony/config Version ^2.8|^3.0|^4.0|^5.0
jms/serializer Version ^1.1
guzzlehttp/guzzle Version ^5.0|^6.0|^7.0
doctrine/cache Version ^1.6
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package swedbank-spp/swedbank-payment-portal contains the following files

Loading the files please wait ....