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).
Via composer
composer require hans-thomas/lyra
Then publish the config file
php artisan vendor:publish --tag lyra-config
Lyra supports online and offline modes. First, we are going to introduce the online mode.
You can call the pay
method and pass the amount to pay for a purchase.
Lyra::pay(10000);
After calling pay
method, you can call getRedirectUrl
method to get the gateway URL as a string.
Lyra::pay(10000)->getRedirectUrl();
Also, you can call redirect
method to redirect the user to the gateway URL after calling the pay
method.
Lyra::pay(10000)->redirect();
You can set another gateway before calling the pay
method and override the default one.
Lyra::setGateway(Payir::class, 10000)->pay();
To verify the purchase, on callback, you can call verify
method and pass the payment amount.
Lyra::verify(10000);
After calling pay
method, you can get the created invoice using getInvoice
method.
Lyra::pay(10000)->getInvoice();
To purchase an offline payment, you must call offline
method first and then pay
method.
Lyra::offline()->pay($file, $amount = 10000);
Also, in offline mode, you can call getInvoice
method to get the created invoice after the pay
method.
Lyra::offline()->pay($file, 10000)->getInvoice();
To accept an offline purchase, call accept
method and pass the related invoice.
Lyra::offline()->accept($invoice);
To deny a purchase, call deny
method.
Lyra::offline()->deny($invoice);
- 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 ❤️