loki1729/laravel-thepeer

Laravel Package for easy integration of ThePeer APIs.

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

This package is auto-updated.

Last update: 2024-06-06 20:37:35 UTC


README

Installation

composer require loki1729/laravel-thepeer

Usage

Following are some ways through which you can access the ThePeer provider:

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

$the_peer_service = new ThePeerClient;

Publish Config Folder

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

Configuration File

The configuration file loki_the_peer.php is located in the config folder. Following are its contents when published:

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', ''),
    ],

];

Configuration Options

You can either use the env to set your keys or use your keys as shown in the example below:

     $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');

Index User

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

All Users

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

Update User

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

Delete User

$the_peer_service->deleteUSer(string $userReference);

Get User Link

$the_peer_service->getUserLink(string $userReference);

Get Transaction

$the_peer_service->getTransaction(string $transactionId);

Refund Transaction

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

Get Link

$the_peer_service->getLink(string $linkId);

Charge Link

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

Test Credit

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

Test Charge

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