mujhtech / laravel-lazerpay
Laravel lazerpay API 的包
1.0.1
2022-06-05 07:01 UTC
Requires
- php: ^7.2|^8.0
- guzzlehttp/guzzle: ~6|~7|~8
- illuminate/support: ~6|~7|~8|~9
Requires (Dev)
- mockery/mockery: ^1.4
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-09-22 19:34:53 UTC
README
一个用于 lazerpay API 的 Laravel 包
安装
要获取 Lazerpay 的最新版本,只需要求它
composer require mujhtech/laravel-lazerpay
或者将以下行添加到您的 composer.json
文件的 require 块中。
"mujhtech/laravel-lazerpay": "1.0.*"
一旦 Laravel Sendchamp 安装完毕,您需要注册服务提供者。打开 config/app.php
并将以下内容添加到 providers
键。
'providers' => [ ... Mujhtech\Lazerpay\LazerpayServiceProvider::class, ... ]
如果您使用的是 Laravel >= 5.5,您可以跳过此步骤并转到
配置
Mujhtech\Lazerpay\LazerpayServiceProvider::class
此外,按如下方式注册 Facade
'aliases' => [ ... 'Lazerpay' => Mujhtech\Lazerpay\Facades\Lazerpay::class, ... ]
配置
您可以使用此命令发布配置文件
php artisan vendor:publish --provider="Mujhtech\Lazerpay\LazerpayServiceProvider"
一个名为 lazerpay.php
的配置文件,其中包含一些合理的默认值,将被放置在您的 config
目录中
<?php return [ /** * Live API url * */ 'baseUrl' => 'https://api.lazerpay.engineering/api/v1', /** * Public Key * */ 'publicKey' => getenv('LAZERPAY_PUBLIC_KEY'), /** * Secret Key * */ 'secretKey' => getenv('LAZERPAY_SECRET_KEY'), ];
使用
打开您的 .env 文件并添加您的 API 密钥,如下所示
LAZERPAY_PUBLIC_KEY=pk_xxxxx LAZERPAY_SECRET_KEY=sk_xxxxx
如果您正在使用类似 heroku 的托管服务,请确保将上述详细信息添加到您的配置变量中。
用例
/** * Verify transaction * Verify transactions after payments * @return array */ Lazerpay::verifyTransaction(string $reference) /** * Alternatively, use the helper. */ lazerpay()->verifyTransaction(string $reference) /** * Get all coins * @return array */ Lazerpay::getAllCoins() /** * Alternatively, use the helper. */ lazerpay()->getAllCoins() /** * Get coin rate * @query string $coin, string $currency * @return array */ Lazerpay::getCoinRate(string $coin, string $currency) /** * Alternatively, use the helper. */ lazerpay()->getCoinRate(string $coin, string $currency) /** * Get wallet balance * @query string $coin * @return array */ Lazerpay::getWalletBalance(string $coin) /** * Alternatively, use the helper. */ lazerpay()->getWalletBalance(string $coin) /** * Crypto Transfer * @param string $reference * Unique case sensitive transaction reference. If you do not pass this parameter, Lazerpay will generate a unique reference for you. * @param string $amount * The amount you want to send out * @param string $fromCoin * Crypto you want to swap from * @param string $toCoin * Crypto you want to swap to * @param string $blockchain * The blockchain network you are sending to * @param array $metadata e.g ['type' => "Crypto swap"] * @return array */ Lazerpay::cryptoTransfer(string $reference, string $coin, string $recipient, string $amount, array $metadata, string $blockchain) /** * Alternatively, use the helper. */ lazerpay()->cryptoTransfer(string $reference, string $coin, string $recipient, string $amount, array $metadata, string $blockchain) /** * Crypto Swap * @param string $reference * Unique case sensitive transaction reference. If you do not pass this parameter, Lazerpay will generate a unique reference for you. * @param string $amount * The amount you want to send out * @param string $fromCoin * Crypto you want to swap from * @param string $toCoin * Crypto you want to swap to * @param string $blockchain * The blockchain network you are sending to * @param array $metadata e.g ['type' => "Crypto swap"] * @return array */ Lazerpay::cryptoSwap(string $reference, string $fromCoin, string $toCoin, integer $amount, array $metadata, string $blockchain) /** * Alternatively, use the helper. */ lazerpay()->cryptoSwap(string $reference, string $fromCoin, string $toCoin, integer $amount, array $metadata, string $blockchain) /** * Crypto Swap Amount * This endpoint helps you get the amount you will receive on swap even before initiating the swap * @param string $amount * The amount you want to send out * @param string $fromCoin * Crypto you want to swap from * @param string $toCoin * Crypto you want to swap to * @param string $blockchain * The blockchain network you are sending to * @return array */ Lazerpay::cryptoSwapAmount(string $fromCoin, string $toCoin, string $amount, string $blockchain) /** * Alternatively, use the helper. */ lazerpay()->cryptoSwapAmount(string $fromCoin, string $toCoin, string $amount, string $blockchain) /** * Get all payment links * @return array */ Lazerpay::getPaymentLinks() /** * Alternatively, use the helper. */ lazerpay()->getPaymentLinks() /** * Fetch payment link * @param string $reference or id * @return array */ Lazerpay::fetchPaymentLink(string $reference) /** * Alternatively, use the helper. */ lazerpay()->fetchPaymentLink(string $reference) /** * Create Payment link * With payment links, you can share your unique payment link to anyone in the world. * @param string $amount * Amount the user will pay * @param string $currency * Payment page currency * @param string $title * The title of the link * @param string $description * Description of the payment page * @param string $logo * Your logo url * @param string $type * Payment links type default is "standard" * @return array */ Lazerpay::createPaymentLink(string $title, string $description, string $type = 'standard', string $logo, string $amount, string $currency, string $redirect_url) /** * Alternatively, use the helper. */ lazerpay()->createPaymentLink(string $title, string $description, string $type = 'standard', string $logo, string $amount, string $currency, string $redirect_url) /** * Update Payment link * Update a particular payment link with the following endpoint. * @param string $reference * Id or reference * @param string $amount * Amount the user will pay * @param string $currency * Payment page currency * @param string $title * The title of the link * @param string $description * Description of the payment page * @param string $logo * Your logo url * @param string $type * Payment links type default is "standard" * @return array */ Lazerpay::updatePaymentLink(string $reference, string $title, string $description, string $type = 'standard', string $logo, string $amount, string $currency, string $redirect_url) /** * Alternatively, use the helper. */ lazerpay()->updatePaymentLink(string $reference, string $title, string $description, string $type = 'standard', string $logo, string $amount, string $currency, string $redirect_url)
许可证
MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件