click / module
The library to integration with click
Installs: 19
Dependents: 0
Suggesters: 0
Security: 0
Stars: 22
Watchers: 2
Forks: 5
Open Issues: 3
pkg:composer/click/module
Requires
- guzzlehttp/guzzle: ~6.0
This package is not auto-updated.
Last update: 2025-10-21 14:29:04 UTC
README
This library allows you to integrate payment acceptance using "CLICK" payment system into PHP web applications.
For the library to function properly, the user must be connected to Click Merchant using the Shop API scheme.
Detailed documentation is available here https://docs.click.uz.
Installation via Git
git clone https://github.com/click-llc/click-integration-php.git
cd click-integration-php
composer install
After installing, you need to require autoloader
require(__DIR__ . '\vendor\autoload.php');
Documentation
Configuration
Your can set your configurations via click/configs.php file.
Click configuration
return [ ... 'provider' => [ 'endpoint' => 'https://api.click.uz/v2/merchant/', 'click' => [ 'merchant_id' => 1111, 'service_id' => 2222, 'user_id' => 3333, 'secret_key' => 'AAAAAAAA' ] ] ... ]
Database configuration
return [ ... 'db' => [ 'dsn' => 'mysql:host=localhost;dbname=<your_db_name>', 'username' => 'root', 'password' => '' ] ... ]
Quick Start
1) Create Model
You can use the \cick\models\Payments model
use click\models\Payments; $model = new Payments();
Or can create payments model yourself via \click\models\Payments class
use click\models\Payments; class MyPayments extends Payments{ ... } $model = new MyPayments();
SHOP Api methods
Prepare
$model->prepare([ 'click_trans_id' => 1111, 'service_id' => 2222, 'click_paydoc_id' => 3333, 'merchant_trans_id' => '11111', 'amount' => 1000.0, 'action' => 0, 'error' => 0, 'error_note' => 'Success', 'sign_time' => 'YYYY-MM-DD HH:mm:ss', 'sign_string' => 'AAAAAAAAAAAAAAAAAAAAAAAAAA' ]);
Complete
$model->complete([ 'click_trans_id' => 1111, 'service_id' => 2222, 'click_paydoc_id' => 3333, 'merchant_trans_id' => '11111', 'merchant_prepare_id' => 11111, 'amount' => 1000.0, 'action' => 1, 'error' => 0, 'error_note' => 'Success', 'sign_time' => 'YYYY-MM-DD HH:mm:ss', 'sign_string' => 'AAAAAAAAAAAAAAAAAAAAAAAAAA' ]);
Merchant Api methods
Note : All of the merchant api methods return the CLICK-MERCHANT-API response as arrays
Create invoice
$model->create_invoice([ 'token' => 'aaaa-bbbb-cccc-ddddddd', 'phone_number' => '998112222222' ]);
Check invoice status
$model->check_invoice([ 'token' => 'aaaa-bbbb-cccc-ddddddd', 'invoice_id' => 2222 ]);
Create card token
$model->create_card_token([ 'token' => 'aaaa-bbbb-cccc-ddddddd', 'card_number' => 'AAAA-BBBB-CCCC-DDDD', 'expire_date' => 'BBEE', 'temporary' => 1 ]);
Verify card token
$model->verify_card_token([ 'token' => 'aaaa-bbbb-cccc-ddddddd', 'sms_code' => '12345' ]);
Payment with card token
$model->payment_with_card_token([ 'token' => 'aaaa-bbbb-cccc-ddddddd', 'card_token' => 'AAAAAA-BBBB-CCCC-DDDDDDD' ]);
Delete card token
$model->delete_card_token([ 'token' => 'aaaa-bbbb-cccc-ddddddd', 'card_token' => 'AAAAAA-BBBB-CCCC-DDDDDDD' ]);
Check payment status by payment_id
$model->check_payment([ 'token' => 'aaaa-bbbb-cccc-ddddddd', 'payment_id' => 1111 ]);
Check payment status by merchant_trans_id
$model->merchant_trans_id([ 'token' => 'aaaa-bbbb-cccc-ddddddd', 'merchant_trans_id' => 1111 ]);
Cancel payment (reversal)
$model->cancel([ 'token' => 'aaaa-bbbb-cccc-dddddddd', 'payment_id' => 1111 ]);
2) Overwrite the some methods over the Payments
use click\models\Payments; class MyPayments extends Payments{ /** * @param data array * @return response \GuzzleHttp\Client */ public function on_invoice_creating($data){ ... $response = $this->client->request('POST', 'invoice/create', [ ... ]); ... return $response; } /** * @param request array * @param response \GuzzleHttp\Client object * @param token string * @return response array|null */ public function on_invoice_created($request, $response, $token){ ... if($response->getStatusCode() == 200){ $result = (array)json_decode((string) $response->getBody()); ... $this->model->update_by_token($token, [ ... ]); ... } ... return $result; } }
List of the Payments methods
on_invoice_creatingandon_invoice_createdfor create invoiceon_invoice_checkingandon_invoice_checkedfor check invoiceon_cancelingandon_canceledfor cancel paymenton_card_token_creatingandon_card_token_createdfor create card tokenon_card_token_verifyingandon_card_token_verifiedfor verify card tokenon_card_token_payingandon_card_token_payedfor payment via card tokenon_card_token_deletingandon_card_token_deletedfor delete card tokenon_payment_checkingandon_payment_checkedfor check payment status by merchant_idon_checking_with_merchant_trans_idandon_checked_with_merchant_trans_idfor check payment status by merchant_trans_id
If you want check whether the payment user exists, complete this method
use click\models\Payments; class MyPayments extends Payments{ /** * @name on_user_is_exists method * @param payment array * @return response boolean|null */ protected function on_user_is_exists($payment){ ... } }
Advanced
1) Create the application for rest api
use click\applications\Application; use click\models\Payments; $model = new Payments(); $application = new Application([ 'model' => $model ]);
2) Create the application with application session for authorization via token
use click\applications\Application; use click\models\Payments; Application::session('<YOUR_AUTH_TOKEN>', ['/prepare', '/complete'], function(){ $model = new Payments(); $application = new Application([ 'model' => $model ]); $application->run(); });
SHOP Api methods
/preparefor prepare/completefor complete
Merchant Api methods
/invoice/createfor create invoice/invoice/checkfor check invoice/payment/statusfor check payment status via payment_id/payment/merchant_train_idfor check payment status via merchant_trans_id/cancelfor cancel payment/card/createfor create card token/card/verifyfor verify card token/card/paymentfor payment with card token/card/deletefor delete card token