chapdel/notchpay-php
Composer 安装命令:
composer require chapdel/notchpay-php
包简介
Notch Pay PHP Wrapper.
关键字:
README 文档
README
A PHP API wrapper for Notch Pay.
Installation
You can install the package via composer:
composer require notchpay/notchpay-php
Usage
Do a redirect to the authorization URL received from calling the payments/initialize endpoint. This URL is valid for one time use, so ensure that you generate a new URL per payment.
When the payment is successful, we will call your callback URL (as setup in your dashboard or while initializing the transaction) and return the reference sent in the first step as a query parameter.
If you use a test public key, we will call your test callback url, otherwise, we'll call your live callback url.
0. Prerequisites
Confirm that your server can conclude a TLSv1.2 connection to Notch Pay's servers. Most up-to-date software have this capability. Contact your service provider for guidance if you have any SSL errors. Don't disable SSL peer verification!
1. Prepare your parameters
email, amount and currency are the most common compulsory parameters. Do send a unique email per customer.
The amount accept numeric value value.
The currency accept currency ISO 3166.
For instance, to accept For US Dollar, please send USD as the currency.
2. Initialize a onetime payments
Initialize a payment by calling our API.
use NotchPay\NotchPay; use NotchPay\Payment; NotchPay::setApiKey('sk_1234abcd'); try { $tranx = Payment::initialize([ 'amount'=>$amount, // according to currency format 'email'=>$email, // unique to customers 'currency'=>$currency, // currency iso code 'callback'=>$callback, // optional callback url 'reference'=>$reference, // unique to transactions ]); } catch(\NotchPay\Exceptions\ApiException $e){ print_r($e->errors); die($e->getMessage()); } // redirect to page so User can pay header('Location: ' . $tranx->authorization_url);
When the user enters their payment details, NotchPay will validate and charge the card. It will do all the below:
Send a payment.complete event to your Webhook URL set at: https://business.notchpay.co/settings/developer
If receipts are not turned off, an HTML receipt will be sent to the customer's email.
3. Verify Transaction
After we redirect to your callback, please verify the transaction before giving value.
$reference = isset($_GET['reference']) ? $_GET['reference'] : ''; if(!$reference){ die('No reference supplied'); } // initiate the Library's NotchPay Object NotchPay::setApiKey('sk_1234abcd'); try { $tranx = Payment::verify($reference); if ($tranx->transaction->status === 'complete') { // transaction was successful... // please check other things like whether you already gave value for this ref // if the email matches the customer who owns the product etc // Give value } } catch(\NotchPay\Exceptions\ApiException $e){ print_r($e->errors); die($e->getMessage()); }
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email hello@notchpay.co instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.
chapdel/notchpay-php 适用场景与选型建议
chapdel/notchpay-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 01 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「curl」 「api」 「payment」 「customer」 「gateway」 「payment processing」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 chapdel/notchpay-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 chapdel/notchpay-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 chapdel/notchpay-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
cURL and cURL based Soap-Client for PHP
Simple cURL wrapper
A PSR-7 compatible library for making CRUD API endpoints
A fluent PHP CURL wrapper
Build mini web servers in PHP for testing
Async Curl using React\ChildProcess
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-01-18