{"id":28311029,"url":"https://github.com/morning-train/nets-easy","last_synced_at":"2026-03-03T22:31:09.852Z","repository":{"id":292820341,"uuid":"963179374","full_name":"Morning-Train/NETS-Easy","owner":"Morning-Train","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-04T17:50:21.000Z","size":48,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-16T05:44:48.993Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Morning-Train.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"Morningtrain"}},"created_at":"2025-04-09T09:27:10.000Z","updated_at":"2025-06-04T17:50:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"568424b7-4ec4-4a02-a0ed-4074789a45b7","html_url":"https://github.com/Morning-Train/NETS-Easy","commit_stats":null,"previous_names":["morning-train/nets-easy"],"tags_count":0,"template":false,"template_full_name":"spatie/package-skeleton-laravel","purl":"pkg:github/Morning-Train/NETS-Easy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morning-Train%2FNETS-Easy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morning-Train%2FNETS-Easy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morning-Train%2FNETS-Easy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morning-Train%2FNETS-Easy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Morning-Train","download_url":"https://codeload.github.com/Morning-Train/NETS-Easy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morning-Train%2FNETS-Easy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30064278,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T18:21:05.932Z","status":"ssl_error","status_checked_at":"2026-03-03T18:20:59.341Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-24T12:10:23.928Z","updated_at":"2026-03-03T22:31:09.836Z","avatar_url":"https://github.com/Morning-Train.png","language":"PHP","funding_links":["https://github.com/sponsors/Morningtrain"],"categories":[],"sub_categories":[],"readme":"# Nets Easy for MorningMedley \u0026 Laravel\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Setup your .env file](#setup-your-env-file)\n  - [Running migrations](#running-migrations)\n  - [Create payment](#create-payment)\n  - [Handle existing payment](#handle-existing-payment)\n    - [Get Payment](#get-payment)\n    - [Create payment](#create-payment-1)\n    - [Terminate payment](#terminate-payment)\n    - [Cancel payment](#cancel-payment)\n    - [Charge payment](#charge-payment)\n  - [Handle webhooks](#handle-webhooks)\n    - [List of implemented webhooks](#list-of-implemented-webhooks)\n    - [Actions](#actions)\n-  [Testing](#testing)\n- [Credits](#credits)\n- [License](#license)\n\nThis is where your description should go. Limit it to a paragraph or two. Consider adding a small example.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require morningtrain/nets-easy\n```\n\n### For Laravel\n\nYou can publish and run the migrations with:\n\n```bash\nphp artisan vendor:publish --tag=\"nets-easy-migrations\"\nphp artisan migrate\n```\n\nYou can publish the config file with:\n\n```bash\nphp artisan vendor:publish --tag=\"nets-easy-config\"\n```\n\nThis is the contents of the published config file:\n\n```php\nreturn [\n    'auth-key' =\u003e env('NETS_EASY_AUTH_KEY'),\n    'events' =\u003e [\n        'payment.cancel.created' =\u003e \\Morningtrain\\NETSEasy\\Events\\PaymentCancelCreated::class,\n        'payment.cancel.failed' =\u003e \\Morningtrain\\NETSEasy\\Events\\PaymentCancelFailed::class,\n        'payment.charge.created.v2' =\u003e \\Morningtrain\\NETSEasy\\Events\\PaymentChargeCreatedV2::class,\n        'payment.charge.failed' =\u003e \\Morningtrain\\NETSEasy\\Events\\PaymentChargeFailed::class,\n        'payment.checkout.completed' =\u003e \\Morningtrain\\NETSEasy\\Events\\PaymentCheckoutCompleted::class,\n        'payment.created' =\u003e \\Morningtrain\\NETSEasy\\Events\\PaymentCreated::class,\n        'payment.refund.completed' =\u003e \\Morningtrain\\NETSEasy\\Events\\PaymentRefundCompleted::class,\n        'payment.refund.failed' =\u003e \\Morningtrain\\NETSEasy\\Events\\PaymentRefundFailed::class,\n        'payment.refund.initiated.v2' =\u003e \\Morningtrain\\NETSEasy\\Events\\PaymentRefundInitiatedV2::class,\n        'payment.reservation.created.v2' =\u003e \\Morningtrain\\NETSEasy\\Events\\PaymentReservationCreatedV2::class,\n        'payment.reservation.failed' =\u003e \\Morningtrain\\NETSEasy\\Events\\PaymentReservationFailed::class,\n    ],\n    'in_test_mode' =\u003e env('NETS_EASY_IN_TEST_MODE', true),\n    'secret_key' =\u003e env('NETS_EASY_SECRET_KEY'),\n];\n\n```\n\n## Usage\n\n### Setup your .env file\n\n```dotenv\nNETS_EASY_AUTH_KEY={random_string}\nNETS_EASY_IN_TEST_MODE={true|false}\nNETS_EASY_SECRET_KEY={SECRET_KEY}\n```\n\n### Running migrations\n#### For Laravel\n\n```bash\nphp wp artisan migrate\n```\n#### For Laravel\n\n```bash\nphp artisan migrate\n```\n\n### Create payment\n\n```php\n// Create payment and set payment information and urls\n$netsEasyPayment = \\Morningtrain\\NETSEasy\\NETSEasy::makeNetsEasyPaymentFromPaymentDTO(\n    new \\Morningtrain\\NETSEasy\\DTOs\\Payment(\n        reference: $order-\u003eid,\n        items: [\n            new \\Morningtrain\\NETSEasy\\DTOs\\Item(\n                reference: $orderItem-\u003esku,\n                name: $orderItem-\u003ename,\n                unitPrice: $orderItem-\u003eprice,\n                unit: 'pcs',\n                quantity: $orderItem-\u003equantity,\n                taxRate: $orderItem-\u003etax_rate,\n                taxIncluded: true,\n            ),\n        ],\n        currency: 'DKK',\n        termsUrl: 'https://example.com/terms',\n        returnUrl: 'https://example.com/success?token=' . $order-\u003etoken,\n        cancelUrl: 'https://example.com/cancel',\n        customer: new \\Morningtrain\\NETSEasy\\DTOs\\Customer(\n            reference: $customer-\u003eid, \n            email: $customer-\u003eemail,\n            firstName: $customer-\u003efirst_name,\n            lastName: $customer-\u003elast_name,\n            phoneNumber: 12345678,\n            phoneCountryPrefix: 45,\n            billingAddress: new \\Morningtrain\\NETSEasy\\DTOs\\Address(\n                addressLine1: $customer-\u003eaddress1,\n                addressLine2: $customer-\u003eaddress2,\n                postalCode: $customer-\u003ezip_code,\n                city: $order-\u003ecity,\n                country: CountryCode::tryFromName('DK')?-\u003evalue,\n            ),\n        ),\n        autoCharge: true\n    )\n);\n\ntry {\n    $response = $netsEasyPayment-\u003ecreate();\n} catch (ConnectionException $e) {\n    return new \\WP_REST_Response(['errors' =\u003e [__('Fejl ved oprettelse af ordre.', 'great-northern')]], 406);\n}\n\nif ($response-\u003egetStatusCode() !== 201) {\n    wp_redirect($checkoutUrl);\n    exit();\n}\n\n// Save payment id for later use\n// $netsEasyPayment-\u003egetPaymentId()\n\n// Redirect to payment page\nwp_redirect($response-\u003egetPaymentPageUrl());\nexit();\n```\n\n### Handle existing payment\n\n#### Get Payment\n\n```php\n$netsEasyPayment = \\Morningtrain\\NETSEasy\\NETSEasy::makeNetsEasyPaymentFromPaymentId($paymentId);\n```\n\n#### Create payment\n\n```php\n$netsEasyPayment-\u003ecreate();\n```\n\n#### Terminate payment\nTo terminate payment, the customer must not have finished checkout. You can use it on the cancel callback to avoid double payments later.\n\n```php\n$netsEasyPayment-\u003eterminate();\n```\n\n#### Cancel payment\n\n```php\n$netsEasyPayment-\u003ecancel();\n```\n\n#### Charge payment\n\n```php\n$netsEasyPayment-\u003echarge();\n```\n\n### Handle webhooks\nThe implementation handle webhooks and sets the payment status automatically.\n\nIf you need to do something on a specific webhook, you can do that throug actions and filters.\n\n#### List of implemented webhooks\n\n| Name                        | Descritpion                                                     |\n|-----------------------------|-----------------------------------------------------------------|\n| payment.created             | A payment has been created.                                     |\n| payment.reservation.created | The amount of the payment has been reserved.                    |\n| payment.reservation.failed  | A reservation attempt has failed.                               |\n| payment.checkout.completed  | The customer has completed the checkout.                        |\n| payment.charge.created.v2   | The customer has successfully been charged, partially or fully. |\n| payment.charge.failed       | A charge attempt has failed.                                    |\n| payment.refund.initiated.v2 | A refund has been initiated.                                    |\n| payment.refund.failed       | A refund attempt has failed.                                    |\n| payment.refund.completed    | A refund has successfully been completed.                       |\n| payment.cancel.created      | A reservation has been canceled.                                |\n| payment.cancel.failed       | A cancellation has failed.                                      |\n\n#### Actions\n\n| Hook Name                                     | Description                                      |\n|-----------------------------------------------|--------------------------------------------------|\n| morningtrain/nets-easy/webhook/{$webhookName} | Do something when the webhook is being processed |\n\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Credits\n\n- [Mathias B](https://github.com/matbaek)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorning-train%2Fnets-easy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorning-train%2Fnets-easy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorning-train%2Fnets-easy/lists"}