Giter VIP home page Giter VIP logo

click-llc / click-integration-php Goto Github PK

View Code? Open in Web Editor NEW
20.0 3.0 5.0 46 KB

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.

Home Page: https://docs.click.uz

PHP 100.00%
php php-integration click click-shopping-api click-merchant-api uzbekistan clickuz uz

click-integration-php's Introduction

CLICK Integration PHP

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.

ClickLLC

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

  1. on_invoice_creating and on_invoice_created for create invoice
  2. on_invoice_checking and on_invoice_checked for check invoice
  3. on_canceling and on_canceled for cancel payment
  4. on_card_token_creating and on_card_token_created for create card token
  5. on_card_token_verifying and on_card_token_verified for verify card token
  6. on_card_token_paying and on_card_token_payed for payment via card token
  7. on_card_token_deleting and on_card_token_deleted for delete card token
  8. on_payment_checking and on_payment_checked for check payment status by merchant_id
  9. on_checking_with_merchant_trans_id and on_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){
        ...
    }
}

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

  1. /prepare for prepare
  2. /complete for complete

Merchant Api methods

  1. /invoice/create for create invoice
  2. /invoice/check for check invoice
  3. /payment/status for check payment status via payment_id
  4. /payment/merchant_train_id for check payment status via merchant_trans_id
  5. /cancel for cancel payment
  6. /card/create for create card token
  7. /card/verify for verify card token
  8. /card/payment for payment with card token
  9. /card/delete for delete card token

click-integration-php's People

Contributors

akbar-pardayev avatar tensor2flow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

click-integration-php's Issues

Iltimos

Assalom men bazi narsalarni tushunmadim shuni qayerdan aniqlab olsam bo'ladi masalan secret_key qayerdan olinadi yani token .

Model/BasicPaymentErrors : is_not_possible_data

Model/BasicPaymentErrors : is_not_possible_data

function is
private function is_not_possible_data($request){
if(!(
isset($request['click_trans_id']) &&
isset($request['service_id']) &&
isset($request['merchant_trans_id']) &&
isset($request['merchant_prepare_id']) &&
isset($request['amount']) &&
isset($request['action']) &&
isset($request['error']) &&
isset($request['error_note']) &&
isset($request['sign_time']) &&
isset($request['sign_string']) &&
isset($request['click_paydoc_id'])
) || ((int)$request['action'] > 0 && !isset($request['merchant_prepare_id']))){
return true;
}
return false;
}
I think we dont need ' isset($request['merchant_prepare_id']) && ' condition here, as I already had problem with it

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.