PHPackages                             mrdulal/laravel-vipps - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. mrdulal/laravel-vipps

ActiveLibrary[Payment Processing](/categories/payments)

mrdulal/laravel-vipps
=====================

Laravel package for MobilePay Vipps payment integration with ePayment, Checkout, Express, and recurring payments support

v1.2.2(7mo ago)1160↓40%MITPHPPHP ^8.1CI failing

Since Sep 27Pushed 7mo agoCompare

[ Source](https://github.com/mrdulal/Vipps-MobilePay)[ Packagist](https://packagist.org/packages/mrdulal/laravel-vipps)[ Docs](https://github.com/mrdulal/Vipps-MobilePay)[ GitHub Sponsors](https://github.com/sponsors/mrdulal)[ RSS](/packages/mrdulal-laravel-vipps/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (9)Versions (7)Used By (0)

Laravel MobilePay Vipps Package
===============================

[](#laravel-mobilepay-vipps-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/87c3d717669c406e95b27f77c7015312c58ea0fc9ec956349c0aa715b48417bd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d7264756c616c2f6c61726176656c2d76697070732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mrdulal/laravel-vipps)[![Total Downloads](https://camo.githubusercontent.com/3e2fdabf5e1d1e8976ad8fd2c3574a3687938cc7b39d36a12b8c4aea6a517473/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d7264756c616c2f6c61726176656c2d76697070732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mrdulal/laravel-vipps)[![License](https://camo.githubusercontent.com/d67b1210f46f2969901ce911e21f07d77c5def8fc3f4a40d96625e0a5b7b0d51/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d7264756c616c2f56697070732d4d6f62696c655061792e7376673f7374796c653d666c61742d737175617265)](https://github.com/mrdulal/Vipps-MobilePay/blob/main/LICENSE)[![PHP Version Require](https://camo.githubusercontent.com/fbcfe5f528ba7059b48e05cb752b77a992b4385f1a0d985e859e25f328293a2f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d7264756c616c2f6c61726176656c2d76697070732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mrdulal/laravel-vipps)[![Laravel Support](https://camo.githubusercontent.com/965cdc20ff8005af424202772bab63acdf3cb69ea64b9cdc3b81ba4c92f2207d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d392532422d6f72616e67652e7376673f7374796c653d666c61742d737175617265)](https://laravel.com)[![Tests](https://camo.githubusercontent.com/e9e245fd17b052be70d0c4efc8552c7d51a42627e25ede9be77ae1d7d3fbe04f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d7264756c616c2f56697070732d4d6f62696c655061792f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/mrdulal/Vipps-MobilePay/actions)

A comprehensive Laravel package for MobilePay Vipps payment integration with support for all major Vipps payment methods. This package provides a clean, modern API for integrating with the Vipps MobilePay payment platform used across Norway, Denmark, and Finland.

> **⚠️ Important Notice**: This is an **unofficial** package and is not affiliated with, endorsed by, or officially supported by MobilePay or Vipps. This package is developed independently by a solo developer for Laravel developers. For official MobilePay Vipps integration documentation, please visit the [Vipps Developer Portal](https://developer.vippsmobilepay.com/).

🎯 Features
----------

[](#-features)

### Payment Methods

[](#payment-methods)

- **🏪 MobilePay Vipps ePayment** - Standard payment method integration
- **🛒 MobilePay Vipps Checkout** - Complete checkout solution with card payments
- **⚡ MobilePay Vipps Express** - Quick checkout from product pages with QR codes
- **🔄 Recurring Payments** - Subscription and recurring payment support

### Management &amp; Operations

[](#management--operations)

- **📊 Order Management API** - Capture, refund, cancel, and order management
- **🔗 Webhook Support** - Handle payment status updates automatically with signature verification
- **📡 Event-Driven Architecture** - Laravel events for all payment actions
- **🛡️ Security** - Built-in signature verification and request validation

### Developer Experience

[](#developer-experience)

- **✅ Comprehensive Testing** - Full test suite with PHPUnit and Orchestra Testbench
- **📚 Type Safety** - Full type hints and PHPDoc annotations
- **🔧 Configurable** - Extensive configuration options
- **🐞 Debugging** - Built-in logging and error handling
- **📦 Laravel Integration** - Service providers, facades, and Artisan commands

🌍 Countries Supported
---------------------

[](#-countries-supported)

CountryServiceMarket PenetrationUsers**🇳🇴 Norway**Vipps77% population4.2M users**🇩🇰 Denmark**MobilePay75% population4.4M users**🇫🇮 Finland**MobilePay50% population2.8M users> **Total Market Reach:** 11+ million active users across Nordic countries

📋 Requirements
--------------

[](#-requirements)

RequirementVersionNotes**PHP**8.1+Uses modern PHP features like enums, readonly properties**Laravel**9.0+Compatible with Laravel 9, 10, 11, and 12**Guzzle HTTP**7.0+For API communication**ext-json**\*JSON processing**ext-openssl**\*SSL/TLS support for API calls### Development Requirements

[](#development-requirements)

- **PHPUnit** 9.0+ or 10.0+
- **Orchestra Testbench** 7.0+, 8.0+, or 9.0+
- **Mockery** 1.4+ (for testing)

🚀 Installation
--------------

[](#-installation)

### 1. Install via Composer

[](#1-install-via-composer)

#### From Packagist (Recommended)

[](#from-packagist-recommended)

```
composer require mrdulal/laravel-vipps
```

#### From GitHub Packages (Alternative)

[](#from-github-packages-alternative)

See [GitHub Packages Installation Guide](GITHUB_PACKAGES.md) for detailed instructions on installing from GitHub Packages.

### 2. Publish Configuration

[](#2-publish-configuration)

```
# Publish configuration file
php artisan vendor:publish --provider="Mrdulal\LaravelVipps\VippsServiceProvider" --tag="config"

# Publish migrations
php artisan vendor:publish --provider="Mrdulal\LaravelVipps\VippsServiceProvider" --tag="migrations"

# Publish views (optional)
php artisan vendor:publish --provider="Mrdulal\LaravelVipps\VippsServiceProvider" --tag="views"
```

### 3. Run Migrations

[](#3-run-migrations)

```
php artisan migrate
```

This will create the following tables:

- `vipps_payments` - Store payment records
- `vipps_recurring_agreements` - Store recurring payment agreements
- `vipps_recurring_charges` - Store individual recurring charges

### 4. Laravel Auto-Discovery

[](#4-laravel-auto-discovery)

The package uses Laravel's auto-discovery feature. The service provider and facade will be registered automatically.

**Manual Registration (if needed):**

```
// config/app.php
'providers' => [
    // ...
    Mrdulal\LaravelVipps\VippsServiceProvider::class,
],

'aliases' => [
    // ...
    'Vipps' => Mrdulal\LaravelVipps\Facades\Vipps::class,
],
```

⚙️ Configuration
----------------

[](#️-configuration)

### Environment Variables

[](#environment-variables)

Add your Vipps credentials to your `.env` file:

```
# Required: Basic Configuration
VIPPS_ENVIRONMENT=test                    # test or production
VIPPS_CLIENT_ID=your_client_id
VIPPS_CLIENT_SECRET=your_client_secret
VIPPS_SUBSCRIPTION_KEY=your_ocp_apim_subscription_key
VIPPS_MERCHANT_SERIAL_NUMBER=123456       # 6-digit MSN

# Required: Webhook Configuration
VIPPS_WEBHOOK_SECRET=your_webhook_secret

# Optional: Logging & Debugging
VIPPS_LOGGING_ENABLED=false
VIPPS_LOG_CHANNEL=default
VIPPS_LOG_LEVEL=info
```

### Configuration File

[](#configuration-file)

The package configuration is located at `config/vipps.php`. Key sections include:

```
return [
    // Environment (test/production)
    'environment' => env('VIPPS_ENVIRONMENT', 'test'),

    // API Credentials
    'client_id' => env('VIPPS_CLIENT_ID'),
    'client_secret' => env('VIPPS_CLIENT_SECRET'),
    'subscription_key' => env('VIPPS_SUBSCRIPTION_KEY'),
    'merchant_serial_number' => env('VIPPS_MERCHANT_SERIAL_NUMBER'),

    // Feature toggles
    'features' => [
        'epayment' => true,
        'checkout' => true,
        'express' => true,
        'recurring' => true,
        'order_management' => true,
        'webhooks' => true,
    ],

    // HTTP client settings
    'http' => [
        'timeout' => 30,
        'connect_timeout' => 10,
        'verify' => true,
    ],

    // Express checkout UI settings
    'express' => [
        'button_theme' => 'orange',  // orange, white, white-outline
        'button_size' => 'large',    // small, medium, large
        'show_on_cart' => true,
        'show_on_product' => true,
    ],
];
```

🏁 Getting Started
-----------------

[](#-getting-started)

### 1. Get Vipps MobilePay Account Keys

[](#1-get-vipps-mobilepay-account-keys)

#### Step-by-Step Account Setup:

[](#step-by-step-account-setup)

1. **Sign up** at [Vipps MobilePay Portal](https://portal.vippsmobilepay.com/)
2. **Wait for approval** (1-2 days) - you'll receive login details via email
3. **Access Developer Portal:**
    - Login to Vipps MobilePay Business Portal
    - Navigate to "Developer" tab
    - Select "Test Keys" for development or "Production Keys" for live environment
4. **Retrieve Credentials:**
    - **Merchant Serial Number (MSN)** - 6-digit number displayed prominently
    - **Client ID** - Click "Show keys" to reveal
    - **Client Secret** - Click "Show keys" to reveal
    - **Subscription Key** - Listed as "Ocp-Apim-Subscription-Key"

#### Test vs Production

[](#test-vs-production)

EnvironmentPurposeAPI EndpointFeatures**Test**Development &amp; Testing`https://apitest.vipps.no`Full API access, test cards**Production**Live transactions`https://api.vipps.no`Real payments, KYC required### 2. Webhook Setup

[](#2-webhook-setup)

Vipps requires a webhook endpoint for payment status updates:

```
// routes/web.php or routes/api.php
Route::post('/vipps/webhook', [\Mrdulal\LaravelVipps\Http\Controllers\WebhookController::class, 'handle']);
```

**Register your webhook URL in the Vipps portal:**

- Format: `https://yourdomain.com/vipps/webhook`
- Must be HTTPS in production
- Must respond with HTTP 200 for successful processing

### 3. Basic Usage

[](#3-basic-usage)

#### ePayment (Standard Payment)

[](#epayment-standard-payment)

```
use Mrdulal\LaravelVipps\Facades\Vipps;

// Create a payment
$payment = Vipps::ePayment()->create([
    'amount' => 10000, // Amount in øre (100.00 NOK)
    'currency' => 'NOK',
    'orderId' => 'order-123',
    'description' => 'Payment for order #123',
    'redirectUrl' => 'https://yoursite.com/payment/callback',
    'userFlow' => 'WEB_REDIRECT'
]);

// Get payment details
$details = Vipps::ePayment()->getPayment($payment['orderId']);

// Capture payment
$capture = Vipps::ePayment()->capture($payment['orderId'], [
    'amount' => 10000,
    'description' => 'Capture for order #123'
]);
```

#### Express Checkout

[](#express-checkout)

```
use Mrdulal\LaravelVipps\Facades\Vipps;

// Create express checkout session
$session = Vipps::express()->create([
    'amount' => 10000,
    'currency' => 'NOK',
    'orderId' => 'order-123',
    'description' => 'Express checkout for order #123',
    'redirectUrl' => 'https://yoursite.com/express/callback',
    'userInfo' => [
        'userId' => 'user-123'
    ]
]);

// Generate QR code for express checkout
$qrCode = Vipps::express()->generateQrCode([
    'orderId' => 'order-123',
    'amount' => 10000,
    'currency' => 'NOK',
    'description' => 'Product purchase',
    'redirectUrl' => 'https://yoursite.com/callback',
    'qrFormat' => 'SVG', // or 'PNG'
    'qrSize' => 300
]);

// Create shareable payment link
$shareableLink = Vipps::express()->createShareableLink([
    'orderId' => 'order-456',
    'amount' => 15000,
    'currency' => 'NOK',
    'description' => 'Shareable payment link',
    'redirectUrl' => 'https://yoursite.com/callback',
    'expiresAt' => now()->addHours(24)
]);
```

#### Recurring Payments

[](#recurring-payments)

```
use Mrdulal\LaravelVipps\Facades\Vipps;

// Create recurring agreement
$agreement = Vipps::recurring()->createAgreement([
    'currency' => 'NOK',
    'price' => 9900, // 99.00 NOK
    'productName' => 'Monthly Subscription',
    'productDescription' => 'Premium subscription service',
    'merchantRedirectUrl' => 'https://yoursite.com/recurring/callback',
    'merchantAgreementUrl' => 'https://yoursite.com/agreement/123',
    'interval' => 'MONTH',
    'intervalCount' => 1,
    'isApp' => false
]);

// Create charge for agreement
$charge = Vipps::recurring()->createCharge($agreement['agreementId'], [
    'amount' => 9900,
    'currency' => 'NOK',
    'description' => 'Monthly subscription charge',
    'orderId' => 'charge-456'
]);

// List all charges for an agreement
$charges = Vipps::recurring()->listCharges($agreement['agreementId']);

// Stop an agreement
$result = Vipps::recurring()->stopAgreement($agreement['agreementId'], [
    'reason' => 'Customer requested cancellation'
]);
```

📚 API Reference
---------------

[](#-api-reference)

### Services Overview

[](#services-overview)

ServicePurposeKey Methods**ePayment**Standard payments`create()`, `capture()`, `refund()`, `cancel()`**Express**Quick checkout`create()`, `generateQrCode()`, `createShareableLink()`**Checkout**Full checkout flow`create()`, `updateSession()`, `getPaymentDetails()`**Recurring**Subscriptions`createAgreement()`, `createCharge()`, `stopAgreement()`**OrderManagement**Payment operations`capture()`, `refund()`, `cancel()`, `getPaymentHistory()`**Webhook**Event handling`handleWebhook()`, `verifySignature()`### ePayment Service

[](#epayment-service)

#### Create Payment

[](#create-payment)

```
Vipps::ePayment()->create([
    'amount' => 10000,              // Required: Amount in øre (100.00 NOK)
    'currency' => 'NOK',            // Optional: NOK, DKK, EUR (default: NOK)
    'orderId' => 'order-123',       // Required: Unique order identifier
    'description' => 'Payment for order #123',  // Required: Payment description
    'redirectUrl' => 'https://yoursite.com/callback',  // Required: Callback URL
    'userFlow' => 'WEB_REDIRECT',   // Optional: WEB_REDIRECT, NATIVE_REDIRECT
    'paymentMethod' => 'WALLET',    // Optional: WALLET, CARD
    'skipLandingPage' => false,     // Optional: Skip Vipps landing page
    'userInfo' => [                 // Optional: Pre-fill user information
        'userId' => 'user-123',
        'mobileNumber' => '+4712345678',
        'email' => 'user@example.com'
    ],
    'reference' => 'ref-456'        // Optional: Your internal reference
]);
```

#### Capture Payment

[](#capture-payment)

```
Vipps::ePayment()->capture('order-123', [
    'amount' => 10000,              // Required: Amount to capture
    'description' => 'Capture for order #123',  // Required
    'reference' => 'capture-ref'    // Optional
]);
```

#### Refund Payment

[](#refund-payment)

```
Vipps::ePayment()->refund('order-123', [
    'amount' => 5000,               // Required: Amount to refund
    'description' => 'Partial refund',  // Required
    'reference' => 'refund-ref'     // Optional
]);
```

### Express Service

[](#express-service)

#### Generate QR Code

[](#generate-qr-code)

```
Vipps::express()->generateQrCode([
    'orderId' => 'qr-order-123',
    'amount' => 15000,
    'currency' => 'NOK',
    'description' => 'QR Code Payment',
    'redirectUrl' => 'https://yoursite.com/callback',
    'qrFormat' => 'SVG',            // SVG or PNG
    'qrSize' => 300                 // Size in pixels (100-2000)
]);
```

#### Create Shareable Link

[](#create-shareable-link)

```
Vipps::express()->createShareableLink([
    'orderId' => 'share-order-123',
    'amount' => 20000,
    'currency' => 'NOK',
    'description' => 'Shareable Payment Link',
    'redirectUrl' => 'https://yoursite.com/callback',
    'expiresAt' => now()->addDays(7)  // Optional: Link expiration
]);
```

### Recurring Service

[](#recurring-service)

#### Create Agreement

[](#create-agreement)

```
Vipps::recurring()->createAgreement([
    'currency' => 'NOK',
    'price' => 9900,                // Monthly price in øre
    'productName' => 'Premium Plan', // Max 45 characters
    'productDescription' => 'Monthly premium subscription',  // Max 100 chars
    'merchantRedirectUrl' => 'https://yoursite.com/recurring/success',
    'merchantAgreementUrl' => 'https://yoursite.com/terms',
    'interval' => 'MONTH',          // WEEK, MONTH, YEAR
    'intervalCount' => 1,           // How many intervals between charges
    'isApp' => false,               // True if initiated from mobile app
    'phoneNumber' => '+4712345678', // Optional: Pre-fill phone
    'campaign' => [                 // Optional: Campaign pricing
        'start' => now(),
        'end' => now()->addMonths(3),
        'price' => 4900             // Campaign price in øre
    ]
]);
```

### Order Management Service

[](#order-management-service)

#### Get Payment History

[](#get-payment-history)

```
$history = Vipps::orderManagement()->getPaymentHistory('order-123');
// Returns array of all transactions for the order
```

#### Send Receipt

[](#send-receipt)

```
Vipps::orderManagement()->sendReceipt('order-123', [
    'orderLines' => [
        [
            'name' => 'Premium Subscription',
            'id' => 'sub-001',
            'totalAmount' => 9900,
            'totalAmountExcludingTax' => 7920,
            'totalTaxAmount' => 1980,
            'taxRate' => 25.0,
            'unitInfo' => [
                'unitPrice' => 9900,
                'quantity' => '1',
                'quantityUnit' => 'month'
            ]
        ]
    ],
    'bottomLine' => [
        'currency' => 'NOK',
        'tipAmount' => 500,
        'barcode' => [
            'format' => 'EAN-13',
            'data' => '1234567890123'
        ]
    ]
]);
```

🔗 Webhook Handling
------------------

[](#-webhook-handling)

### Setup Webhook Route

[](#setup-webhook-route)

```
// routes/web.php or routes/api.php
Route::post('/vipps/webhook', [\Mrdulal\LaravelVipps\Http\Controllers\WebhookController::class, 'handle']);
```

### Event Listeners

[](#event-listeners)

```
// app/Providers/EventServiceProvider.php
use Mrdulal\LaravelVipps\Events\{
    PaymentCompleted,
    PaymentCancelled,
    PaymentCaptured,
    PaymentRefunded,
    RecurringAgreementCreated,
    RecurringChargeCreated
};

protected $listen = [
    PaymentCompleted::class => [
        \App\Listeners\HandlePaymentCompleted::class,
    ],
    PaymentCancelled::class => [
        \App\Listeners\HandlePaymentCancelled::class,
    ],
    PaymentCaptured::class => [
        \App\Listeners\HandlePaymentCaptured::class,
    ],
    PaymentRefunded::class => [
        \App\Listeners\HandlePaymentRefunded::class,
    ],
    RecurringAgreementCreated::class => [
        \App\Listeners\HandleRecurringAgreementCreated::class,
    ],
    RecurringChargeCreated::class => [
        \App\Listeners\HandleRecurringChargeCreated::class,
    ],
];
```

### Event Listener Example

[](#event-listener-example)

```
