hans-thomas / lyra
payment gateway with offline purchase support
Requires
- php: ^8.1
- ext-exif: *
- guzzlehttp/guzzle: ^7.7
- hans-thomas/alicia: ^1.0
Requires (Dev)
- nunomaduro/collision: ^7.0
- orchestra/testbench: ^8.0
This package is auto-updated.
Last update: 2025-01-08 17:51:47 UTC
README
Lyra is a payment package that supports offline purchases as well. There are two defined gateway by default, but you can implement your own gateway(s).
Installation
Via composer
composer require hans-thomas/lyra
Then publish the config file
php artisan vendor:publish --tag lyra-config
Usage
Lyra supports online and offline modes. First, we are going to introduce the online mode.
Online purchase
Pay
You can call the pay
method and pass the amount to pay for a purchase.
Lyra::pay(10000);
getRedirectUrl
After calling pay
method, you can call getRedirectUrl
method to get the gateway URL as a string.
Lyra::pay(10000)->getRedirectUrl();
redirect
Also, you can call redirect
method to redirect the user to the gateway URL after calling the pay
method.
Lyra::pay(10000)->redirect();
setGateway
You can set another gateway before calling the pay
method and override the default one.
Lyra::setGateway(Payir::class, 10000)->pay();
verify
To verify the purchase, on callback, you can call verify
method and pass the payment amount.
Lyra::verify(10000);
getInvoice
After calling pay
method, you can get the created invoice using getInvoice
method.
Lyra::pay(10000)->getInvoice();
Offline purchase
pay
To purchase an offline payment, you must call offline
method first and then pay
method.
Lyra::offline()->pay($file, $amount = 10000);
getInvoice
Also, in offline mode, you can call getInvoice
method to get the created invoice after the pay
method.
Lyra::offline()->pay($file, 10000)->getInvoice();
accept
To accept an offline purchase, call accept
method and pass the related invoice.
Lyra::offline()->accept($invoice);
deny
To deny a purchase, call deny
method.
Lyra::offline()->deny($invoice);
Contributing
- Fork it!
- Create your feature branch: git checkout -b my-new-feature
- Commit your changes: git commit -am 'Add some feature'
- Push to the branch: git push origin my-new-feature
- Submit a pull request ❤️