Package: yookassa-payout
YooMoney Payout API Python Client LibraryRussian| EnglishClient to work on theProtocol for mass payoutsOpportunitiesYou can with this SDK:Generate a certificatefor interaction with YooMoney.Transfer moneyto individuals for wallets in YooMoney, mobile phone numbers, Bank cards and accounts (makeDeposition).To test the possibility of transfer of remittancesto wallets in YooMoney (testDeposition).Keep track of the balance of payouts(balance).Receive notificationsthe unsuccessful status of transfers to a Bank account, card, or mobile phone (errorDepositionNotification).RequirementsPython 3.5 (or later version)pipInstallationUnder console using pipInstall pip.In the console, run the following command:pipinstallyookassa-payoutUnder console using easy_installInstall easy_install.In the console, run the following command:easy_install--upgradeyookassa-payoutManuallyIn the console, run the following command:wgethttps://git.yoomoney.ru/rest/api/latest/projects/SDK/repos/yookassa-payout-sdk-python/archive?format=zip-Oyookassa-payout-sdk-python-master.zip
unzipyookassa-payout-sdk-python-master.zip-dyookassa-payout-sdk-python-mastercdyookassa-payout-sdk-python-master
pythonsetup.pyinstallGetting a certificate for authenticating requestsTo interact with YooMoney.The cashier must obtain a certificate. For this:Create a private key and a certificate request (CSR).Fill out the certificate application form.Exchange data with YooMoney.Step 1. Creating a private key and CSRUsing the SDK methodImport classes to create CSRfromyookassa_payout.domain.models.organizationimportOrganizationfromyookassa_payout.payoutimportPayoutCreate an instance of theOrganizationclass with data for creating the request. All data must be entered in Latin.org=Organization({"org_name":"YooMoney",# Organization Name (Latin)"common_name":"/business/yoomoney",# Common Name, for example the name of your organization; must start with В«/business/В»"email":"cms@yoomoney.ru"# Email})Create a CSR and a private key.# Specify the location where the files should be saved and the password for the private key (if necessary)Payout.get_csr(org,'./files/output','12345')As a result, the SDK will generate a private key, CSR, and a text file with an electronic signature (necessary for further steps).Via the consoleIn the console, go to your project folder.cd'<your project folder>'Execute the command:yookassa-payout -getcsrEnter data for the certificate, following the instructions on the screen. The text must be entered in Latin letters.
As a result, the SDK will generate a private key, CSR, and a text file with an electronic signature (necessary for further steps).Step 2. Filling out the certificate applicationDownload the applicationto the certificate, fill it out and print it out. Sign and seal the document. Scan.ParameterDescriptionCNMust match the value of the Common Name parameter (eg, YOUR name). For example,/business/predpriyatie.Electronic signature of the certificate requestThe text view obtained in the previous step.Organization name in Latin lettersMust match the value of the Organization Name parameter (eg, company)Internet Widgits Pty Ltd.The reason for the requestPossible options:initialвЂ” to get the first certificate;scheduled replacementвЂ” to replace a certificate that has expired;replacement of a compromisedвЂ” to replace a previously issued certificate in the event of a security breach;adding a serverвЂ” to use the new certificate on additional servers or services.Contact person (full name, phone number, e-mail)Contact a specialist to contact you if you have any questions about the issued certificate.Step 3. Data exchange with YooMoneySend the certificate request file (request.csr) and a scan of the request by email to your YooMoney Manager.Box office.
In response to the request, the Manager will send a file with the certificate within 2 business days. The certificate is valid for 1 year.
Place the received certificate on your serverStart of workDetermine what types of payouts you need and whether you want to check your balance.Import required classesfromyookassa_payout.domain.common.keychainimportKeyChainfromyookassa_payout.configurationimportConfigurationfromyookassa_payout.payoutimportPayoutImport the classes you need to solve your problems.Create an instance of theKeyChainclass by passing the path to the public key, the path to the private key, and, if necessary, the password for the private key.keychain=KeyChain('publicCert.cer','privateCert.pem','password')Create an instance of theClientclass and pass the gateway ID from themerchant profileYooMoney and instance of theKeyChainclass.Configuration.configure('000000',keychain)Call the appropriate method.More information about making payoutsExample of payout to a Bank account# Importing classesfromyookassa_payout.configurationimportConfigurationfromyookassa_payout.payoutimportPayoutfromyookassa_payout.domain.common.keychainimportKeyChainfromyookassa_payout.domain.models.recipients.bank_account_recipientimportBankAccountRecipientfromyookassa_payout.domain.request.make_deposition_requestimportMakeDepositionRequest# Creating a housekeeper and saving settingskeychain=KeyChain('./files/250000.cer','./files/privateKey.pem','12345')Configuration.configure(250000,keychain)# Getting the current balancebalance=Payout.get_balance()# The compilation of data on the beneficiaryrecipient=BankAccountRecipient()recipient.pof_offer_accepted=Truerecipient.bank_name='Barclays'recipient.bank_city='London'recipient.bank_cor_account='30101810400000000225'recipient.customer_account='40817810255030943620'recipient.bank_bik='042809679'recipient.payment_purpose='Refund under the agreement 25-001, without VAT'recipient.pdr_first_name='John'recipient.pdr_last_name='Watson'recipient.pdr_doc_number='4002109067'recipient.pdr_doc_issue_date='1999-07-30'recipient.pdr_address='Baker street, 221'recipient.pdr_birth_date='1987-05-24'recipient.sms_phone_number='79653457676'# Preparing a request to create a payoutrequest=MakeDepositionRequest()request.agent_id=250000request.client_order_id='215d8da0-000f-50be-b000-0003308c89be'request.request_dt='2020-03-04T15:39:45.456+03:00'request.payment_params=recipient# The carrying out of the payoutresult=Payout.create_deposition(request)