litvinchuk/laravel-liqpay

Laravel liqpay library.

v0.0.1 2022-02-22 23:44 UTC

This package is auto-updated.

Last update: 2024-11-23 06:20:38 UTC


README

Install library: composer require litvinchuk/laravel-liqpay

Register Tool in NovaServiceProvider

App\Providers\NovaServiceProvider.php

public function tools()
{
    return [
        new \Litvinchuk\LaravelLiqpay\LaravelLiqpay([
            'registerPublicRoutes' => true,
        ]),
    ];
}

Configuration

Add secret and public keys to .env

LIQPAY_PUBLIC_KEY=public
LIQPAY_PRIVATE_KEY=secret

Create payment

use Litvinchuk\LaravelLiqpay\LiqpayPayment;

$payment = LiqpayPayment::createPayment(10, 'UAH', 'Test payment description');

Pay by link

$payment->getPaymentLink()

Inline pay

render

$payment->renderInline()

manual

<div id="liqpay_checkout"></div>

<script>
    window.LiqPayCheckoutCallback = function() {
        LiqPayCheckout.init({
            data: "{{ $payment->getEncodedParams() }}",
            signature: "{{ $payment->getSignature() }}",
            embedTo: "#liqpay_checkout",
            language: "{{ $payment->language }}",
            mode: "embed" // embed || popup
        }).on("liqpay.callback", function(data){
             console.log(data.status);
             console.log(data);
         }).on("liqpay.ready", function(data){
             // ready
         }).on("liqpay.close", function(data){
             // close
         });
    };
</script>

<script src="//static.liqpay.ua/libjs/checkout.js" async></script>