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.
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');
Your can set your configurations via click/configs.php
file.
return [
...
'provider' => [
'endpoint' => 'https://api.click.uz/v2/merchant/',
'click' => [
'merchant_id' => 1111,
'service_id' => 2222,
'user_id' => 3333,
'secret_key' => 'AAAAAAAA'
]
]
...
]
return [
...
'db' => [
'dsn' => 'mysql:host=localhost;dbname=<your_db_name>',
'username' => 'root',
'password' => ''
]
...
]
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();
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'
]);
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
]);
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_creating
andon_invoice_created
for create invoiceon_invoice_checking
andon_invoice_checked
for check invoiceon_canceling
andon_canceled
for cancel paymenton_card_token_creating
andon_card_token_created
for create card tokenon_card_token_verifying
andon_card_token_verified
for verify card tokenon_card_token_paying
andon_card_token_payed
for payment via card tokenon_card_token_deleting
andon_card_token_deleted
for delete card tokenon_payment_checking
andon_payment_checked
for check payment status by merchant_idon_checking_with_merchant_trans_id
andon_checked_with_merchant_trans_id
for 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){
...
}
}
use click\applications\Application;
use click\models\Payments;
$model = new Payments();
$application = new Application([
'model' => $model
]);
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();
});
/prepare
for prepare/complete
for complete
/invoice/create
for create invoice/invoice/check
for check invoice/payment/status
for check payment status via payment_id/payment/merchant_train_id
for check payment status via merchant_trans_id/cancel
for cancel payment/card/create
for create card token/card/verify
for verify card token/card/payment
for payment with card token/card/delete
for delete card token