• Stars
    star
    229
  • Rank 173,702 (Top 4 %)
  • Language
    Python
  • License
    GNU General Publi...
  • Created over 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

YooMoney API Python library

API Yoomoney - unofficial python library

This is an unofficial YooMoney API python library.

Summary

Introduction

This repository is based on the official documentation of YooMoney.

Features

Implemented methods:

  • Access token - Getting an access token
  • Account information - Getting information about the status of the user account.
  • Operation history - This method allows viewing the full or partial history of operations in page mode. History records are displayed in reverse chronological order (from most recent to oldest).
  • Operation details - Provides detailed information about a particular operation from the history.
  • Quickpay forms - The YooMoney form is a set of fields with information about a transfer. You can embed payment form into your interface (for instance, a website or blog). When the sender pushes the button, the details from the form are sent to YooMoney and an order for a transfer to your wallet is initiated.

Installation

You can install with:

pip install yoomoney --upgrade

You can install from source with:

git clone https://github.com/AlekseyKorshuk/yoomoney-api --recursive
cd yoomoney-api
python setup.py install

Quick start

Access token

First of all we need to receive an access token.

token.gif

  1. Log in to your YooMoney wallet with your username. If you do not have a wallet, create it.
  2. Go to the App registration page.
  3. Set the application parameters. Save CLIENT_ID and YOUR_REDIRECT_URI for net steps
  4. Click the Confirm button.
  5. Paste CLIENT_ID and REDIRECT_URI insted of YOUR_CLIENT_ID and YOUR_REDIRECT_URI. Choose scopes and run code.
  6. Follow all steps from the program.
from yoomoney import Authorize

Authorize(
      client_id="YOUR_CLIENT_ID",
      redirect_uri="YOUR_REDIRECT_URI",
      scope=["account-info",
             "operation-history",
             "operation-details",
             "incoming-transfers",
             "payment-p2p",
             "payment-shop",
             ]
      )

You are done with the most difficult part!

Account information

Paste YOUR_TOKEN and run this code:

from yoomoney import Client

token = "YOUR_TOKEN"

client = Client(token)

user = client.account_info()

print("Account number:", user.account)
print("Account balance:", user.balance)
print("Account currency code in ISO 4217 format:", user.currency)
print("Account status:", user.account_status)
print("Account type:", user.account_type)

print("Extended balance information:")
for pair in vars(user.balance_details):
    print("\t-->", pair, ":", vars(user.balance_details).get(pair))

print("Information about linked bank cards:")
cards = user.cards_linked

if len(cards) != 0:
    for card in cards:
        print(card.pan_fragment, " - ", card.type)
else:
    print("No card is linked to the account")

Output:

Account number: 410019014512803
Account balance: 999999999999.99
Account currency code in ISO 4217 format: 643
Account status: identified
Account type: personal
Extended balance information:
   --> total : 999999999999.99
   --> available : 999999999999.99
   --> deposition_pending : None
   --> blocked : None
   --> debt : None
   --> hold : None
Information about linked bank cards:
No card is linked to the account

Operation history

Paste YOUR_TOKEN and run this code:

from yoomoney import Client

token = "YOUR_TOKEN"

client = Client(token)

history = client.operation_history()

print("List of operations:")
print("Next page starts with: ", history.next_record)

for operation in history.operations:
    print()
    print("Operation:",operation.operation_id)
    print("\tStatus     -->", operation.status)
    print("\tDatetime   -->", operation.datetime)
    print("\tTitle      -->", operation.title)
    print("\tPattern id -->", operation.pattern_id)
    print("\tDirection  -->", operation.direction)
    print("\tAmount     -->", operation.amount)
    print("\tLabel      -->", operation.label)
    print("\tType       -->", operation.type)

Output:

List of operations:
Next page starts with:  None

Operation: 670278348725002105
  Status     --> success
  Datetime   --> 2021-10-10 10:10:10
  Title      --> Пополнение с карты ****4487
  Pattern id --> None
  Direction  --> in
  Amount     --> 100500.0
  Label      --> 3784030974
  Type       --> deposition

Operation: 670244335488002313
  Status     --> success
  Datetime   --> 2021-10-10 10:10:10
  Title      --> Перевод от 410019014512803
  Pattern id --> p2p
  Direction  --> in
  Amount     --> 100500.0
  Label      --> 7920963969
  Type       --> incoming-transfer

