loki1729/laravel-thepeer

Laravel 包,用于轻松集成 ThePeer API。

dev-main 2022-08-06 16:20 UTC

This package is auto-updated.

Last update: 2024-09-06 21:10:31 UTC


README

安装

composer require loki1729/laravel-thepeer

用法

以下是一些您可以通过它们访问 ThePeer 提供者的方式

// Import the class namespaces first, before using it directly
use \Loki1729\LaravelThePeer\Services\ThePeer as ThePeerClient;

$the_peer_service = new ThePeerClient;

发布配置文件夹

 php artisan vendor:publish --provider "Loki1729\LaravelThePeer\ServiceProviders\ThePeerServiceProvider"

配置文件

配置文件 loki_the_peer.php 位于 config 文件夹中。以下是其发布内容

return [
    'mode' => env('THE_PEER_MODE', 'sandbox'), // Can only be 'sandbox' Or 'live'. If empty or invalid, 'live' will be used.
    'sandbox' => [
        'public_key' => env('THE_PEER_TEST_PUBLIC_KEY', ''),
        'secret_key' => env('THE_PEER_TEST_SECRET_KEY', ''),
    ],
    'live' => [
        'public_key' => env('THE_PEER_LIVE_PUBLIC_KEY', ''),
        'secret_key' => env('THE_PEER_LIVE_SECRET_KEY', ''),
    ],

];

配置选项

您可以使用 env 来设置您的密钥或使用以下示例中的密钥

     $the_peer_service = new ThePeerClient($mode, $secret_key);
     
    For local testing, the "mode" is set to "sandbox"; 
    
    $the_peer_service = new ThePeerClient('sandbox', 'secret-key');
    
    For Live testing, the "mode" is set to "live";
    
    $the_peer_service = new ThePeerClient('live', 'secret-key');

索引用户

  $the_peer_service->indexUser(string $name, string $email, string $identifier);

所有用户

$the_peer_service->allUsers(int $page = null, int $perPage = null);

更新用户

$the_peer_service->updateUser(string $userReference, string $identifier);

删除用户

$the_peer_service->deleteUSer(string $userReference);

获取用户链接

$the_peer_service->getUserLink(string $userReference);

获取交易

$the_peer_service->getTransaction(string $transactionId);

退款交易

$the_peer_service->refundTransaction(string $transactionId, string $reason);

获取链接

$the_peer_service->getLink(string $linkId);

收费链接

$the_peer_service->chargeLink(string $linkId, float $amount, string $remark);

测试信用

$the_peer_service->testCredit(float $amount, string $currency, string $user_reference);

测试收费

$the_peer_service->testCharge(float $amount, string $from, string $to, string $currency, string $remark, string $channel);