Metadata-Version: 2.1
Name: cloudtipsadp
Version: 0.15.2
Summary: CloudTips Adapter - integration module with API CloudPayments.
Project-URL: Homepage, https://github.com/SETTER2000/cloudtips-adp
Project-URL: Bug Tracker, https://github.com/SETTER2000/cloudtips-adp/issues
Author-email: setter <lphp@mail.ru>
License: MIT License
        
        Copyright (c) 2022 Alexander Petrov
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# cloudtips-adp
CloudTips Adapter позволяет интегрировать прием донатов в Django приложение.

## Старт
Установка
```angular2html
pip install cloudtipsadp
```
Удаление пакета
```angular2html
pip uninstall cloudtipsadp
```
Зависимости разрешить [^1]
```angular2html
pip install python-dotenv requests python-magic dependency-injector
```
### Настройка переменных окружения
В корне проекта создать файл .env 

*Файл .env используется для тестов. В production установить переменные 
окружения уровня сеанса пользователя или системы.*

```angular2html
sudo touch .env
```
Для авторизации на CloudTips добавить настройки в файл .env

placeId - идентификатор вашего заведения (в админке CloudTips)

```angular2html
CTA_GRANT_TYPE=password
CTA_CLIENT_ID=Partner
CTA_USER_NAME=<your_email>
CTA_PASSWORD=<your_password>
CTA_PLACE_ID=<your_placeId>

# Production. Раскомментировать
#CTA_BASE_URL=https://identity.cloudtips.ru
#CTA_BASE_URL_API=https://api.cloudtips.ru/api

# Production. Закомментировать
CTA_BASE_URL=https://identity-sandbox.cloudtips.ru
CTA_BASE_URL_API=https://api-sandbox.cloudtips.ru
```

#  Работа с пакетом

### Подключение 
```angular2html
import cloudtipsadp as cta
```


## Получатель
#### Создать получателя донатов
```angular2html
response = cta.receivers_create(name, phone_number)
```
#### Удалить получателя из скоупа
```angular2html
response = cta.receivers_detach_agent(user_id)
```
#### Все получатели донатов
```angular2html
response = cta.receivers_pages()
```
#### Загрузка фотографии получателя
```angular2html
response = cta.receivers_photo(user_id, photo_path)
```

#### Вариант просмотра результата ответа сервера
```angular2html
if type(response) == dict and response.get('succeed'):
    print(response.get('data'))
else:
    print(response)
```


## Заведения
#### Информация по всем заведениям ТСП
```angular2html
response = cta.places_get()
```
#### Привязка получателя к заведению. Отправить сотруднику на его номер телефона код в смс сообщении.
```angular2html
response = cta.places_send_sms(user_id)
```
#### Подтверждение привязки телефона (пользователя) к предприятию. Передать код из смс.
```angular2html
response = cta.places_confirm(user_id, code)
```



## Карты
#### Список карт получателя
```angular2html
response = cta.cards_get(user_id)
```
#### Отправить криптограмму
```angular2html
response = cta.cards_auth(user_id, checkout)
```
#### Для проведения 3-D Secure аутентификации
```angular2html
response = cta.cards_3ds(user_id, md, paReq)
```
#### Изменить карту, которая по умолчанию
```angular2html
response = cta.cards_default(user_id, card_token)
```
#### Удаление карты получателя. Карту по умолчанию удалить нельзя
```angular2html
response = cta.cards_delete(user_id, card_token)
```

#### Подтвердить привязку карты на стороне системы
```angular2html
response = cta.cards_add(user_id, transact_id)
```



## Накопления
#### Накопления по получателю
```angular2html
response = cta.accums_summary(user_id)
```
#### Выплата накопления получателю
```angular2html
response = cta.accums_payout_receiver(user_id)
```



## Транзакции
#### Получение всех транзакций выплат получателям менеджера
```angular2html
response = cta.payouts()
```

### Возможные проблемы
____

[^1]: Если возникли проблемы с установкой пакета python-magic на macos 
установите:

```angular2html
brew install libmagic 
pip uninstall python-magic
pip install python-magic-bin
```