Operation details

Paste YOUR_TOKEN with an OPERATION_ID (example: 670244335488002312) from previous example output and run this code:

from yoomoney import Client

token = "YOUR_TOKEN"

client = Client(token)

details = client.operation_details(operation_id="OPERATION_ID")

properties = [i for i in details.__dict__.keys() if i[:1] != '_']

max_size = len(max(properties, key=len))

for prop in properties:
    print(prop, " " * (max_size - len(prop)), "-->", str(details.__getattribute__(prop)).replace('\n', ' '))

Output:

operation_id     --> 670244335488002312
status           --> success
pattern_id       --> p2p
direction        --> in
amount           --> 100500.0
amount_due       --> None
fee              --> None
datetime         --> 2021-10-10 10:10:10
title            --> Перевод от 410019014512803
sender           --> 410019014512803
recipient        --> None
recipient_type   --> None
message          --> Justtext
comment          --> None
codepro          --> False
protection_code  --> None
expires          --> None
answer_datetime  --> None
label            --> 7920963969
details          --> Justtext
type             --> incoming-transfer
digital_goods    --> None

Quickpay forms

Run this code:

from yoomoney import Quickpay

quickpay = Quickpay(
            receiver="410019014512803",
            quickpay_form="shop",
            targets="Sponsor this project",
            paymentType="SB",
            sum=150,
            )

print(quickpay.base_url)
print(quickpay.redirected_url)

Output:

https://yoomoney.ru/quickpay/confirm.xml?receiver=410019014512803&quickpay-form=shop&targets=Sponsor%20this%20project&paymentType=SB&sum=150
https://yoomoney.ru/transfer/quickpay?requestId=343532353937313933395f66326561316639656131626539326632616434376662373665613831373636393537613336383639

More Repositories

1

huggingnft

Generate NFT or train new model in just few clicks! Train as much as you can, others will resume from checkpoint!
Jupyter Notebook
139
star
2

optimum-transformers

Accelerated NLP pipelines for fast inference on CPU and GPU. Built with Transformers, Optimum and ONNX Runtime.
Python
126
star
3

huggingartists

Lyrics generation with GPT2-based Transformer
Jupyter Notebook
99
star
4

clip-gan

Create music videos using CLIP with BigGAN, DALL-E and StyleGAN
Jupyter Notebook
50
star
5

role-play-synthetic

Synthetic Role-Play Conversation Dataset Generation
Python
24
star
6

chat-data-pipeline

Chat data cleaning, filtering and deduplication pipeline.
Python
11
star
7

Slaves-Vk-MiniApp-Bot

8
star
8

accompaniment-generator

Generate accompaniment part with chords using Evolutionary algorithm.
Python
7
star
9

gai-project

Train expert conversational role-play LLMs with synthetic data
Python
6
star
10

numerical-methods

Numerical methods for ordinary differential equations: Euler, Improved Euler, Runge-Kutta.
Python
5
star
11

least-square-approximation

A computer program in C++ programming language to compose a least square approximation.
C++
3
star
12

graph-adt

Graph ADT and its implementation based on adjacency matrix
C++
3
star
13

snowball-fight

Python
3
star
14

tenderhack-volat

TenderHack: рекомендательный сервис для публикации и участия в закупках
CSS
3
star
15

FSAtoRegExp

FSA to RegExp Translator
Python
2
star
16

GymGo

Python
2
star
17

AlekseyKorshuk

2
star
18

VOLAT

C++
2
star
19

os-course

C
2
star
20

studying-notes

Studying notes from my learning journey
2
star
21

AlekseyKorshuk.github.io

HTML
2
star
22

vision-ai

Derive insights from your images in the cloud or at the edge with Vertex AI’s vision capabilities powered by AutoML, or use pre-trained Vision API models to detect emotion, understand text, and more.
2
star
23

dgp

Decision Genetic Programming - Solving OpenAI Gyms
Python
1
star
24

WgForgeDocker

WGForge homework: docker, database.
Python
1
star
25

database-course

PLpgSQL
1
star
26

agi-poe

Python
1
star
27

aml-faster-rcnn-vs-yolovx

Applied Machine Learning Assignment: Comparison of Faster RCNN and Yolovx
Jupyter Notebook
1
star