Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atualização do README.md #71

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 36 additions & 5 deletions examples/flask/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
FlaskSeguro
==========
Exemplo do python-pagseguro utilizando Flask.
Exemplo de integração do python-pagseguro utilizando Flask.

Instalação
Instalando a virtualenv
==========

```bash
virtualenv env
pip install -U pip
pip install virtualenv
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eu acho que você poderia utilizar o pipenv ou poetry ao invés de criar o virtualenv na mão, apesar destas libs utilizar por debaixo dos panos o virtualenv, ganhamos algumas features como versionamento, lock file e etc...

```
Caso tenha alguma dúvida sobre a virtualenv ou ocorra algum erro no momento da instalação, verifique a documentação [clicando aqui](https://virtualenv.pypa.io/en/stable/installation/).

Download e Instalação
==========
Testado com o Python 3.6 >.

```bash
virtualenv -p python3 env
source env/bin/activate
git clone https://github.com/rochacbruno/python-pagseguro.git
cd python-pagseguro/examples/flask/
pip install -r requirements.txt
./run.py
```

Execução
==========
Com o terminal aberto e setado na pasta _python-pagseguro/examples/flask_, execute o seguinte comando:

```bash
env FLASK_APP=run.py flask run
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FLASK_APP é uma variável de ambiente, utilize o export para exporta-la. Ou sugiro também add uma referência para o SET do CMD Windows.

Referência: https://flask.palletsprojects.com/en/1.0.x/cli/

```

Configuração
==========
Altere o settings.cfg, ele possui as seguintes configurações por padrão:
Altere o _settings.cfg_, ele possui as seguintes configurações por padrão:

```
EXTRA_AMOUNT = 12.12
REDIRECT_URL = "http://meusite.com/obrigado"
Expand All @@ -26,11 +44,24 @@ TOKEN = "ABCDEFGHIJKLMNO"
SECRET_KEY = "s3cr3t"
```

Caso as alterações não sejam feitas, o PagSeguro te notificará de erro retornando a seguinte mensagem _Código de checkout inválido_:

![](https://raw.githubusercontent.com/JacksonOsvaldo/python-pagseguro/master/examples/flask/screenshots/screen4.png)



Testes
==========
Para executar alguns testes e verificar se está tudo certo com a aplicação, execute:

```bash
./tests.py
```

Caso retorne algum erro, dê permissão ao arquivo e reexecute o comando acima. Assim:

```bash
chmod +x tests.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eu ainda estou em dúvida sobre isso, mas eu acredito que não precisa da permissão para rodar os testes. Caso sinta dificuldade de utilizar o Makefile rode manualmente assim: pytest <test_file.py>.

O que acha @mazulo e @rochacbruno ?

./tests.py
```

Expand Down
Binary file added examples/flask/screenshots/screen4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.