Pei payment gateway integration with PHP. – Iceland.

By | July 2, 2020

Basic Information:

This article is about the Pei payment gateway. It is a payment method owned by Greiðsluiðlun ehf . Payment intermediation is the development and operation of payment solutions, credit purchases, and debt management for companies, NGOs, pension funds, and public bodies.

Here in this article, we will operate the Norra registration and payment system. Like sports clubs, organizations, municipalities, and companies to simplify registration and payment for courses, events, and various other services.

Let’s Start

Let’s start now. First of all, you need to initialize composer if the composer is not installed please [click here] to follow installation instructions.

Therefor, I assume composer is installed so please follow below steps

$ cd your/project/path/dir
$ composer init

You need to run this command in your terminal.

While performing the steps the composer will ask for a couple of questions.

Therefore, you just need to answer it or just hit enter throughout with default values.

Now time to run and install package of PEI payment as below.

$ composer require "coderubix/php-pei":"dev-master"

Or alternatively you can add below code to you composer.json file at “require” section

    "require": {

Now run composer update

$ composer update
$ composer dump-autoload

You will see successfully installation of package as below screen.

Output of composer after installing the package of Pei payment gateway

Now create pei-redirect.php file and pass relevant parameter in that.

Make sure and don’t forgot to use the PEI class.


ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

//If you are using core PHP then first include the class from relevent directory from your code.
require_once __DIR__ . '/vendor/coderubix/php-pei/src/pei/PeiPayment.php';

use Pei\PeiPayment as PeiPayment;

$config = [
        'live' => [
            'auth_url' => '',
            'order_url' => '',
            'payment_url' => '',
            'client_id' => 'XXXXXXXXXXXXXXX', // replace this with your client id provided by
            'secret_key' => 'XXXXXXXXXXXXXXX', // replace this with your secret provided by
            'merchantid' => 1, // replace this with your merchant id provided by
            'postback_url' => '',
            'cancel_url' => '',
            'success_url' => ''
        'sandbox' => [
            'auth_url' => '',
            'order_url' => '',
            'payment_url' => '',
            'client_id' => 'democlient',
            'secret_key' => 'demosecret',
            'merchantid' => 1,
            'postback_url' => '',
            'cancel_url' => '',
            'success_url' => 'success.php'

$PeiPayment = new PeiPayment($config, 'sandbox');

// get auth token
//$auth_token = $PeiPayment->authorize();

$ssn = 5554452454;

$order_info = [
	'order_id' => uniqid(),
	'user' => [
		'firstname' => 'jhon',
		'lastname' => 'doe',
		'email' => ''
	'tax' => [
		'label' => 'Vat',
		'amount' => 100
  	'shipping' => [
		'label' => 'Shipping',
		'amount' => 50
	'items' => [
			'name' => 'item 1',
			'code' => '#FFER23', //optional
			'quantity' => 20,
			'price' => 100
			'name' => 'item 2',	        
			'quantity' => 30,
			'price' => 150

$PeiPayment->pay($ssn, $order_info);

Create success.php and write your code which can be perform after successful transaction.

Now the next steps is to open a browser and enter the URL till pei-redirect.php

It will redirect and process the code as below screenshots.

Example of pei30 and pei60 option of Pei payment gateway
Example of pei30 and pei60 option
Example of credit card option of Pei payment gateway
Example of credit card option

There will be two options for payment “Pei 30/Pei 60” and “Credit Card” as above screenshot.

The Pei payment gateway suggests to integrated with a hosted page.

It is very easy to integrate but you can always use credit card payment integration on your own website.

if required for that Pei payment gateway provides REST API.

Feel free to comment if you find any issue or need any improvement.

Congratulations !! we are done here to learn and implementation of Pei gateway. Enjoy coding.

Below provided link is another article about the Razorpay payment gateway integration.

PS: Click Here to Checkout RazorPay payment gateway

Leave a Reply

Your email address will not be published. Required fields are marked *