Skip to content

altynbek07/laravel-uds

Repository files navigation

Laravel UDS

Latest Version on Packagist GitHub Tests Action Status Total Downloads

UDS integration for Laravel. This package is the bridge between UDS and Laravel.

Installation

You can install the package via composer:

composer require altynbek07/laravel-uds

You should set these environment variables in your .env file:

UDS_ID=YourCompanyId
UDS_KEY=YourApiKey

You can publish the config file with:

php artisan vendor:publish --provider="Altynbek07\Uds\UdsServiceProvider" --tag="config"

This is the contents of the published config file:

<?php

return [
    /**
     * Your company ID from UDS
     */
    'id' => env('UDS_ID'),
    /**
     * Your API Key from UDS
     */
    'key' => env('UDS_KEY'),
    /**
     * This is the API URI path where Uds will be accessible from. Feel free
     * to change this path to anything you like.
     */
    'path' => env('UDS_PATH', 'api/uds'),
    /**
     * These middleware will be assigned to every Uds route, giving you
     * the chance to add your own middleware to this list or change any of
     * the existing middleware. Or, you can simply stick with this list.
     */
    'middleware' => [
        'api',
        // 'auth:api'
    ],
];

Usage

You can use the methods from \Altynbek07\Uds\Facades\Uds anywhere you want, or you can send a request to the API routes from anywhere you want (for example, from the front via axios).

Available Methods

Get company settings

Docs: https://docs.uds.app/#tag/Settings

<?php

namespace Altynbek07\Uds\Facades\Uds;

$settings = Uds::settings();

Create transaction

Docs: https://docs.uds.app/#tag/Operations/paths/~1operations/post

<?php

namespace Altynbek07\Uds\Facades\Uds;

$data = [
    'code' => '3485bf3c-5f9b-42a7-9f25-f102fe464256',
    'receipt' => [
        'total' => 900,
        'cash' => 600,
        'points' => 300
    ]
];

$transaction = Uds::createTransaction($data);

Refund transaction

Docs: https://docs.uds.app/#tag/Operations/paths/~1operations~1{id}~1refund/post

<?php

namespace Altynbek07\Uds\Facades\Uds;

$id = 113327216;

$transaction = Uds::refundTransaction($id);

Get transaction information

Docs: https://docs.uds.app/#tag/Operations/paths/~1operations~1calc/post

<?php

namespace Altynbek07\Uds\Facades\Uds;

$data = [
    'code' => '123456',
    'receipt' => [
        'total' => 900,
        'points' => 0
    ]
];

$transaction = Uds::getTransactionInformation($data);

Find customer

Docs: https://docs.uds.app/#tag/Customers/paths/~1customers~1find/get

<?php

namespace Altynbek07\Uds\Facades\Uds;

$data = [
    'code' => '123456',
    'exchangeCode' => true
    'total' => 900
];

$customer = Uds::customersFind($data);

Get customer information

Docs: https://docs.uds.app/#tag/Customers/paths/~1customers~1{id}/get

<?php

namespace Altynbek07\Uds\Facades\Uds;

$id = 9099536206450;

$customer = Uds::customers($id);

Available API Routes

Get company settings

Docs: https://docs.uds.app/#tag/Settings

# GET
/api/uds/settings

Create transaction

Docs: https://docs.uds.app/#tag/Operations/paths/~1operations/post

# POST
/api/uds/operations

Refund transaction

Docs: https://docs.uds.app/#tag/Operations/paths/~1operations~1{id}~1refund/post

# POST
/api/uds/operations/{id}/refund

Get transaction information

Docs: https://docs.uds.app/#tag/Operations/paths/~1operations~1calc/post

# POST
/api/uds/operations/calc

Find customer

Docs: https://docs.uds.app/#tag/Customers/paths/~1customers~1find/get

# GET
/api/uds/customers/find?code=123456&exchangeCode=true

Get customer information

Docs: https://docs.uds.app/#tag/Customers/paths/~1customers~1{id}/get

# GET
/api/uds/customers/{id}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.