Skip to content

Latest commit

History

75 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

LiqPay Payment Module

LiqPay PHP SDK for seamless integration with LiqPay payment gateway.


Documentation

For full API reference and details, see the LiqPay API documentation:
LiqPay API Docs

Table of Contents

  1. Installation
  2. Quick Start
  3. Usage
  4. Public Methods

Installation

Install via Composer:

composer require liqpay/liqpay

Or include manually:

require_once'path/to/LiqPay.php';

Quick Start

useLiqPay;
$liqpay = newLiqPay('your_public_key', 'your_private_key');
// Check payment status$response = $liqpay->api('payment/status', [
'version' => 3,
'action' => 'status',
'order_id' => 'order123',
]);
// Generate checkout formecho$liqpay->cnb_form([
'version' => 3,
'action' => 'pay',
'amount' => 100.50,
'currency' => 'USD',
'description' => 'Order #123 Payment',
'language' => 'en',
]);

Usage


Public Methods

Methods Summary

MethodSignatureDescription
apiapi(string $path, array $params = [], int $timeout = 5): object|arrayCall LiqPay API and return parsed response.
get_response_codeget_response_code(): int|nullLast HTTP status code from API.
cnb_formcnb_form(array $params): stringRender HTML checkout form.
cnb_form_rawcnb_form_raw(array $params): arrayRaw URL, data, and signature.
cnb_signaturecnb_signature(array $params): stringCompute data signature for checkout.
decode_paramsdecode_params(string $data): arrayDecode Base64‑encoded payload.
str_to_signstr_to_sign(string $str): stringGenerate Base64‑SHA1 signature.

__construct

Initialize the LiqPay client with your credentials.

publicfunction __construct(
string$public_key,
string$private_key,
string|null$api_url = null
)
  • Parameters:
    • $public_key(string) — Your LiqPay public key.
    • $private_key(string) — Your LiqPay private key.
    • $api_url(string|null) — Override default API endpoint.
  • Exceptions:
    • InvalidArgumentException if keys are empty.

api

Send a request to a LiqPay API endpoint and get a parsed response.

publicfunction api(
string$path,
array$params = [],
int$timeout = 5
): object\|array
  • Parameters:
    • $path(string) — Endpoint path (e.g., 'payment/status').
    • $params(array) — Must include version and action (e.g., 'pay').
    • $timeout(int) — Timeout in seconds (connect + exec).
  • Returns:
    • JSON-decoded object on success.
    • ['error' => '...'] on failure.
  • Exceptions:
    • InvalidArgumentException if required params missing.

get_response_code

Retrieve HTTP status code from the last api() call.

publicfunction get_response_code(): int\|null
  • Returns:
    • HTTP status code (e.g., 200) or null.

cnb_form

Render a fully functional HTML checkout form with LiqPay JavaScript SDK.

publicfunction cnb_form(array$params): string
  • Parameters:
    • version, action, amount, currency, description(required)
    • language(optional)'uk', 'ru', or 'en'.
  • Returns:
    • HTML <form> string with embedded button.
  • Example:
echo$liqpay->cnb_form([
'version' => 3,
'action' => 'paydonate',
'amount' => 5,
'currency' => 'UAH',
'description' => 'Support project',
'language' => 'uk',
]);

cnb_form_raw

Get raw payload data for custom form implementations.

publicfunction cnb_form_raw(array$params): array
  • Returns:
    [
    'url' => 'https://www.liqpay.ua/api/3/checkout',
    'data' => '<Base64 JSON>',
    'signature' => '<Signature>',
    ]

cnb_signature

Compute the signature for given parameters (used in custom integrations).

publicfunction cnb_signature(array$params): string

decode_params

Decode Base64‑encoded payment data back to an array.

publicfunction decode_params(string$data): array

str_to_sign

Generate a Base64‑SHA1 signature for any string.

publicfunction str_to_sign(string$str): string

About

LiqPay SDK for php

Resources

Stars

111 stars

Watchers

20 watching

Forks

Releases

Packages

Used by

Contributors

Languages