Comments (5)
Se você entrar no site do nubank você vê as suas transações daquele cartão?
Consegue postar um exemplo de como você está buscando as transações?
from pynubank.
No app eu vejo, mas o porém é que preciso saber qual cartão. Acho que ao cancelar eles apagam a informação. Não sei...
O código a baixo:
#!/bin/python3
from pynubank import Nubank
nu = Nubank()
import json
import os
from meu_googlesheet import googlesheet
import sys
########################
# Dados gerais da fatura
########################
mesabertura = ''
mesfechamento = ''
if len(sys.argv) > 2:
mesabertura = sys.argv[1]
mesfechamento = sys.argv[2]
else:
print("falta argumentos: meunu.py [inicio] [fim]")
exit(0)
hereiam = os.path.expanduser( '~' ) + "/code/meunu"
print("Auntenticando...")
nu.authenticate_with_cert('xxxxxxxx', 'xxxxxxxxx', hereiam+'/cert.p12')
jsonstr=""
bills=[]
print("get_bills...")
bills = nu.get_bills()
bills = [x for x in bills if x["summary"]["open_date"][:7] == mesabertura
and x["summary"]["close_date"][:7] == mesfechamento]
summary = bills[0]["summary"]
abertura = summary["open_date"]
fechamento = summary["close_date"]
#######################
# Registros de compras desabilitado, bills já contem compras (com menos detalhes)
#######################
#card_statements = nu.get_card_statements()
#card_statements = [x for x in card_statements if x["time"][:10] >= summary["open_date"]
# and x["time"][:10] <= summary["close_date"]]
#file = open('lancamento_cartao.json', 'w')
#file.write(json.dumps(card_statements, indent=2))
#file.close()
##############
# Pagamentos
##############
print("get_bill_details...")
bill_details = nu.get_bill_details(bills[0])
r = len(bill_details['bill']['line_items'])
for i in range(r):
percentagem = str(int((i / r) * 100));
print(percentagem + "% ", end="\r")
momentbill = bill_details['bill']['line_items'][i]
file = open(hereiam+'/dump.json', 'w')
file.write(json.dumps(momentbill, indent=2))
file.close()
if momentbill.get('category')!='Pagamento' and momentbill.get("type")!='payment':
if momentbill.get("href"):
idbill = momentbill.get("href").replace('nuapp://transaction/','https://prod-s1-facade.nubank.com.br/api/transactions/')
else:
idbill = 'https://prod-s1-facade.nubank.com.br/api/transactions/' + momentbill.get("loan_id")
momentbill["_links"] = {"self": {
"href": idbill
}}
try:
bill_more_detail=nu.get_card_statement_details(momentbill)
momentbill["card_last_four_digits"] = bill_more_detail['transaction'].get('card_last_four_digits')
except:
print(momentbill)
print("Fineshed ")
file = open(hereiam+'/bills.json', 'w')
file.write(json.dumps(bill_details, indent=2))
file.close()
creditonu = nu.get_credit_card_balance()
creditonu = creditonu['available']/100
## Atualiza Folha de Calculo ###
print("Atualizando Folha de Calculo...")
googlesheet(abertura,fechamento,hereiam,creditonu)
Mais especificamente neste trecho:
file = open(hereiam+'/dump.json', 'w')
file.write(json.dumps(momentbill, indent=2))
file.close()
if momentbill.get('category')!='Pagamento' and momentbill.get("type")!='payment':
if momentbill.get("href"):
idbill = momentbill.get("href").replace('nuapp://transaction/','https://prod-s1-facade.nubank.com.br/api/transactions/')
else:
idbill = 'https://prod-s1-facade.nubank.com.br/api/transactions/' + momentbill.get("loan_id")
momentbill["_links"] = {"self": {
"href": idbill
}}
try:
bill_more_detail=nu.get_card_statement_details(momentbill)
momentbill["card_last_four_digits"] = bill_more_detail['transaction'].get('card_last_four_digits')
except:
print(momentbill)
```
from pynubank.
Talvez meu código esteja antigo ou sujo devido a ter feito a muito tempo, e ser apenas para minhas próprias contas. Eu só preciso do valor e do número cartão que fez a compra.
from pynubank.
Eu fiz um teste aqui e consegui recuperar os 4 ultimos digitos:
nu = Nubank()
nu.authenticate_with_cert(...)
transactions = nu.get_card_statements()
transaction = transactions[0]
details = nu.get_card_statement_details(transaction)
print(f'card_last_four_digits={details["transaction"]["card_last_four_digits"]}')
from pynubank.
nu = Nubank() nu.authenticate_with_cert(...) transactions = nu.get_card_statements() transaction = transactions[0] details = nu.get_card_statement_details(transaction) print(f'card_last_four_digits={details["transaction"]["card_last_four_digits"]}')
Agradeço Imensamente o código resumido.
Mas acho que eles tiram a referencia mesmo porque aparece isso:
Auntenticando...
Traceback (most recent call last):
File "/home/tneves/code/meunu/a.py", line 14, in <module>
details = nu.get_card_statement_details(transaction)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tneves/.local/lib/python3.12/site-packages/pynubank/auth_mode.py", line 23, in wrapper
return function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tneves/.local/lib/python3.12/site-packages/pynubank/nubank.py", line 202, in get_card_statement_details
return self._client.get(statement['_links']['self']['href'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tneves/.local/lib/python3.12/site-packages/pynubank/utils/http.py", line 46, in get
return self._handle_response(self.raw_get(url))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tneves/.local/lib/python3.12/site-packages/pynubank/utils/http.py", line 35, in _handle_response
raise NuRequestException(response)
pynubank.exception.NuRequestException: The request made failed with HTTP status code 400
Como se não existisse a referência.
Será que perde-se mesmo?
from pynubank.
Related Issues (20)
- Possibilidade de verificar se um pix foi recebido na conta. HOT 4
- (WSL) Erro ao tentar requisitar um código via email HOT 1
- Erro no método get_bill_details HOT 2
- Erro com o get_pix_identifier HOT 6
- Refresh certificate HOT 9
- Mudança na API que gera certificados HOT 1
- Não é possível acessar os dados da Nuconta (Extrato, saldo, etc) HOT 146
- Por onde Começar para Replicar para a XP HOT 2
- pynubank.exception.NuRequestException: The request made failed with HTTP status code 401 HOT 1
- Envio de pagamento via PIX
- Gerar Certificado
- Renomear Transação
- Erro 400 quando requisitando algumas transações HOT 1
- Erro 401 em requisições para a conta HOT 1
- Não consigo Gerar um Certificado HOT 13
- pynubank.exception.NuRequestException: The request made failed with HTTP status code 401 HOT 1
- pynubank.exception.NuRequestException: The request made failed with HTTP status code 401 [POR FAVOR NÃO FECHA ESSE ISSUE] HOT 2
- Alguém pode me ajudar com o PyNubank HOT 3
- Ainda esta em funcionamento a lib ? Esta solicitando a autorização do dispositivo apos a geração do certificado ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pynubank.