nicolasflamel/mwc-pay
Composer 安装命令:
composer require nicolasflamel/mwc-pay
包简介
PHP SDK for MWC Pay
README 文档
README
Description
PHP SDK for MWC Pay.
Installing
Run the following command from the root of your project to install this library and configure your project to use it.
composer require nicolasflamel/mwc-pay
Usage
After an MwcPay object has been created, it can be used to create payments, query the status of payments, get the current price of MimbleWimble coin, and get info about MWC Pay's public server.
A high level overview of a payment's life cycle when using this SDK consists of the following steps:
- The merchant creates a payment and gets the payment's URL from the response.
- The buyer sends MimbleWimble Coin to that URL.
- The merchant can optionally monitor the payment's status via the
getPaymentInfomethod, thecreatePaymentmethod'sreceivedCallbackparameter, thecreatePaymentmethod'sconfirmedCallbackparameter, and/or thecreatePaymentmethod'sexpiredCallbackparameter. - The payment's completed callback is ran once the payment achieves the desired number of on-chain confirmations.
The following code briefly shows how to use this SDK. A more complete example with error checking is available here.
<?php
// Require dependencies
require_once __DIR__ . "/vendor/autoload.php";
// Use MWC Pay
use Nicolasflamel\MwcPay\MwcPay;
// Initialize MWC Pay
$mwcPay = new MwcPay("http://localhost:9010");
// Create payment
$payment = $mwcPay->createPayment("123.456", 5, 600, "http://example.com/completed", "http://example.com/received", "http://example.com/confirmed", "http://example.com/expired", "notes");
// Get payment info
$paymentInfo = $mwcPay->getPaymentInfo($payment["payment_id"]);
// Get price
$price = $mwcPay->getPrice();
// Get public server info
$publicServerInfo = $mwcPay->getPublicServerInfo();
?>
Functions
-
MWC Pay constructor:
constructor(string $privateServer = "http://localhost:9010"): MwcPayThis constructor is used to create an
MwcPayobject and it accepts the following parameter:string $privateServer(optional): The URL for your MWC Pay's private server. If not provided then the default valuehttp://localhost:9010will be used.
This method returns the following value:
MwcPay: AnMwcPayobject.
-
MWC Pay create payment method:
createPayment(?string $price, ?int $requiredConfirmations, ?int $timeout, string $completedCallback, ?string $receivedCallback = NULL, ?string $confirmedCallback = NULL, ?string $expiredCallback = NULL, ?string $notes = NULL, ?string $apiKey = NULL): array | FALSE | NULLThis method is used to create a payment and it accepts the following parameters:
?string $price: The expected amount for the payment. IfNULLthen any amount will fulfill the payment.?int $requiredConfirmations: The required number of on-chain confirmations that the payment must have before it's considered complete. IfNULLthen one required confirmation will be used.?int $timeout: The duration in seconds that the payment can be received. IfNULLthen the payment will never expire.string $completedCallback: The HTTP GET request that will be performed when the payment is complete. If the response status code to this request isn'tHTTP 200 OK, then the same request will be made at a later time. This request can't follow redirects. This request may happen multiple times despite a previous attempt receiving anHTTP 200 OKresponse status code, so make sure to prepare for this and to respond to all requests with anHTTP 200 OKresponse status code if the request has already happened. All instances of__id__,__completed__, and__received__are replaced with the payment's ID, completed timestamp, and received timestamp respectively.?string $receivedCallback(optional): The HTTP GET request that will be performed when the payment is received. If the response status code to this request isn'tHTTP 200 OK, then anHTTP 500 Internal Errorresponse will be sent to the payment's sender when they are sending the payment. This request can't follow redirects. This request may happen multiple times despite a previous attempt receiving anHTTP 200 OKresponse status code, so make sure to prepare for this and to respond to all requests with anHTTP 200 OKresponse status code if the request has already happened. All instances of__id__,__price__,__sender_payment_proof_address__,__kernel_commitment__, and__recipient_payment_proof_signature__are replaced with the payment's ID, price, sender payment proof address, kernel commitment, and recipient payment proof signature respectively. If not provided orNULLthen no request will be performed when the payment is received.?string $confirmedCallback(optional): The HTTP GET request that will be performed when the payment's number of on-chain confirmations changes and the payment isn't completed. The response status code to this request doesn't matter. This request can't follow redirects. All instances of__id__, and__confirmations__are replaced with the payment's ID and number of on-chain confirmations respectively. If not provided orNULLthen no request will be performed when the payment's number of on-chain confirmations changes.?string $expiredCallback(optional): The HTTP GET request that will be performed when the payment is expired. If the response status code to this request isn'tHTTP 200 OK, then the same request will be made at a later time. This request can't follow redirects. This request may happen multiple times despite a previous attempt receiving anHTTP 200 OKresponse status code, so make sure to prepare for this and to respond to all requests with anHTTP 200 OKresponse status code if the request has already happened. All instances of__id__are replaced with the payment's ID. If not provided orNULLthen no request will be performed when the payment is expired.?string $notes(optional): Text to associate with the payment.?string $apiKey(optional): API key that must match the private server's API key if it's using one.
This method returns the following values:
array: The payment was created successfully. This array contains thestring payment_id,string url, andstring recipient_payment_proof_addressof the created payment.FALSE: An error occurred on the private server and/or communicating with the private server failed.NULL: Parameters are invalid.
-
MWC Pay get payment info method:
getPaymentInfo(string $paymentId, ?string $apiKey = NULL): array | FALSE | NULLThis method is used to get the status of a payment and it accepts the following parameters:
string $paymentId: The payment's ID.?string $apiKey(optional): API key that must match the private server's API key if it's using one.
This method returns the following values:
array: This array contains the payment'sstring url,?string price,int required_confirmations,bool received,int confirmations,?int time_remaining,string status, andstring recipient_payment_proof_address. Thestring statuscan be one of the following values:Expired,Not received,Received,Confirmed, orCompleted.FALSE: An error occurred on the private server and/or communicating with the private server failed.NULL: Parameters are invalid and/or the payment doesn't exist.
-
MWC Pay get price method:
getPrice(?string $apiKey = NULL): string | FALSE | NULLThis method is used to get the price of MimbleWimble coin and it accepts the following parameters:
?string $apiKey(optional): API key that must match the private server's API key if it's using one.
This method returns the following values:
string: The price of MimbleWimble Coin in USDT.FALSE: An error occurred on the private server and/or communicating with the private server failed.NULL: Parameters are invalid and/or the price API is disabled on the private server.
-
MWC Pay get public server info method:
getPublicServerInfo(?string $apiKey = NULL): array | FALSE | NULLThis method is used to get info about MWC Pay's public server and it accepts the following parameters:
?string $apiKey(optional): API key that must match the private server's API key if it's using one.
This method returns the following values:
array: This array contains the public server'sstring urland?string onion_service_address.FALSE: An error occurred on the private server and/or communicating with the private server failed.NULL: Parameters are invalid.
nicolasflamel/mwc-pay 适用场景与选型建议
nicolasflamel/mwc-pay 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 29 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 01 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「crypto」 「cryptocurrency」 「payment processor」 「MWC Pay」 「MWC」 「MimbleWimble Coin」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nicolasflamel/mwc-pay 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nicolasflamel/mwc-pay 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nicolasflamel/mwc-pay 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
High-level cryptographic primitives and security utilities for Maatify systems including password hashing, reversible encryption, HKDF key derivation, and key rotation.
Cryptonator Merchant API
Implementation of Bitclout API interaction through its node
A simple PHP Cryptography Implementation for the Ark Blockchain.
A simple PHP API client for the Ark Blockchain.
A Laravel bridge for Ark Core.
统计信息
- 总下载量: 29
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-01-27