https://github.com/digital-threads/liqpay
Laravel LiqPay Client
https://github.com/digital-threads/liqpay
Last synced: 8 days ago
JSON representation
Laravel LiqPay Client
- Host: GitHub
- URL: https://github.com/digital-threads/liqpay
- Owner: Digital-Threads
- License: mit
- Created: 2021-06-16T05:18:41.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2025-11-22T16:40:57.000Z (5 months ago)
- Last Synced: 2025-11-22T18:21:39.872Z (5 months ago)
- Language: PHP
- Homepage:
- Size: 17.6 KB
- Stars: 1
- Watchers: 0
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Laravel Liqpay Client
[](https://github.com/Digital-Threads/Liqpay/releases) [](https://github.com/Digital-Threads/Liqpay/blob/master/LICENSE) [](https://codecov.io/gh/Digital-Threads/Liqpay)
## Installation
Run `composer require digital-threads/liqpay`
## Configurations
[LiqPay](https://www.liqpay.ua) client requires following configurations to be set in your environment:
| Key | Description |
| ------------------------- | ----------------------------------------------------------------------------------- |
| `LIQPAY_PUBLIC_KEY` | [LiqPay Public Key](https://www.liqpay.ua/ru/registration) |
| `LIQPAY_PRIVATE_KEY` | [LiqPay Private Key](https://www.liqpay.ua/ru/registration) |
| `LIQPAY_DEFAULT_CURRENCY` | Default order currency that will be used if none will be specified for each request |
Alternatively you can publish package configurations and specify your own boundaries:
`php artisan vendor:publish --provider='DigitalThreads\LiqPay\LiqPayServiceProvider' --tag='config'`
## Usage
After package configurations were specified you can use `DigitalThreads\LiqPay\LiqPay` facade for your payment operations.
### Checkout
In order to render LiqPay form you may want to securly recieve [Checkout encoded form parameters](https://www.liqpay.ua/documentation/api/aquiring/checkout/doc) from your backend API like following:
#### PaymentController.php
```php
$order->amount,
'description' => $order->description,
'order_id' => $order->id,
'result_url' => route('web.checkout'),
'server_url' => route('api.liqpay_callback'), // The url that wil be used for order webhook notification
'currency' => $order->currency, // Optional. If not set - default currency will be used.
]);
return new JsonResponse([
'action' => $prerequisites->getAction(),
'data' => $prerequisites->getData(),
'signature' => $prerequisites->getSignature(),
]);
}
}
```
#### api.php
```php
export default {
data() {
return {
orderId: 1,
form: {
action: null,
data: null,
signature: null,
},
};
},
async mounted() {
const response = await fetch(`{your-api-url}/${this.orderId}/checkout`);
this.form = response.json();
},
};
```
### Callback Validation
During payment processing your API will recieve a [Callback](https://www.liqpay.ua/documentation/api/callback) post request with url that was specified as `server_url` in the `PaymentController`. You will need to register callback handler route in order to update order status according to the data in the request.
#### PaymentController.php
```php
$order->amount,
'description' => $order->description,
'order_id' => $order->id,
'result_url' => route('web.checkout'),
'server_url' => route('api.liqpay_callback'), // The url that wil be used for order webhook notification
'currency' => $order->currency, // Optional. If not set - default currency will be used.
]);
return new JsonResponse([
'action' => $prerequisites->getAction(),
'data' => $prerequisites->getData(),
'signature' => $prerequisites->getSignature(),
]);
}
public function callback(Request $request)
{
try {
$payload = LiqPay::validateCallback($request);
$order = Order::findOrFail($payload->get('order_id'));
$order->update(['status' => $payload->get('status')]);
} catch (InvalidCallbackRequestException $e) {
return new JsonResponse(['error' => $e->getMessage()], 400);
}
}
}
```
#### api.php
```php
name('liqpay_callback');
```
`LiqPay::validateCallback` method will take care of the request validation and signature checks and will return an instance of `LiqPayPaymentDetailsInterface`, use it to extract order details data for your needs.
## Credits
- [Stas Vartanyan](https://github.com/vaawebdev)
- [Digital Threads](https://github.com/Digital-Threads)