netbums/laravel-quickpay
Composer 安装命令:
composer require netbums/laravel-quickpay
包简介
A fluent api around the quickpay api for Laravel applications
README 文档
README
This laravel package will help you utilize the Quickpay API Client, without knowing too much about the endpoints. It provides a fluent api for using the API. See examples below.
Support me
Consider supporting me by sponsoring my work
Installation
- You can install the package via composer:
composer require netbums/laravel-quickpay
- Publish the config file with:
php artisan vendor:publish
Search for "quickpay", and publish both the config and Netbums\Quickpay\QuickpayServiceProvider
This is the contents of the published config file:
// config/quickpay.php return [ 'api_key' => env('QUICKPAY_API_KEY'), 'login' => env('QUICKPAY_LOGIN'), 'password' => env('QUICKPAY_PASSWORD'), 'merchant_id' => env('QUICKPAY_MERCHANT_ID'), ];
- Add the environment variables to your
.envfile:
QUICKPAY_API_KEY=
And alternatively, you can add the following environment variables to your .env file instead of the QUICKPAY_API_KEY:
QUICKPAY_LOGIN= QUICKPAY_PASSWORD= QUICKPAY_MERCHANT_ID=
Usage
Payments
Get all payments
use \Netbums\Quickpay\Facades\Quickpay; $payments = Quickpay::payments()->all();
Get a payment
Getting a single payment by id
use \Netbums\Quickpay\Facades\Quickpay; $payment = Quickpay::payments()->find($paymentId);
Create a payment
First create a basket with items, and then create a payment with the basket and a unique order id.
use \Netbums\Quickpay\DataObjects\Basket; use \Netbums\Quickpay\DataObjects\BasketItem; use \Netbums\Quickpay\DataObjects\Payment; use \Netbums\Quickpay\Facades\Quickpay; $basket = new Basket( items: [ new BasketItem( qty: 1, item_name: 'Test item', item_no: 'sku-1234', item_price: 100, // in smallest currency unit vat_rate: 0.25, // 25% ) ] ); $paymentData = new Payment( currency: 'DKK', order_id: '1234', basket: $basket, ); $createdPayment = Quickpay::payments()->create( payment: $paymentData );
After a payment is created you can create a payment link for it, and redirect the user to the payment link.
Create a payment link
use \Netbums\Quickpay\Facades\Quickpay; use \Netbums\Quickpay\DataObjects\PaymentLink; $paymentLinkData = new PaymentLink( id: $createdPayment['id'], amount: 100 ); $paymentLink = Quickpay::payments()->createLink($paymentLinkData);
This will return a URL, that you can redirect the user to.
Update a payment
Capture a payment
Capture a payment. This will capture the amount of the payment specified.
use \Netbums\Quickpay\Facades\Quickpay; $payment = Quickpay::payments()->capture( id: $paymentId, amount: 100, // in smallest currency unit );
Refund a payment
Refund a payment. This will refund the amount of the payment specified.
use \Netbums\Quickpay\Facades\Quickpay; $payment = Quickpay::payments()->refund( id: $paymentId, amount: 100, // in smallest currency unit );
Authorize a payment
Authorize a payment. This will reserve the amount on the card, but not capture it.
use \Netbums\Quickpay\Facades\Quickpay; $payment = Quickpay::payments()->authorize( id: $paymentId, amount: 100, // in smallest currency unit );
Renew authorization of a payment
Renew the authorization of a payment. This will reserve the amount on the card, but not capture it.
use \Netbums\Quickpay\Facades\Quickpay; $payment = Quickpay::payments()->renew( id: $paymentId, );
Cancel a payment
Cancel a payment. This will cancel the payment, and release the reserved amount on the card.
use \Netbums\Quickpay\Facades\Quickpay; $payment = Quickpay::payments()->cancel( id: $paymentId, );
Create a payment link
Create a payment link for a payment. Optional parameters are: language, continue_url, cancel_url, callback_url:
use \Netbums\Quickpay\Facades\Quickpay; use \Netbums\Quickpay\DataObjects\PaymentLink; $paymentLinkData = new PaymentLink( id: $paymentId, amount: 100, // in smallest currency unit language: 'da', continue_url: 'https://example.com/continue', cancel_url: 'https://example.com/cancel', callback_url: 'https://example.com/callback', ); $paymentLink = Quickpay::payments()->createPaymentLink( paymentLink: $paymentLinkData, );
Create a payment session
use \Netbums\Quickpay\Facades\Quickpay; $session = Quickpay::payments()->session( id: $paymentId, amount: 100, // in smallest currency unit );
Create Fraud Report
Create a fraud report for a payment. Optional parameters are: description:
use \Netbums\Quickpay\Facades\Quickpay; $fraudReport = Quickpay::payments()->createFraudReport( id: $paymentId, description: 'Fraudulent payment', );
Subscriptions
The Quickpay::subscriptions() facade provides a fluent API for interacting with Quickpay Subscription endpoints.
Get all subscriptions
use \Netbums\Quickpay\Facades\Quickpay; $subscriptions = Quickpay::subscriptions()->all();
Get a subscription
Get a single subscription by id.
use \Netbums\Quickpay\Facades\Quickpay; $subscriptionId = 'your_subscription_id'; $subscription = Quickpay::subscriptions()->find($subscriptionId);
Create a subscription link
Create a payment link for a subscription. Requires a SubscriptionLink DataObject.
use \Netbums\Quickpay\Facades\Quickpay; use \Netbums\Quickpay\DataObjects\SubscriptionLink; $subscriptionLinkData = new SubscriptionLink( id: $createdSubscription['id'], amount: 100, // in smallest currency unit order_id: 'link_'.uniqid(), language: 'en', continue_url: 'https://example.com/continue', cancel_url: 'https://example.com/cancel', callback_url: 'https://example.com/callback' // API ); $subscriptionLink = Quickpay::subscriptions()->createSubscriptionLink($subscriptionLinkData);
Delete a subscription payment link
Delete the payment link for a subscription.
use \Netbums\Quickpay\Facades\Quickpay; $subscriptionId = 'your_subscription_id'; Quickpay::subscriptions()->deletePaymentLink($subscriptionId);
Create a subscription
Create a new subscription. Requires a Subscription DataObject.
use \Netbums\Quickpay\Facades\Quickpay; use \Netbums\Quickpay\DataObjects\Subscription; $subscriptionData = new Subscription( currency: 'DKK', order_id: 'order_'.uniqid(), description: 'Subscription description', // Example description // Add other relevant Subscription properties based on Quickpay docs if known // e.g., frequency: 30 ); $createdSubscription = Quickpay::subscriptions()->create($subscriptionData);
Update a subscription
Update a subscription. Requires the subscription ID and an array of data.
use \Netbums\Quickpay\Facades\Quickpay; $subscriptionId = 'your_subscription_id'; $updateData = [ 'state' => 'active', // ... other update properties ]; $updatedSubscription = Quickpay::subscriptions()->update($subscriptionId, $updateData);
Authorize a subscription
Authorize a subscription.
use \Netbums\Quickpay\Facades\Quickpay; $subscriptionId = 'your_subscription_id'; $authorizedSubscription = Quickpay::subscriptions()->authorize($subscriptionId);
Cancel a subscription
Cancel a subscription.
use \Netbums\Quickpay\Facades\Quickpay; $subscriptionId = 'your_subscription_id'; $canceledSubscription = Quickpay::subscriptions()->cancel($subscriptionId);
Create a recurring payment
Create a recurring payment for a subscription.
use \Netbums\Quickpay\Facades\Quickpay; use \Netbums\Quickpay\DataObjects\SubscriptionRecurring; $subscriptionRecurringData = new SubscriptionRecurring( id: $subscriptionId, amount: 100 // in smallest currency unit // ... other SubscriptionRecurring properties ); $recurringPayment = Quickpay::subscriptions()->createRecurring($subscriptionRecurringData);
Create a fraud report
Create a fraud report for a subscription.
use \Netbums\Quickpay\Facades\Quickpay; $subscriptionId = 'your_subscription_id'; $fraudReport = Quickpay::subscriptions()->fraudReport($subscriptionId);
Get subscription payments
Get payments associated with a subscription.
use \Netbums\Quickpay\Facades\Quickpay; $subscriptionId = 'your_subscription_id'; $payments = Quickpay::subscriptions()->getPayments($subscriptionId);
Exception Handling
Dedicated exception classes are provided for handling errors during subscription operations. These include:
FetchSubscriptionFailedFetchSubscriptionsFailedCreateRecurringFailedCreateSubscriptionFailedCreateSubscriptionLinkFailedDeletePaymentLinkFailedUpdateSubscriptionFailedAuthorizeSubscriptionFailedCancelSubscriptionFailedFraudReportSubscriptionFailedGetSubscriptionPaymentsFailed
You should wrap your Quickpay subscription calls in try-catch blocks to handle these specific exceptions.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
netbums/laravel-quickpay 适用场景与选型建议
netbums/laravel-quickpay 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 64 次下载、GitHub Stars 达 22, 最近一次更新时间为 2024 年 01 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「Netbums」 「laravel-quickpay」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 netbums/laravel-quickpay 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 netbums/laravel-quickpay 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 netbums/laravel-quickpay 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Alfabank REST API integration
This is a preset for laravel subscription through stripe
Laravel package for Accurate Online API integration.
Shared RCX Laravel DataTables UI and configuration helpers.
Boot a Laravel project on any machine with one command: app:serve installs missing tools (PHP, Node, Composer, Herd, Docker), creates .env, sets up the database, runs migrations, builds assets, starts a queue worker and serves via Herd, Sail or artisan serve; app:down cleanly stops everything it sta
Branded, diagnostic error pages (500, 403, 404, 419, 503) for Filament — native Filament UI, dark mode and translations out of the box.
统计信息
- 总下载量: 64
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 23
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-01-09