pipedev/lazerpay

laravel sdk for lazerpay

dev-main 2023-02-18 10:38 UTC

This package is auto-updated.

Last update: 2024-04-18 13:00:47 UTC


README

68747470733a2f2f692e6962622e636f2f6b677171394a702f696d6167652e706e67

Lazerpay Laravel Package

pipedev/lazerpay is a laravel sdk package that access to laravel api

Total Downloads

Installation

PHP 5.4+ and Composer are required.

To get the latest version of Laravel Lazerpay, simply require it

composer require pipedev/lazerpay

Or add the following line to the require block of your composer.json file.

"pipedev/lazerpay": "*"

You'll then need to run composer install or composer update to download it and have the autoloader updated.

Once Laravel Lazerpay is installed, you need to register the service provider. Open up config/app.php and add the following to the providers key.

'providers' => [
    ...
    Pipedev\Lazerpay\LazerPayServiceProvider::class,
    ...
]

If you use Laravel >= 5.5 you can skip this step and go to configuration

  • Pipedev\Lazerpay\LazerPayServiceProvider::class

Also, register the Facade like so:

'aliases' => [
    ...
    'Lazerpay' => Pipedev\Lazerpay\Facades\LazerpayFacade::class,
    ...
]

Configuration

You can publish the configuration file using this command:

php artisan vendor:publish --provider="Pipedev\Lazerpay\LazerPayServiceProvider" --tag="lazerpay"

A configuration-file named lazerpay.php with some sensible defaults will be placed in your config directory:

<?php

return [
    /**
     * Public Key From Lazerpay developer Dashboard
     *
     */

    'key' => env('LAZER_PUBLIC_KEY'),

    /**
     * Secret Key From Lazerpay developer Dashboard
     *
     */

    'secret' => env('LAZER_SECRET_KEY')
];

Usage

Open your .env file and add your lazer pay public key and secret key as displayed below:

LAZER_PUBLIC_KEY=********
LAZER_SECRET_KEY=*******

Test

composer test

Basic methods this package provides....

<?php

use Pipedev\Lazerpay\Lazerpay;

$lazerpay = new Lazerpay();

/**
 * Initializes a payment transaction and returns the address to be used in completing the payment.
 */
    $lazerpay->initializePayment([
        "customer_name" => "iamnotstatic.eth",
        "customer_email" => "abdulfataisuleiman67@gmail.com",
        "coin" => "USDC",
        "currency" => "USD",
        "amount" => 100,
        "fiatAmount" => "100",
        "accept_partial_payment" => true
    ]);

/**
 * Gets the list of coins supported by Lazerpay. 
 * Using a mainnet API key returns accepted coins on the mainnet and using a testnet API key returns the accepted coins on the testnet.
 */
    $lazerpay->getAcceptedCoins();

/**
 * Checks if a payment has been completed and returns a state to show the status of the payment. 
 * Payment status can either be confirmed or incomplete.
 */
    $identifier = 'Transaction reference';
    $lazerpay->confirmPayment($identifier);

/**
 * Transfers crypto amount from businesses lazerpay balance to external crypto wallet
 */
    $lazerpay->transferFunds([
        "amount" =>  1,
        "recipient" => "0x0B4d358D349809037003F96A3593ff9015E89efA",
        "coin" => 'BUSD',
        "blockchain" => 'Binance Smart Chain',
    ]);

/**
 * Generate payment links
 */
    $lazerpay->generatePaymentLink([
      "title" => 'Njoku Test',
      "description" => 'Testing this sdk',
      "logo" => 'https://webhook.site/d1e815d0-0aa4-4bee-aeb5-a5eb0f62701a',
      "currency" => 'USD',
      "type" => 'standard',
      "amount" => 100
    ]);
    
/**
 * This describes to allow you get all Payment links created
 */
    $lazerpay->allPaymentLinks();
    
/**
 * This describes disabling or enabling a payment link by updating it "active" or "inactive"
 */
    $lazerpay->updatePaymentLink([
        "status" => "active"
    ], "jgidgd");

/**
 * This describes to allow you swap between two stable coins
 */
     $lazerpay->swapCrypto([
        "amount" => 100,
        "fromCoin" => 'BUSD',
        "toCoin" => 'USDT',
        "blockchain" => 'Binance Smart Chain',
        "metadata" => array("id" => "343243243223432"),
    ]);

Contributing

Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.

Support me 😭😭

Kindly star the repo and share with friends

Don't forget to follow me on twitter!

🤡🤡, Muritala David