PHPackages                             morningtrain/wp-nets-easy - 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. morningtrain/wp-nets-easy

ActiveLibrary[Payment Processing](/categories/payments)

morningtrain/wp-nets-easy
=========================

Nets Easy SDK for WordPress

v0.2.0(2y ago)441MITPHP

Since Jan 2Pushed 2y ago3 watchersCompare

[ Source](https://github.com/Morning-Train/wp-nets-easy)[ Packagist](https://packagist.org/packages/morningtrain/wp-nets-easy)[ RSS](/packages/morningtrain-wp-nets-easy/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (7)Used By (0)

Morningtrain\\WpNetsEasy
========================

[](#morningtrainwpnetseasy)

A Morningtrain package to simple handle NETS Easy payments.

Table of Contents
-----------------

[](#table-of-contents)

- [Introduction](#introduction)
- [Getting Started](#getting-started)
    - [Installation](#installation)
- [Dependencies](#dependencies)
    - [illuminate/database](#illuminatedatabase)
- [Usage](#usage)
    - [Initializing package](#initializing-package)
    - [Create payment](#create-payment)
    - [Handle existing payment](#handle-existing-payment)
    - [Create subscription](#create-subscription)
    - [Handle existing subscription](#handle-existing-subscription)
    - [Handle webhooks](#handle-webhooks)
- [Credits](#credits)
- [Testing](#testing)
- [License](#license)

Introduction
------------

[](#introduction)

Getting Started
---------------

[](#getting-started)

To get started install the package as described below in [Installation](#installation).

To use the tool have a look at [Usage](#usage)

### Installation

[](#installation)

Install with composer

```
composer require morningtrain/wp-nets-easy
```

Dependencies
------------

[](#dependencies)

- [morningtrain/wp-route](https://packagist.org/packages/morningtrain/wp-route)
- [morningtrain/wp-database](https://packagist.org/packages/morningtrain/wp-database)
- [morningtrain/php-loader](https://packagist.org/packages/morningtrain/php-loader)

Usage
-----

[](#usage)

### Initializing package

[](#initializing-package)

Initialize `\Morningtrain\WpNetsEasy\NetsEasy` with NETS Easy test or live secret key.

```
\Morningtrain\WpNetsEasy\NetsEasy::init('live-secret-key-abcdefghijklmnopqrstuvwxyz123456789');
```

### Running migrations

[](#running-migrations)

This needs to be done before using the package, or after updating the package.
You can run all new migrations like so:

Using `wp cli`:

```
wp dbmigrate
```

Using `php`:

```

```

### Create payment

[](#create-payment)

```
use Morningtrain\WpNetsEasy\Classes\Payment\Payment;
use Morningtrain\WpNetsEasy\Classes\Payment\Customer;
use Morningtrain\WpNetsEasy\Classes\Payment\Address;
use Morningtrain\WpNetsEasy\Classes\Payment\Item;

// Create payment and set payment information and urls
$payment = Payment::create()
    ->setReference($orderId)
    ->setCustomer(
        Customer::create()
            ->setReference($customer->id)
            ->setEmail($customer->email)
            ->setPhone($customer->phone)
            ->setName($customer->firstName, $customer->lastName)
            ->setCompanyName($customer->companyName)
            ->setShippingAddress(
                Address::create()
                    ->setAddressLine1($customer->address1)
                    ->setAddressLine2($customer->address2)
                    ->setPostalCode($customer->zipCode)
                    ->setCity($customer->city())
            )
        )
    ->setTermsUrl(get_post_permalink($termsPageId))
    ->setReturnUrl(Route::route('payment-success', ['token' => $order->token]))
    ->setCancelUrl(Route::route('payment-cancel', ['token' => $order->token]));

// Add items to payments
foreach($order->items as $item) {
    $payment->addItem(
        Item::create($item->sku)
            ->setName($item->name)
            ->setQuantity($item->quantity)
            ->setUnitPriceInclusiveTax($item->price)
    );
}

// Persist payment in NETS Easy
$response = $payment->createRequest();

if(wp_remote_retrieve_response_code($response) !== 201) {
    // Error handling when something was wrong with the payment
    wp_redirect($checkoutUrl);
    exit();
}

// Save payment reference to order
$order->setPaymentId($payment->getPaymentId());

// Redirect to payment page
wp_redirect($payment->getPaymentPageUrl());
exit();
```

#### Auto charge payment

[](#auto-charge-payment)

If your product allows you to auto charge payment. You can tell Nets Easy to charge the payment automatically before you persist the payment.

```
$payment->autoCharge()
```

### Handle existing payment

[](#handle-existing-payment)

When a payment requrest has been created, the payment reference will be saved to the database.

#### Get payment

[](#get-payment)

Payment is a model implementet with Eloquent. To get payments you can use all methods from Eloquent (see [documentation](https://laravel.com/docs/9.x/eloquent#retrieving-models)).

You can use the custom method `Payment::getByPaymentId($paymentId);`

```
$payment = Payment::getByPaymentId($order->payment_id);
```

#### Terminate payment

[](#terminate-payment)

To terminate payment, the customer must not have finished checkout. You can use it on the cancel callback to avoid double payments later.

```
$payment->terminate()
```

#### Check if payment is reserved

[](#check-if-payment-is-reserved)

```
$payment->isReserved()
```

#### Check if payment is charged

[](#check-if-payment-is-charged)

```
$payment->isCharged()
```

#### Charge payment

[](#charge-payment)

```
$payment->charge()
```

*NOTE: Partly charges is not implementet yet*

#### Refund payment

[](#refund-payment)

*NOTE: Refund and partly refund is not implementet yet*

### Create subscription

[](#create-subscription)

*NOTE: Subscriptions is not implementet yet*

### Handle existing subscription

[](#handle-existing-subscription)

*NOTE: Subscriptions is not implementet yet*

### Handle webhoks

[](#handle-webhoks)

The implementation handle webhooks and sets the payment status automatically.

If you need to do something on a specific webhook, you can do that throug actions and filters.

#### List of implemented webhooks

[](#list-of-implemented-webhooks)

NameDescritpionpayment.createdA payment has been created.payment.reservation.createdThe amount of the payment has been reserved.payment.reservation.failedA reservation attempt has failed.payment.checkout.completedThe customer has completed the checkout.payment.charge.created.v2The customer has successfully been charged, partially or fully.payment.charge.failedA charge attempt has failed.payment.refund.initiated.v2A refund has been initiated.payment.refund.failedA refund attempt has failed.payment.refund.completedA refund has successfully been completed.payment.cancel.createdA reservation has been canceled.payment.cancel.failedA cancellation has failed.#### Actions

[](#actions)

Hook NameDescriptionmorningtrain/nets-easy/webhook/{$webhookName}Do something on the webhook (before the implementet handling but after we have checked for previous handling)#### Filters

[](#filters)

Hook NameFiltered valueExtra parametersDescriptionmorningtrain/nets-easy/webhook/{$webhookName}/bypassfalsenoneReturn something to bypass all webhook handling logicmorningtrain/nets-easy/webhook/{$webhookName}/after-handlefalse or value from handle function$webhook - The Webhook object with dataDo something after default handling. Return something to bypass setting the webhook as handled and return status 200morningtrain/nets-easy/webhook/{$webhookName}/responseWP\_REST\_Response with default values (status 200)$webhook - The Webhook object with dataFilter the response after webhook fully handledCredits
-------

[](#credits)

- [Martin Schadegg Brønniche](https://github.com/mschadegg)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 86.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~89 days

Recently: every ~111 days

Total

6

Last Release

781d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/278725?v=4)[morningtrain](/maintainers/morningtrain)[@morningtrain](https://github.com/morningtrain)

---

Top Contributors

[![mschadegg](https://avatars.githubusercontent.com/u/11231039?v=4)](https://github.com/mschadegg "mschadegg (25 commits)")[![matbaek](https://avatars.githubusercontent.com/u/2310644?v=4)](https://github.com/matbaek "matbaek (3 commits)")[![larasmorningtrain](https://avatars.githubusercontent.com/u/86046759?v=4)](https://github.com/larasmorningtrain "larasmorningtrain (1 commits)")

---

Tags

netspaymentpaymentsphpwordpresswp

### Embed Badge

![Health badge](/badges/morningtrain-wp-nets-easy/health.svg)

```
[![Health](https://phpackages.com/badges/morningtrain-wp-nets-easy/health.svg)](https://phpackages.com/packages/morningtrain-wp-nets-easy)
```

###  Alternatives

[omnipay/paypal

PayPal gateway for Omnipay payment processing library

3156.8M53](/packages/omnipay-paypal)[eduardokum/laravel-boleto

Biblioteca com boletos para o laravel

626351.9k2](/packages/eduardokum-laravel-boleto)[tbbc/money-bundle

This is a Symfony bundle that integrates moneyphp/money library (Fowler pattern): https://github.com/moneyphp/money.

1961.9M](/packages/tbbc-money-bundle)[2checkout/2checkout-php

2Checkout PHP Library

83740.3k2](/packages/2checkout-2checkout-php)[smhg/sepa-qr-data

Generate QR code data for SEPA payments

61717.2k5](/packages/smhg-sepa-qr-data)[omnipay/dummy

Dummy driver for the Omnipay payment processing library

271.2M33](/packages/omnipay-dummy)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
