apriil / nets-easy
Nets Easy library
Requires
- php: ^7.3|^7.4|^8.0
- illuminate/support: ^8.0|^9.0|^10.0|^11.0|^12.0
- nesbot/carbon: >=1.26 <4.0
Requires (Dev)
- vlucas/phpdotenv: >=4.1 <5
This package is auto-updated.
Last update: 2026-06-03 15:20:00 UTC
README
The NETS Easy PHP library provides convenient access to the NETS Easy API from applications written in the PHP language. It includes a pre-defined set of classes for API resources that initialize themselves dynamically from API responses.
Requirements
PHP 8.4 and later. Requires Laravel 13 (illuminate/support ^13.0).
Composer
You can install the bindings via Composer. Run the following command:
composer require apriil/nets-easy
To use the bindings, use Composer's autoload:
require_once('vendor/autoload.php');
Getting Started
Simple usage looks like:
Backend integration
<?php use Nets\Easy; use Nets\Easy\Payment; Easy::setup([ 'secret_key' => '00000000000000000000000000000000', 'checkout_key' => '00000000000000000000000000000000', 'merchant_id' => '000000000' ]); $payment = Payment::create([ 'checkout' => [ 'url' => 'https://domain.tld/checkout', // The exact URL where your checkout is hosted (except query parameters and fragments) 'termsUrl' => 'https://domain.tld/terms', // Your terms ], 'order' => [ 'currency' => 'NOK', 'reference' => '1', // A unique reference for this specific order 'amount' => 10000, // Total order amount in cents 'items' => [ [ 'reference' => '1', // A unique reference for this specific item 'name' => 'Test', 'quantity' => 1, 'unit' => 'pcs', 'unitPrice' => 8000, // Price per unit except tax in cents 'taxRate' => 25000 // Taxrate (e.g 25.0 in this case), 'taxAmount' => 2000 // The total tax amount for this item in cents, 'grossTotalAmount' => 10000 // Total for this item with tax in cents, 'netTotalAmount' => 8000 // Total for this item without tax in cents ] ] ] ]);
Frontend integration
The simplest way to integrate the checkout form in the frontend, is to use the form helper method on the Payment object.
<?php use Nets\Easy; use Nets\Easy\Payment; Easy::setCredentials(...); $payment = isset($_GET['paymentId'] ? Payment::retrieve($_GET['paymentId']) : Payment::create(...); $form = $payment->form([ 'redirect' => 'https://domain.tld/checkout/complete', // URL to redirect to on payment completion (paymentId query parameter is appended) 'theme' => [ // Optional 'textColor' => 'blue', 'linkColor' => '#bada55', 'buttonRadius' => '50px' ] ]); ?> <div id="easy-complete-checkout"></div> <?php echo $form; ?>
Alternatively, if you require full control of checkout flow, implement it manually:
<html> <head> <title>Example checkout</title> </head> <body> <div id="easy-complete-checkout"></div> <script> document.addEventListener('DOMContentLoaded', () => { const checkout = new Dibs.Checkout({ checkoutKey: "00000000000000000000000000000000", // Checkout Key paymentId: "00000000000000000000000000000000", // Payment ID created in the backend integration partnerMerchantNumber: "000000000", // Merchant ID containerId: "easy-complete-checkout", // Container element where the checkout form should be created }) checkout.on('payment-completed', ({ paymentId }) => { // Payment is completed, do what you need to do here }) }) </script> <script src="https://test.checkout.dibspayment.eu/v1/checkout.js?v=1"></script> <!-- or if in production: --> <script src="https://checkout.dibspayment.eu/v1/checkout.js?v=1"></script> </body> </html>
Documentation
See the Official API docs.