apility/nets-easy-omnipay
Composer 安装命令:
composer require apility/nets-easy-omnipay
包简介
Nets Easy driver for the Omnipay PHP payment processing library
README 文档
README
Nets Easy driver for the Omnipay PHP payment processing library
Omnipay is a framework agnostic, multi-gateway payment processing library for PHP. This package implements Stripe support for Omnipay.
Table Of Contents
Installation
Omnipay is installed via Composer. To install, simply require league/omnipay and apility/nets-easy-omnipay with Composer:
composer require league/omnipay apility/nets-easy-omnipay
Basic Usage
The following gateway os provided by this package:
For general usage instructions, please see the main Omnipay repository.
Initial setup
<?php use Omnipay\Common\GatewayFactory; use Apility\Omnipay\NetsEasy\Gateway as NetsEasyGateway; $factory = new GatewayFactory(); $gateway = $factory->create(NetsEasyGateway::class); $gateway->setMerchantNumber(/* ... */); $gateway->setSecretKey(/* ... */); $gateway->setCheckoutKey(/* ... */); // Some API keys contains the "test-" prefix. If this is present, we automatically enable test mode. // However, if your API key does not contain this prefix, you can manually toggle test mode using this method: $gateway->setTestMode(true);
Hosted Payment Page
If you don't want to host the checkout page yourself (EmbeddedCheckout), you may the the HostedPaymentPage integration type. This will use a checkout page hosted by Nexi Group.
authorize.php
```php <?php use Apility\Omnipay\NetsEasy\Types\Checkout\IntegrationType; $authorization = $gateway->authorize([ // ... 'checkout' => [ // ... 'returnUrl' => 'http://example.com/callback.php', 'integrationType' => IntegrationType::HostedPaymentPage // ... ] ])->send(); if (!$authorization->isSuccessful()) { if ($authorization->isRedirect()) { return $authorization->redirect(); } die('Authorize failed: ' . $authorization->getMessage()); } header('Location: /callback.php?paymentid=' . $authorization->getPaymentId());
callback.php
<?php $transaction = $gateway->fetchTransaction(['paymentId' => $_GET['paymentid']])->send(); if (!$transaction->isSuccessful()) { die('Failed to fetch transaction: ' . $transaction->getMessage()); } if ($transaction->getChargedAmount()) { header('Location: /receipt.php?paymentid=' . $transaction->getPaymentId()); return; } if ($transaction->getCancelledAmount() > 0) { die('Payment was cancelled: ' . $transaction->getPaymentId()); return; } if ($transaction->getRefundedAmount() > 0) { die('Payment refunded: ' . $transaction->getPaymentId()); } if ($transaction->getUnscheduledSubscriptionId()) { header('Location: /unscheduledSubscriptionCallback.php?paymentid=' . $transaction->getPaymentId()); return; } header('Location: /capture.php?paymentid=' . $transaction->getPaymentId());
capture.php
<?php $transaction = $gateway->fetchTransaction(['paymentId' => $_GET['paymentid']])->send(); if (!$transaction->isSuccessful()) { die('Failed to fetch transaction: ' . $transaction->getMessage()); } if ($transaction->getCancelledAmount() > 0) { die('Cannot capture payment, already cancelled: ' . $transaction->getPaymentId()); } if ($transaction->getRefundedAmount() > 0) { die('Cannot capture payment, already refunded: ' . $transaction->getPaymentId()); } if (!$transaction->getReservedAmount()) { header('Location: ' . $transaction->getCheckoutUrl()); return; } if ($transaction->getChargedAmount() == $transaction->getReservedAmount()) { header('Location: /receipt.php?paymentid=' . $transaction->getPaymentId()); return; } $capture = $gateway->capture([ 'paymentId' => $transaction->getPaymentId(), 'amount' => $transaction->getReservedAmount(), ])->send(); if (!$capture->isSuccessful()) { die('Capture failed: ' . $capture->getMessage()); } header('Location: /receipt.php&paymentid=' . $transaction->getPaymentId());
Checkout JS SDK
The Nets Easy integration is fairly straight forward. Essentially you just pass
the checkoutKey and paymentId fields through to Nets Easy instead of the regular authorization flow.
Start by following the standard Stripe JS guide here: https://developer.nexigroup.com/nexi-checkout/en-EU/api/checkout-js-sdk/
Example:
Backend
<?php use Apility\Omnipay\NetsEasy\Types\Checkout\IntegrationType; $authorization = $gateway->authorize([ // ... 'checkout' => [ // ... 'integrationType' => IntegrationType::EmbeddedCheckout // ... ] ])->send(); if (!$authorization->isSuccessful()) { die('Authorization failed: ' . $authorization->getMessage()); } $paymentId = $authorization->getPaymentId(); $checkoutKey = $gateway->getCheckoutKey();
Frontend
<!-- Production --> <script src="https://checkout.dibspayment.eu/v1/checkout.js?v=1"></script> <!-- Test --> <script src="https://test.checkout.dibspayment.eu/v1/checkout.js?v=1"></script> <script> const checkoutOptions = { checkoutKey: "<?php echo $checkoutKey; ?>", paymentId : "<?php echo $paymentId; ?>", containerId : "checkout-container-div", language: "en-GB" }; const checkout = new Dibs.Checkout(checkoutOptions); checkout.on('payment-completed', function(response) { window.location.href = '/callback.php?paymentid=' + response.paymentId; }); </script> <div id="checkout-container-div"></div> </html>
Example Implementation
A fully implemented example can be found in the example directory.
To serve this example navigate to the example directory and start up a php server on port 8000:
cd examples
php -S localhost:8000
You need valid credentials for Nets Easy to run the examples.
Copy the .env.example file to a new file named .env in the same directory. Add your credentials to the .env file.
You can now open http://localhost:8000 in your browser.
Copyright © 2025 Apility AS
apility/nets-easy-omnipay 适用场景与选型建议
apility/nets-easy-omnipay 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 127 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 01 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「payment」 「pay」 「gateway」 「merchant」 「omnipay」 「nets」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 apility/nets-easy-omnipay 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 apility/nets-easy-omnipay 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 apility/nets-easy-omnipay 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Payyo Gateway for the Omnipay payment processing library
Библиотека для приема платежей через Альфабанк.
Some pre-defined rules for validation in Omnipay payment processing library.
BluePay gateway for the Omnipay payment processing library
支付宝接口扩展包
统计信息
- 总下载量: 127
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-30