Skip to content

Payment package that supports offline purchases

Notifications You must be signed in to change notification settings

hans-thomas/lyra

Repository files navigation

Lyra

lyra banner

codecov GitHub Workflow Status GitHub top language GitHub release (latest by date) StyleCi

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

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request ❤️

Support