# SDK Python3 para Integração com Safe2Pay
Esta SDK foi desenvolvida para abstrair aos desenvolvedores os principais detalhes da comunicação com API da Safe2Pay tanto em produção quanto ambiente sandbox.
Você pode acessar a documentação base da api aqui: [Api Safe2Pay](https://developers.safe2pay.com.br/).
![Licença](https://img.shields.io/github/license/robertons/safe2pay) ![image](https://img.shields.io/pypi/v/safe2pay) ![image](https://img.shields.io/pypi/status/safe2pay) ![image](https://img.shields.io/badge/python-v3.9-blue) ![image](https://img.shields.io/badge/build-passing-brightgreen) ![image](https://img.shields.io/badge/coverage-100%25-brightgreen) ![image](https://img.shields.io/github/last-commit/robertons/safe2pay)
# Instalação
Instalação utilizando Pip
```bash
pip install safe2pay
```
Git/Clone
```
git clone https://github.com/robertons/safe2pay
cd safe2pay
pip install -r requirements.txt
python setup.py install
```
# Objetos
Os objetos neste SDK podem ser criados em 3 (três) formas distintas a critério do utilizador.
## Criação
**Método 1 - Construtor**
```python
objeto = Objeto(campo1 = 'valor', campo2 = 'valor 2', campo_datetime = datetime.now(), campo_float = 10.1)
```
**Método 2 - Construtor com Dict**
```python
objeto = Objeto(**{'campo1':'valor', 'campo2':'valor 2', 'campo_datetime':datetime.now(), 'campo_float' = 10.1})
```
**Método 3 - Preenchimento Individual de Campos**
```python
objeto = Objeto()
objeto.campo1 = 'valor'
objeto.campo2 = 'valor 2'
objeto.campo_datetime = datetime.now()
objeto.campo_float = 10.1
```
## Método toJSON
Método toJSON() retorna os dados do Objeto em formato *dicionário* não codificados.
```python
objeto = Objeto(...)
print(objeto.toJSON())
```
## Configuração Inicial
|posição | campo | obrigatório | padrão | descrição |
|--|--|--|--|--|
| 1 | token | **sim** | |token da conta Safe2Pay
| 2 | secretKey | **não** | | secretKey da conta Safe2Pay
| 3 | sandbox | **não** | **False** | Ambiente Produção/Sandbox
| 4 | debug | **não** | **False** | Depuração de Request Post, Get, Put, Patch e Delete e Resposta Safe2Pay
```python
import safe2pay
safe2pay.Safe2Pay('token', 'secretKey', sandbox=True, debug=False)
```
**Mais detalhes em [Documentação Oficial](https://developers.safe2pay.com.br/README?id=autentica%c3%a7%c3%a3o)**
# Documentação pendente de atualização
## Cliente
### Criar
```python
cliente = pagarmepy.Customer()
cliente.name = 'Fulano Beltrano'
cliente.email = 'fulano@email.com'
cliente.birthdate = '1980-01-30'
cliente.phones = pagarmepy.Phones(**{'mobile_phone': { "country_code": 55, "area_code": 27, "number": 999999999}})
cliente.Create()
```
### Obter
```python
cliente = pagarmepy.Customer(id='cus_bjgeDobdLsEO48nw').Get()
```
### Atualizar
```python
cliente = pagarmepy.Customer(id='cus_bjgeDobsLsEO48nw').Get()
cliente.address = pagarmepy.Address(line_1='Rua Capitao Domingos Correa da Rocha, 80, Sala 116', line_2='Ed Master Place, Santa Lucia', city='Vitória', state='ES', country='BR', zip_code='29056220')
client.Update()
```
### Listar
```python
clientes = pagarmepy.Customer().List(filters={'page':1, 'size':10, 'gender':'female'})
```
**Mais detalhes em [Documentação Oficial](https://docs.pagar.me/reference/clientes-1)**
## Cartões
### Criar
```python
card = pagarmepy.Card()
card.first_six_digits = "400000"
card.last_four_digits = "0010"
card.brand = "Mastercard"
card.holder_name = "Tony Stark"
card.holder_document = "93095135270"
card.number = "4000000000000010"
card.exp_month = 1
card.exp_year = 2030
card.cvv = 123
card.billing_address = pagarmepy.Address(**{
"zip_code": "22000111",
"city": "Rio de Janeiro",
"state": "RJ",
"country": "BR",
"line_1": "375, Av. General Osorio, Centro",
"line_2": "7º Andar"
})
card.Create(customer_id='cus_bjgeDobsLsEO48nw')
```
### Obter
```python
card = pagarmepy.Card(id="card_MJYE2GDSLHjjkawL").Get(customer_id="cus_bjgeDobsLsEO48nw")
```
### Atualizar
```python
card = pagarmepy.Card(id="card_MJYE2GDSLHjjkawL").Get(customer_id="cus_bjgeDobsLsEO48nw")
card.exp_month = 2
card.exp_year = 2035
card.billing_address = pagarmepy.Address(**{'line_1':'Rua Capitao Domingos Correa da Rocha, 80, Sala 116', 'line_2':'Ed Master Place, Santa Lucia', 'city':'Vitória', 'state':'ES', 'country':'BR', 'zip_code':'29056220'})
card.Update(customer_id="cus_bjgeDobsLsEO48nw")
print(card.toJSON())
```
### Listar
```python
cards = pagarmepy.Card().List(customer_id='cus_bjgeDobsLsEO48nw')
```
### Excluir
```python
pagarmepy.Card(id="card_MJYE2GDSLHjjkawL").Delete(customer_id="cus_bjgeDobsLsEO48nw")
```
### Renovar
```python
card = pagarmepy.Card(id="card_G4QnR6ck7cgBn8XR").Renew(customer_id="cus_bjgeDobsLsEO48nw")
```
### Criar Token
```python
token = pagarmepy.Token()
token.type = "card"
token.card = pagarmepy.Card(
first_six_digits = "400000",
last_four_digits = "0010",
brand = "Mastercard",
holder_name = "Tony Stark",
holder_document = "93095135270",
number = "4000000000000010",
exp_month = 1,
exp_year = 2030,
cvv = 123,
billing_address = pagarmepy.Address(**{
"zip_code": "22000111",
"city": "Rio de Janeiro",
"state": "RJ",
"country": "BR",
"line_1": "375, Av. General Osorio, Centro",
"line_2": "7º Andar"
})
)
token.Create(appId='pk_test_Y479412hrHMQ956j')
```
**Mais detalhes em [Documentação Oficial](https://docs.pagar.me/reference/cart%C3%B5es-1)**
## Endereços
### Criar
```python
address = pagarmepy.Address(**{
"zip_code": "22000111",
"city": "Rio de Janeiro",
"state": "RJ",
"country": "BR",
"line_1": "375, Av. General Osorio, Centro",
"line_2": "7º Andar"
})
address.Create(customer_id='cus_bjgeDobsLsEO48nw')
```
### Obter
```python
address = pagarmepy.Address(id="addr_lOAgNqH1wCxD6eYd").Get(customer_id="cus_bjgeDobsLsEO48nw")
```
### Atualizar
```python
address = pagarmepy.Address(id="addr_BNwDJk2TPTmXGArR").Get(customer_id="cus_bjgeDobsLsEO48nw")
address.line_2 = 'Master Place, Itararé'
address.Update(customer_id='cus_bjgeDobsLsEO48nw')
```
### Listar
```python
addresses = pagarmepy.Address().List(customer_id='cus_bjgeDobsLsEO48nw')
```
### Excluir
```python
pagarmepy.Address(id="addr_lOAgNqH1wCxD6eYd").Delete(customer_id="cus_bjgeDobsLsEO48nw")
```
## BIN
Os seis primeiros dígitos de um número de cartão (incluindo o dígito MII inicial) são conhecidos como o número de identificação do emissor (IIN) ou número de identificação do banco (BIN). Estes números identificam a instituição que emitiu o cartão ao titular do cartão. O restante do número é alocado pelo emissor. Para obter as informações do Emissor:
### Obter
```python
bin = pagarmepy.BIN().Get(bin='555566')
```
## PEDIDOS
Veja a documentação oficial para pedidos com pagamentos multimeios, pedidos com multicompradores.
**Mais detalhes em [Documentação Oficial](https://docs.pagar.me/reference/pedidos-1)**
### Criar
Exemplo Pedido com Checkout:
```python
pedido = pagarmepy.Order()
pedido.customer_id = "cus_bjgeDobsLsEO48nw"
pedido.code = "62LVFN7I4R"
pedido.amount = 2900
pedido.currency = "BRL"
pedido.items.add(pagarmepy.Item(**{
"id": "oi_d478RMAS3bC74PrL",
"description": "Chaveiro do Tesseract",
"amount": 2900,
"quantity": 1,
"status": "active",
"code":"abc"
}))
pedido.shipping = pagarmepy.Shipping(**{
"amount": 100,
"description": "Stark",
"recipient_name": "Tony Stark",
"recipient_phone": "24586787867",
"address": {
"line_1": "10880, Malibu Point, Malibu Central",
"zip_code": "90265",
"city": "Malibu",
"state": "CA",
"country": "US"
}})
pedido.payments.add(pagarmepy.Payment(**{
"amount" : 3000,
"payment_method":"checkout",
"checkout": {
"expires_in":120,
"billing_address_editable" : False,
"customer_editable" : False,
"accepted_payment_methods": ["credit_card"],
"success_url": "https://www.pagar.me",
}
}))
pedido.Create()
```
### Obter
```python
pedido = pagarmepy.Order(id="or_jP82N8VUpXhyYr4b").Get()
```
### Listar
```python
pedidos = pagarmepy.Order().List(customer_id='cus_bjgeDobsLsEO48nw')
```
```python
pedidos = pagarmepy.Order().List()
```
### Fechar um Pedido
```python
pedido = pagarmepy.Order(id="or_jP82N8VUpXhyYr4b").Close()
```
### Excluir
```python
pagarmepy.Address(id="addr_lOAgNqH1wCxD6eYd").Delete(customer_id="cus_bjgeDobsLsEO48nw")
```
## COBRANÇAS
### Obter
```python
cobranca = pagarmepy.Charge(id="ch_Rz8oL2vcjwc3D1OQ").Get()
```
### Capturar Valor Integral
```python
cobranca = pagarmepy.Charge(id="ch_Rz8oL2vcjwc3D1OQ").Capture()
```
### Capturar Valor Parcial
```python
cobranca = pagarmepy.Charge(id="ch_Rz8oL2vcjwc3D1OQ").Capture(amount=10)
```
### Editar cartão de cobrança
```python
cobranca = pagarmepy.Charge(id="ch_Pr5R4D5izhEbyNQY").ChangeCard(pagarmepy.Card(
first_six_digits = "400000",
last_four_digits = "0010",
brand = "Mastercard",
holder_name = "Tony Stark",
holder_document = "93095135270",
number = "4000000000000010",
exp_month = 1,
exp_year = 2030,
cvv = 123,
billing_address = pagarmepy.Address(**{
"zip_code": "22000111",
"city": "Rio de Janeiro",
"state": "RJ",
"country": "BR",
"line_1": "375, Av. General Osorio, Centro",
"line_2": "7º Andar"
})))
```
### Editar data de vencimento da cobrança
```python
cobranca = pagarmepy.Charge(id="ch_Rz8oL2vcjwc3D1OQ").ChangeDueDate('2022-10-21')
```
### Editar método de pagamento
```python
cobranca = pagarmepy.Charge(id="ch_Rz8oL2vcjwc3D1OQ").ChangePaymentMethod(pagarmepy.Payment(**{
"amount" : 3000,
"payment_method":"boleto",
"boleto": {
"instructions": "Instrução de boleto de teste",
"due_at" : "2022-10-20T14:30:22",
"document_number" : "123456",
"type": "DM"
}
}))
```
```python
cobranca = pagarmepy.Charge(id="ch_Pr5R4D5izhEbyNQY").ChangePaymentMethod(pagarmepy.Payment(**{
"amount" : 3000,
"payment_method":"credit_card",
"credit_card": {
'card_id': "card_G4QnR6ck7cgBn8XR",
}
}))
```
### Cancelar Cobrança
```python
cobranca = pagarmepy.Charge(id="ch_Rz8oL2vcjwc3D1OQ").Delete()
```
### Listar
```python
cobrancas = pagarmepy.Charge().List()
```
### Retentar uma cobrança manualmente
```python
cobranca = pagarmepy.Charge(id="ch_Rz8oL2vcjwc3D1OQ").Retry()
```
### Confirmar cobrança (cash)
```python
cobranca = pagarmepy.Charge(id="ch_Rz8oL2vcjwc3D1OQ").Confirm()
```
# RECORRÊNCIA
**Mais detalhes em [Documentação Oficial](https://docs.pagar.me/reference/vis%C3%A3o-geral-da-recorr%C3%AAncia)**
## PLANOS
### Criar
```python
plano = pagarmepy.Plan()
plano.name = "Plano Mensal Teste"
plano.description = "Plano de teste de integração API"
plano.shippable = False
plano.payment_methods.add('credit_card')
plano.statement_descriptor = 'Assinatura'
plano.currency = 'BRL'
plano.interval = 'month'
plano.interval_count = 1
plano.billing_type = 'prepaid'
plano.quantity = 1
plano.pricing_scheme = pagarmepy.PricingScheme(**{
"scheme_type": "unit",
"price": 5000,
"minimum_price": 5000,
})
plano.Create()
```
### Obter
```python
plano = pagarmepy.Plan(id="plan_ODjw15Af9WUgzwkg").Get()
```
### Listar
```python
plano = pagarmepy.Plan().List()
```
### Excluir
```python
pagarmepy.Plan(id="plan_ODjw15Af9WUgzwkg").Delete()
```
### Atualizar
```python
plano = pagarmepy.Plan(id="plan_ODjw15Af9WUgzwkg").Get()
plano.statement_descriptor = "AST Test"
plano.Update()
```
### Modificar Metadata
```python
plano = pagarmepy.Plan(id="plan_VR92ne8UEUGWNMAa").ChangeMetadata(
campo1 = 'valor 1',
campo2 = 'valor 2',
camponumero = 3
)
```
## Items do Plano
### Adicionar Item
```python
items_planos = pagarmepy.Plan(id="plan_brJdw1jTlTa89zyQ").AddItem(pagarmepy.Item(**{
"description": "Chaveiro do Alternativo",
"quantity": 1,
"pricing_scheme": {
"price": 2000,
"scheme_type": "unit"
}
}))
```
### Atualizar Item
```python
items_planos = pagarmepy.Plan(id="plan_brJdw1jTlTa89zyQ").UpdateItem(pagarmepy.Item(**{
"id": "pi_d478RMAS3bC74PrL",
"description": "Chaveiro do Tesseract Antigo",
"status": "active",
"quantity": 1,
"pricing_scheme": {
"price": 3000,
"scheme_type": "unit"
}
}))
```
### Excluir Item
```python
pagarmepy.Plan(id="plan_brJdw1jTlTa89zyQ").DeleteItem("pi_d478RMAS3bC74PrL")
```
## ASSINATURAS
### Criar Assinatura Avulsa
```python
assinatura = pagarmepy.Subscription()
assinatura.code = '1234'
assinatura.customer_id = "cus_bjgeDobsLsEO48nw"
assinatura.interval = 'month'
assinatura.interval_count = 1
assinatura.currency = 'BRL'
assinatura.payment_method = "credit_card"
assinatura.billing_type = 'prepaid'
assinatura.installments = 1
assinatura.statement_descriptor = "AST Gofans"
assinatura.items.add(pagarmepy.Item(**{
"id": "oi_d478RMAS3bC74PrL",
"description": "Chaveiro do Tesseract",
"amount": 2900,
"quantity": 1,
"status": "active",
"code":"abc",
"pricing_scheme":{
"scheme_type": "Unit",
"price": 2900
}
}))
assinatura.card = pagarmepy.Card(**{
"number": "4000000000000010",
"holder_name": "Tony Stark",
"exp_month": 1,
"exp_year": 30,
"cvv": "3531",
"billing_address": {
"line_1": "10880, Malibu Point, Malibu Central",
"zip_code": "90265",
"city": "Malibu",
"state": "CA",
"country": "US"
}
})
assinatura.Create()
```
### Criar Assinatura de um Plano
```python
assinatura = pagarmepy.Subscription()
assinatura.code = '1234'
assinatura.customer_id = "cus_bjgeDobsLsEO48nw"
assinatura.plan_id = "plan_VR92ne8UEUGWNMAa"
assinatura.interval = 'month'
assinatura.interval_count = 1
assinatura.currency = 'BRL'
assinatura.payment_method = "credit_card"
assinatura.billing_type = 'prepaid'
assinatura.installments = 1
assinatura.statement_descriptor = "AST Gofans"
assinatura.card = pagarmepy.Card(**{
"number": "4000000000000010",
"holder_name": "Tony Stark",
"exp_month": 1,
"exp_year": 30,
"cvv": "3531",
"billing_address": {
"line_1": "10880, Malibu Point, Malibu Central",
"zip_code": "90265",
"city": "Malibu",
"state": "CA",
"country": "US"
}
})
assinatura.Create()
```
### Obter
```python
assinaturas = pagarmepy.Subscription(id="sub_9ZVy143Hd1HODql1").Get()
```
### Listar
```python
assinaturas = pagarmepy.Subscription().List()
```
### Cancelar
```python
assinaturas = pagarmepy.Subscription(id="sub_9ZVy143Hd1HODql1").Delete()
```
### Editar cartão da assinatura
```python
assinatura = pagarmepy.Subscription(id="sub_Gdg4m3BTrqTyoK01").ChangePaymentMethod(pagarmepy.Payment(**{
"payment_method":"credit_card",
'card_id': "card_G4QnR6ck7cgBn8XR",
}))
```
### Editar metadados da assinatura
```python
assinatura = pagarmepy.Subscription(id="sub_9ZVy143Hd1HODql1").ChangeMetadata(
campo1 = 'valor 1',
campo2 = 'valor 2',
camponumero = 3
)
```
### Editar meio de pagamento da assinatura
```python
assinatura = pagarmepy.Subscription(id="sub_9ZVy143Hd1HODql1").ChangePaymentMethod(pagarmepy.Payment(**{
"payment_method":"boleto",
"boleto": {
"instructions": "Instrução de boleto de teste",
"due_at" : "2022-10-20T14:30:22",
"document_number" : "123456",
"type": "DM"
}
}))
```
ou
```python
assinatura = pagarmepy.Subscription(id="sub_9ZVy143Hd1HODql1").ChangePaymentMethod(pagarmepy.Payment(**{
"payment_method":"credit_card",
"credit_card": {
'card_id': "card_G4QnR6ck7cgBn8XR",
}
}))
```
### Editar data de início da assinatura
```python
assinatura = pagarmepy.Subscription(id="sub_9ZVy143Hd1HODql1").ChangeStarteDate('2022-10-21')
```
### Editar preço mínimo da assinatura
```python
assinatura = pagarmepy.Subscription(id="sub_9ZVy143Hd1HODql1").ChangeMinimumPrice(10000)
```
### Ativar faturamento manual
```python
assinatura = pagarmepy.Subscription(id="sub_9ZVy143Hd1HODql1").SetManualBilling(True)
```
### Desativar faturamento manual
```python
assinatura = pagarmepy.Subscription(id="sub_9ZVy143Hd1HODql1").SetManualBilling(False)
```
## Items de Assinatura
### Adicionar Item
```python
items_asssinaturas = pagarmepy.Subscription(id="sub_brJdw1jTlTa89zyQ").AddItem(pagarmepy.Item(**{
"description": "Chaveiro do Alternativo",
"quantity": 1,
"pricing_scheme": {
"price": 2000,
"scheme_type": "unit"
}
}))
```
### Atualizar Item
```python
items_asssinaturas = pagarmepy.Subscription(id="sub_brJdw1jTlTa89zyQ").UpdateItem(pagarmepy.Item(**{
"id": "oi_d478RMAS3bC74PrL",
"description": "Chaveiro do Tesseract Antigo",
"status": "active",
"quantity": 1,
"pricing_scheme": {
"price": 3000,
"scheme_type": "unit"
}
}))
```
### Listar Items
```python
items_asssinaturas = pagarmepy.Subscription(id="sub_brJdw1jTlTa89zyQ").ListItems()
```
### Excluir Item
```python
pagarmepy.Subscription(id="sub_brJdw1jTlTa89zyQ").DeleteItem("oi_d478RMAS3bC74PrL")
```
## Uso de Items de Assinatura
### Incluir Uso
```python
uso = pagarmepy.Usage()
uso.quantity = 1
uso.description = "Uso de teste"
uso.Create(subscription_id="sub_brJdw1jTlTa89zyQ", item_id="si_Ww2DP2eHzHnolqbn")
```
### Remover Uso
```python
pagarmepy.Usage(id="usage_2VBDB53fWfjgnZpX").Delete(subscription_id="sub_1VRDB5AfWfjBnZpx", item_id="si_QjGb0BZUkUD0Eyag")
```
### Listar Uso
```python
usos = pagarmepy.Usage().List(subscription_id="sub_1VRDB5AfWfjBnZpx", item_id="si_QjGb0BZUkUD0Eyag")
```
## Descontos
### Incluir
```python
desconto = pagarmepy.Discount()
desconto.uso.value = 100
desconto.increment_type = 'flat'
desconto.Create(subscription_id="sub_brJdw1jTlTa89zyQ")
```
### Obter
```python
desconto = pagarmepy.Discount(id="dis_2VBDB53fWfjgnZpX").Get(subscription_id="sub_brJdw1jTlTa89zyQ")
```
### Remover
```python
pagarmepy.Discount(id="dis_2VBDB53fWfjgnZpX").Delete(subscription_id="sub_brJdw1jTlTa89zyQ")
```
### Listar
```python
descontos = pagarmepy.Discount().List(subscription_id="sub_brJdw1jTlTa89zyQ")
```
## Incremento
### Incluir
```python
incremento = pagarmepy.Increment()
desconto.uso.value = 100
desconto.increment_type = 'flat'
desconto.Create(subscription_id="sub_brJdw1jTlTa89zyQ")
```
### Obter
```python
incremento = pagarmepy.Increment(id="inc_2VBDB53fWfjgnZpX").Get(subscription_id="sub_brJdw1jTlTa89zyQ")
```
### Remover
```python
pagarmepy.Increment(id="inc_2VBDB53fWfjgnZpX").Delete(subscription_id="sub_brJdw1jTlTa89zyQ")
```
### Listar
```python
incrementos = pagarmepy.Increment().List(subscription_id="sub_brJdw1jTlTa89zyQ")
```
## Modificar Regras Split
```python
assinatura = pagarmepy.Subscription()
assinatura.id = "sub_brJdw1jTlTa89zyQ"
assinatura.split.add(pagarmepy.Split(**{
"amount": 50,
"recipient_id": "rp_n9voQ2QT0SQrMwOL",
"type": "percentage",
"options": {
"charge_processing_fee": True,
"charge_remainder_fee": True,
"liable": True
}
}))
assinatura.split.add(pagarmepy.Split(**{
"amount": 50,
"type": "percentage",
"recipient_id": "rp_6gyn5oIvAcwjrNej",
"options": {
"charge_processing_fee": False,
"charge_remainder_fee": False,
"liable": False
}
}))
assinatura.ChangeSplitRule(enabled=True)
```
## Ciclos
### Renovar Ciclo
```python
ciclo = pagarmepy.Cycle(id="cycle_brJdw1jTlTa89zyQ").Renew()
```
### Obter
```python
ciclos = pagarmepy.Cycle(id="cycle_VWk4gY6TMPHN7A0g").Get(subscription_id="sub_9ZVy143Hd1HODql1")
```
### Listar
```python
ciclos = pagarmepy.Cycle().List(subscription_id="sub_9ZVy143Hd1HODql1")
```
## Faturas
### Criar
```python
fatura = pagarmepy.Invoice().Create(subscription_id='sub_brJdw1jTlTa89zyQ', cycle_id='cycle_v0dxrO3i2iyr5J9X')
```
### Obter
```python
fatura = pagarmepy.Invoice(id="in_VWk4gY6TMPHN7A0g").Get()
```
### Listar
```python
fatura = pagarmepy.Invoice().List()
```
### Modificar Metadata
```python
fatura = pagarmepy.Invoice(id="in_VWk4gY6TMPHN7A0g").ChangeMetadata(
campo1 = 'valor 1',
campo2 = 'valor 2',
camponumero = 3
)
```
### Cancelar Fatura
```python
fatura = pagarmepy.Invoice(id="in_VWk4gY6TMPHN7A0g").Delete()
```
## Recebedores
### Criar
```python
recebedor = pagarmepy.Recipient()
recebedor.name = 'Joao da Silva'
recebedor.email = "joaodasilva@gmail.com"
recebedor.document = '000011233000'
recebedor.description = 'Recebedor teste de cadastro'
recebedor.type = 'individual'
recebedor.default_bank_account = pagarmepy.BankAccount(**{
"holder_name": "Joao da Silva",
"holder_type": "individual",
"holder_document": '000011233000',
"bank": "033",
"type": "checking",
"branch_number": "4444",
"branch_check_digit": "0",
"account_number": "11223344",
"account_check_digit": "5",
})
recebedor.Create()
print(recebedor.toJSON())
```
### Obter
```python
recebedor = pagarmepy.Recipient(id="rp_JPx17b8H9HgwY5zo").Get()
```
### Atualizar
```python
recebedor = pagarmepy.Recipient(id="rp_WGAn6Q4SySWZBlRy").Get()
recebedor.description = "Descrição Alterada de Recebedor"
recebedor.Update()
```
### Listar
```python
recebedores = pagarmepy.Recipient().List()
```
### Saldo
```python
saldo = pagarmepy.Recipient(id="rp_JPx17b8H9HgwY5zo").GetBalance()
```
### Alterar Conta Bancária Padrão
```python
recebedor = pagarmepy.Recipient(id="rp_JPx17b8H9HgwY5zo").ChangeDefaultBankAccount(pagarmepy.BankAccount(**{
"holder_name": "Roberto Neves da Silva",
"holder_type": "individual",
"holder_document": '09292800752',
"bank": "033",
"type": "checking",
"branch_number": "4316",
"branch_check_digit": "0",
"account_number": "01001647",
"account_check_digit": "3",
}))
```
### Alterar Configurações de Transferência
```python
recebedor = pagarmepy.Recipient(id="rp_WGAn6Q4SySWZBlRy").ChangeTransferSettings(transfer_enabled=True, transfer_interval="monthly", transfer_day="1")
```
### Alterar Configurações de Antecipação de Recebíveis
```python
pagarmepy.Recipient(id="rp_WGAn6Q4SySWZBlRy").ChangeAnticipationSettings(enabled=True, type="full", volume_percentage="100", days=["1","2"], delay="1")
```
### Criar Saque
```python
saque = pagarmepy.Recipient(id="rp_WGAn6Q4SySWZBlRy").DoWithdraw(100)
```
### Obter Saque
```python
saque = pagarmepy.Recipient(id="rp_WGAn6Q4SySWZBlRy").GetWithdraw("with_LR4Wxpqt68ul2W9M")
```
### Listar Saques
```python
saques = pagarmepy.Recipient(id="rp_WGAn6Q4SySWZBlRy").ListWithdrawals()
```
## Suporte Oficial da Safe2Pay
Em caso de dúvidas, problemas ou sugestões: [suporte@safe2pay.com.br](mailto:suporte@safe2pay.com.br)
## Change log
Veja em [CHANGELOG](CHANGELOG.md) para maiores informações sobre as mudanças recentes
## Contribuições
As contribuições por meio de `Pull Requests` são bem-vindas e serão totalmente creditadas.
## Segurança
Se você descobrir qualquer problema relacionado à segurança, envie um e-mail para robertonsilva@gmail.com
## Créditos
- Autor [Roberto Neves](https://github.com/robertons)
## Licença
Veja em [LICENÇA](LICENSE) para maiores informações sobre a licença de uso.
Raw data
{
"_id": null,
"home_page": "https://github.com/robertons/safe2pay",
"name": "safe2pay",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "safe2pay,pagamento,cart\u00e3o de cr\u00e9dito,boleto,pix,pagamentos,transa\u00e7\u00f5es,payment,payments,credit-card",
"author": "Roberto Neves",
"author_email": "robertonsilva@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/ef/42/1ed06bf0fdadefded15c83b3ec25b5494bf9b8553d01cd97329a7f573195/safe2pay-0.0.16.tar.gz",
"platform": null,
"description": "# SDK Python3 para Integra\u00e7\u00e3o com Safe2Pay\n\nEsta SDK foi desenvolvida para abstrair aos desenvolvedores os principais detalhes da comunica\u00e7\u00e3o com API da Safe2Pay tanto em produ\u00e7\u00e3o quanto ambiente sandbox.\n\nVoc\u00ea pode acessar a documenta\u00e7\u00e3o base da api aqui: [Api Safe2Pay](https://developers.safe2pay.com.br/).\n\n![Licen\u00e7a](https://img.shields.io/github/license/robertons/safe2pay) ![image](https://img.shields.io/pypi/v/safe2pay) ![image](https://img.shields.io/pypi/status/safe2pay) ![image](https://img.shields.io/badge/python-v3.9-blue) ![image](https://img.shields.io/badge/build-passing-brightgreen) ![image](https://img.shields.io/badge/coverage-100%25-brightgreen) ![image](https://img.shields.io/github/last-commit/robertons/safe2pay)\n\n# Instala\u00e7\u00e3o\nInstala\u00e7\u00e3o utilizando Pip\n```bash\npip install safe2pay\n```\nGit/Clone\n```\ngit clone https://github.com/robertons/safe2pay\ncd safe2pay\npip install -r requirements.txt\npython setup.py install\n```\n# Objetos\n\nOs objetos neste SDK podem ser criados em 3 (tr\u00eas) formas distintas a crit\u00e9rio do utilizador.\n\n## Cria\u00e7\u00e3o\n\n**M\u00e9todo 1 - Construtor**\n```python\nobjeto = Objeto(campo1 = 'valor', campo2 = 'valor 2', campo_datetime = datetime.now(), campo_float = 10.1)\n```\n**M\u00e9todo 2 - Construtor com Dict**\n```python\nobjeto = Objeto(**{'campo1':'valor', 'campo2':'valor 2', 'campo_datetime':datetime.now(), 'campo_float' = 10.1})\n```\n**M\u00e9todo 3 - Preenchimento Individual de Campos**\n```python\nobjeto = Objeto()\nobjeto.campo1 = 'valor'\nobjeto.campo2 = 'valor 2'\nobjeto.campo_datetime = datetime.now()\nobjeto.campo_float = 10.1\n```\n## M\u00e9todo toJSON\n\nM\u00e9todo toJSON() retorna os dados do Objeto em formato *dicion\u00e1rio* n\u00e3o codificados.\n\n```python\nobjeto = Objeto(...)\nprint(objeto.toJSON())\n```\n\n\n## Configura\u00e7\u00e3o Inicial\n|posi\u00e7\u00e3o | campo | obrigat\u00f3rio | padr\u00e3o | descri\u00e7\u00e3o |\n|--|--|--|--|--|\n| 1 | token | **sim** | |token da conta Safe2Pay\n| 2 | secretKey | **n\u00e3o** | | secretKey da conta Safe2Pay\n| 3 | sandbox | **n\u00e3o** | **False** | Ambiente Produ\u00e7\u00e3o/Sandbox\n| 4 | debug | **n\u00e3o** | **False** | Depura\u00e7\u00e3o de Request Post, Get, Put, Patch e Delete e Resposta Safe2Pay\n\n```python\nimport safe2pay\n\nsafe2pay.Safe2Pay('token', 'secretKey', sandbox=True, debug=False)\n```\n\n**Mais detalhes em [Documenta\u00e7\u00e3o Oficial](https://developers.safe2pay.com.br/README?id=autentica%c3%a7%c3%a3o)**\n\n# Documenta\u00e7\u00e3o pendente de atualiza\u00e7\u00e3o\n## Cliente\n\n### Criar\n\n```python\n cliente = pagarmepy.Customer()\n cliente.name = 'Fulano Beltrano'\n cliente.email = 'fulano@email.com'\n cliente.birthdate = '1980-01-30'\n cliente.phones = pagarmepy.Phones(**{'mobile_phone': { \"country_code\": 55, \"area_code\": 27, \"number\": 999999999}})\n cliente.Create()\n\n```\n\n### Obter\n```python\n\tcliente = pagarmepy.Customer(id='cus_bjgeDobdLsEO48nw').Get()\n```\n\n### Atualizar\n\n\n```python\n cliente = pagarmepy.Customer(id='cus_bjgeDobsLsEO48nw').Get()\n cliente.address = pagarmepy.Address(line_1='Rua Capitao Domingos Correa da Rocha, 80, Sala 116', line_2='Ed Master Place, Santa Lucia', city='Vit\u00f3ria', state='ES', country='BR', zip_code='29056220')\n client.Update()\n```\n\n### Listar\n\n```python\n clientes = pagarmepy.Customer().List(filters={'page':1, 'size':10, 'gender':'female'})\n```\n**Mais detalhes em [Documenta\u00e7\u00e3o Oficial](https://docs.pagar.me/reference/clientes-1)**\n\n\n## Cart\u00f5es\n\n### Criar\n\n```python\n card = pagarmepy.Card()\n card.first_six_digits = \"400000\"\n card.last_four_digits = \"0010\"\n card.brand = \"Mastercard\"\n card.holder_name = \"Tony Stark\"\n card.holder_document = \"93095135270\"\n card.number = \"4000000000000010\"\n card.exp_month = 1\n card.exp_year = 2030\n card.cvv = 123\n card.billing_address = pagarmepy.Address(**{\n \"zip_code\": \"22000111\",\n \"city\": \"Rio de Janeiro\",\n \"state\": \"RJ\",\n \"country\": \"BR\",\n \"line_1\": \"375, Av. General Osorio, Centro\",\n \"line_2\": \"7\u00ba Andar\"\n })\n card.Create(customer_id='cus_bjgeDobsLsEO48nw')\n\n```\n\n### Obter\n```python\n\tcard = pagarmepy.Card(id=\"card_MJYE2GDSLHjjkawL\").Get(customer_id=\"cus_bjgeDobsLsEO48nw\")\n```\n\n### Atualizar\n\n```python\n card = pagarmepy.Card(id=\"card_MJYE2GDSLHjjkawL\").Get(customer_id=\"cus_bjgeDobsLsEO48nw\")\n card.exp_month = 2\n card.exp_year = 2035\n card.billing_address = pagarmepy.Address(**{'line_1':'Rua Capitao Domingos Correa da Rocha, 80, Sala 116', 'line_2':'Ed Master Place, Santa Lucia', 'city':'Vit\u00f3ria', 'state':'ES', 'country':'BR', 'zip_code':'29056220'})\n card.Update(customer_id=\"cus_bjgeDobsLsEO48nw\")\n print(card.toJSON())\n```\n\n### Listar\n\n```python\n cards = pagarmepy.Card().List(customer_id='cus_bjgeDobsLsEO48nw')\n```\n\n### Excluir\n\n```python\n pagarmepy.Card(id=\"card_MJYE2GDSLHjjkawL\").Delete(customer_id=\"cus_bjgeDobsLsEO48nw\")\n```\n\n### Renovar\n\n```python\n card = pagarmepy.Card(id=\"card_G4QnR6ck7cgBn8XR\").Renew(customer_id=\"cus_bjgeDobsLsEO48nw\")\n```\n\n### Criar Token\n\n```python\n token = pagarmepy.Token()\n token.type = \"card\"\n token.card = pagarmepy.Card(\n first_six_digits = \"400000\",\n last_four_digits = \"0010\",\n brand = \"Mastercard\",\n holder_name = \"Tony Stark\",\n holder_document = \"93095135270\",\n number = \"4000000000000010\",\n exp_month = 1,\n exp_year = 2030,\n cvv = 123,\n billing_address = pagarmepy.Address(**{\n \"zip_code\": \"22000111\",\n \"city\": \"Rio de Janeiro\",\n \"state\": \"RJ\",\n \"country\": \"BR\",\n \"line_1\": \"375, Av. General Osorio, Centro\",\n \"line_2\": \"7\u00ba Andar\"\n })\n )\n\n token.Create(appId='pk_test_Y479412hrHMQ956j')\n```\n\n**Mais detalhes em [Documenta\u00e7\u00e3o Oficial](https://docs.pagar.me/reference/cart%C3%B5es-1)**\n\n## Endere\u00e7os\n\n### Criar\n\n```python\n address = pagarmepy.Address(**{\n \"zip_code\": \"22000111\",\n \"city\": \"Rio de Janeiro\",\n \"state\": \"RJ\",\n \"country\": \"BR\",\n \"line_1\": \"375, Av. General Osorio, Centro\",\n \"line_2\": \"7\u00ba Andar\"\n })\n address.Create(customer_id='cus_bjgeDobsLsEO48nw')\n\n```\n\n### Obter\n```python\n address = pagarmepy.Address(id=\"addr_lOAgNqH1wCxD6eYd\").Get(customer_id=\"cus_bjgeDobsLsEO48nw\")\n```\n\n### Atualizar\n\n```python\n address = pagarmepy.Address(id=\"addr_BNwDJk2TPTmXGArR\").Get(customer_id=\"cus_bjgeDobsLsEO48nw\")\n address.line_2 = 'Master Place, Itarar\u00e9'\n address.Update(customer_id='cus_bjgeDobsLsEO48nw')\n```\n\n### Listar\n\n```python\n addresses = pagarmepy.Address().List(customer_id='cus_bjgeDobsLsEO48nw')\n```\n\n### Excluir\n\n```python\n pagarmepy.Address(id=\"addr_lOAgNqH1wCxD6eYd\").Delete(customer_id=\"cus_bjgeDobsLsEO48nw\")\n```\n\n## BIN\n\nOs seis primeiros d\u00edgitos de um n\u00famero de cart\u00e3o (incluindo o d\u00edgito MII inicial) s\u00e3o conhecidos como o n\u00famero de identifica\u00e7\u00e3o do emissor (IIN) ou n\u00famero de identifica\u00e7\u00e3o do banco (BIN). Estes n\u00fameros identificam a institui\u00e7\u00e3o que emitiu o cart\u00e3o ao titular do cart\u00e3o. O restante do n\u00famero \u00e9 alocado pelo emissor. Para obter as informa\u00e7\u00f5es do Emissor:\n\n### Obter\n\n```python\n bin = pagarmepy.BIN().Get(bin='555566')\n```\n\n## PEDIDOS\n\nVeja a documenta\u00e7\u00e3o oficial para pedidos com pagamentos multimeios, pedidos com multicompradores.\n\n**Mais detalhes em [Documenta\u00e7\u00e3o Oficial](https://docs.pagar.me/reference/pedidos-1)**\n\n\n### Criar\n\nExemplo Pedido com Checkout:\n\n```python\n pedido = pagarmepy.Order()\n pedido.customer_id = \"cus_bjgeDobsLsEO48nw\"\n pedido.code = \"62LVFN7I4R\"\n pedido.amount = 2900\n pedido.currency = \"BRL\"\n pedido.items.add(pagarmepy.Item(**{\n \"id\": \"oi_d478RMAS3bC74PrL\",\n \"description\": \"Chaveiro do Tesseract\",\n \"amount\": 2900,\n \"quantity\": 1,\n \"status\": \"active\",\n \"code\":\"abc\"\n }))\n\n pedido.shipping = pagarmepy.Shipping(**{\n \"amount\": 100,\n \"description\": \"Stark\",\n \"recipient_name\": \"Tony Stark\",\n \"recipient_phone\": \"24586787867\",\n \"address\": {\n \"line_1\": \"10880, Malibu Point, Malibu Central\",\n \"zip_code\": \"90265\",\n \"city\": \"Malibu\",\n \"state\": \"CA\",\n \"country\": \"US\"\n }})\n\n pedido.payments.add(pagarmepy.Payment(**{\n \"amount\" : 3000,\n \"payment_method\":\"checkout\",\n \"checkout\": {\n \"expires_in\":120,\n \"billing_address_editable\" : False,\n \"customer_editable\" : False,\n \"accepted_payment_methods\": [\"credit_card\"],\n \"success_url\": \"https://www.pagar.me\",\n }\n }))\n\n pedido.Create()\n```\n\n### Obter\n```python\n pedido = pagarmepy.Order(id=\"or_jP82N8VUpXhyYr4b\").Get()\n```\n\n### Listar\n\n```python\n pedidos = pagarmepy.Order().List(customer_id='cus_bjgeDobsLsEO48nw')\n```\n\n\n```python\n pedidos = pagarmepy.Order().List()\n```\n\n### Fechar um Pedido\n\n```python\n pedido = pagarmepy.Order(id=\"or_jP82N8VUpXhyYr4b\").Close()\n```\n\n### Excluir\n\n```python\n pagarmepy.Address(id=\"addr_lOAgNqH1wCxD6eYd\").Delete(customer_id=\"cus_bjgeDobsLsEO48nw\")\n```\n\n## COBRAN\u00c7AS\n\n### Obter\n```python\n cobranca = pagarmepy.Charge(id=\"ch_Rz8oL2vcjwc3D1OQ\").Get()\n```\n\n### Capturar Valor Integral\n\n```python\n cobranca = pagarmepy.Charge(id=\"ch_Rz8oL2vcjwc3D1OQ\").Capture()\n```\n\n### Capturar Valor Parcial\n\n```python\n cobranca = pagarmepy.Charge(id=\"ch_Rz8oL2vcjwc3D1OQ\").Capture(amount=10)\n```\n\n### Editar cart\u00e3o de cobran\u00e7a\n\n```python\n cobranca = pagarmepy.Charge(id=\"ch_Pr5R4D5izhEbyNQY\").ChangeCard(pagarmepy.Card(\n first_six_digits = \"400000\",\n last_four_digits = \"0010\",\n brand = \"Mastercard\",\n holder_name = \"Tony Stark\",\n holder_document = \"93095135270\",\n number = \"4000000000000010\",\n exp_month = 1,\n exp_year = 2030,\n cvv = 123,\n billing_address = pagarmepy.Address(**{\n \"zip_code\": \"22000111\",\n \"city\": \"Rio de Janeiro\",\n \"state\": \"RJ\",\n \"country\": \"BR\",\n \"line_1\": \"375, Av. General Osorio, Centro\",\n \"line_2\": \"7\u00ba Andar\"\n })))\n```\n\n### Editar data de vencimento da cobran\u00e7a\n\n```python\n cobranca = pagarmepy.Charge(id=\"ch_Rz8oL2vcjwc3D1OQ\").ChangeDueDate('2022-10-21')\n```\n\n\n### Editar m\u00e9todo de pagamento\n\n```python\n cobranca = pagarmepy.Charge(id=\"ch_Rz8oL2vcjwc3D1OQ\").ChangePaymentMethod(pagarmepy.Payment(**{\n \"amount\" : 3000,\n \"payment_method\":\"boleto\",\n \"boleto\": {\n \"instructions\": \"Instru\u00e7\u00e3o de boleto de teste\",\n \"due_at\" : \"2022-10-20T14:30:22\",\n \"document_number\" : \"123456\",\n \"type\": \"DM\"\n }\n }))\n```\n\n```python\n cobranca = pagarmepy.Charge(id=\"ch_Pr5R4D5izhEbyNQY\").ChangePaymentMethod(pagarmepy.Payment(**{\n \"amount\" : 3000,\n \"payment_method\":\"credit_card\",\n \"credit_card\": {\n 'card_id': \"card_G4QnR6ck7cgBn8XR\",\n }\n }))\n```\n\n### Cancelar Cobran\u00e7a\n\n```python\n cobranca = pagarmepy.Charge(id=\"ch_Rz8oL2vcjwc3D1OQ\").Delete()\n```\n\n### Listar\n\n```python\n cobrancas = pagarmepy.Charge().List()\n```\n\n### Retentar uma cobran\u00e7a manualmente\n\n```python\n cobranca = pagarmepy.Charge(id=\"ch_Rz8oL2vcjwc3D1OQ\").Retry()\n```\n\n\n### Confirmar cobran\u00e7a (cash)\n\n```python\n cobranca = pagarmepy.Charge(id=\"ch_Rz8oL2vcjwc3D1OQ\").Confirm()\n```\n\n# RECORR\u00caNCIA\n\n**Mais detalhes em [Documenta\u00e7\u00e3o Oficial](https://docs.pagar.me/reference/vis%C3%A3o-geral-da-recorr%C3%AAncia)**\n\n## PLANOS\n\n### Criar\n\n```python\nplano = pagarmepy.Plan()\n plano.name = \"Plano Mensal Teste\"\n plano.description = \"Plano de teste de integra\u00e7\u00e3o API\"\n plano.shippable = False\n plano.payment_methods.add('credit_card')\n plano.statement_descriptor = 'Assinatura'\n plano.currency = 'BRL'\n plano.interval = 'month'\n plano.interval_count = 1\n plano.billing_type = 'prepaid'\n plano.quantity = 1\n plano.pricing_scheme = pagarmepy.PricingScheme(**{\n \"scheme_type\": \"unit\",\n \"price\": 5000,\n \"minimum_price\": 5000,\n })\n plano.Create()\n```\n\n### Obter\n\n```python\n plano = pagarmepy.Plan(id=\"plan_ODjw15Af9WUgzwkg\").Get()\n```\n\n### Listar\n\n```python\n plano = pagarmepy.Plan().List()\n```\n\n### Excluir\n\n```python\n pagarmepy.Plan(id=\"plan_ODjw15Af9WUgzwkg\").Delete()\n```\n\n### Atualizar\n\n```python\n plano = pagarmepy.Plan(id=\"plan_ODjw15Af9WUgzwkg\").Get()\n plano.statement_descriptor = \"AST Test\"\n plano.Update()\n```\n\n### Modificar Metadata\n\n```python\nplano = pagarmepy.Plan(id=\"plan_VR92ne8UEUGWNMAa\").ChangeMetadata(\n campo1 = 'valor 1',\n campo2 = 'valor 2',\n camponumero = 3\n )\n```\n\n\n## Items do Plano\n\n### Adicionar Item\n\n```python\n items_planos = pagarmepy.Plan(id=\"plan_brJdw1jTlTa89zyQ\").AddItem(pagarmepy.Item(**{\n \"description\": \"Chaveiro do Alternativo\",\n \"quantity\": 1,\n \"pricing_scheme\": {\n \"price\": 2000,\n \"scheme_type\": \"unit\"\n }\n }))\n```\n\n### Atualizar Item\n\n```python\n items_planos = pagarmepy.Plan(id=\"plan_brJdw1jTlTa89zyQ\").UpdateItem(pagarmepy.Item(**{\n \"id\": \"pi_d478RMAS3bC74PrL\",\n \"description\": \"Chaveiro do Tesseract Antigo\",\n \"status\": \"active\",\n \"quantity\": 1,\n \"pricing_scheme\": {\n \"price\": 3000,\n \"scheme_type\": \"unit\"\n }\n }))\n```\n\n### Excluir Item\n\n```python\n pagarmepy.Plan(id=\"plan_brJdw1jTlTa89zyQ\").DeleteItem(\"pi_d478RMAS3bC74PrL\")\n```\n\n## ASSINATURAS\n\n### Criar Assinatura Avulsa\n\n```python\n assinatura = pagarmepy.Subscription()\n assinatura.code = '1234'\n assinatura.customer_id = \"cus_bjgeDobsLsEO48nw\"\n assinatura.interval = 'month'\n assinatura.interval_count = 1\n assinatura.currency = 'BRL'\n assinatura.payment_method = \"credit_card\"\n assinatura.billing_type = 'prepaid'\n assinatura.installments = 1\n assinatura.statement_descriptor = \"AST Gofans\"\n assinatura.items.add(pagarmepy.Item(**{\n \"id\": \"oi_d478RMAS3bC74PrL\",\n \"description\": \"Chaveiro do Tesseract\",\n \"amount\": 2900,\n \"quantity\": 1,\n \"status\": \"active\",\n \"code\":\"abc\",\n \"pricing_scheme\":{\n \"scheme_type\": \"Unit\",\n \"price\": 2900\n }\n }))\n assinatura.card = pagarmepy.Card(**{\n \"number\": \"4000000000000010\",\n \"holder_name\": \"Tony Stark\",\n \"exp_month\": 1,\n \"exp_year\": 30,\n \"cvv\": \"3531\",\n \"billing_address\": {\n \"line_1\": \"10880, Malibu Point, Malibu Central\",\n \"zip_code\": \"90265\",\n \"city\": \"Malibu\",\n \"state\": \"CA\",\n \"country\": \"US\"\n }\n })\n\n assinatura.Create()\n```\n\n### Criar Assinatura de um Plano\n\n```python\n assinatura = pagarmepy.Subscription()\n assinatura.code = '1234'\n assinatura.customer_id = \"cus_bjgeDobsLsEO48nw\"\n assinatura.plan_id = \"plan_VR92ne8UEUGWNMAa\"\n assinatura.interval = 'month'\n assinatura.interval_count = 1\n assinatura.currency = 'BRL'\n assinatura.payment_method = \"credit_card\"\n assinatura.billing_type = 'prepaid'\n assinatura.installments = 1\n assinatura.statement_descriptor = \"AST Gofans\" \n assinatura.card = pagarmepy.Card(**{\n \"number\": \"4000000000000010\",\n \"holder_name\": \"Tony Stark\",\n \"exp_month\": 1,\n \"exp_year\": 30,\n \"cvv\": \"3531\",\n \"billing_address\": {\n \"line_1\": \"10880, Malibu Point, Malibu Central\",\n \"zip_code\": \"90265\",\n \"city\": \"Malibu\",\n \"state\": \"CA\",\n \"country\": \"US\"\n }\n })\n\n assinatura.Create()\n```\n\n### Obter\n\n```python\n assinaturas = pagarmepy.Subscription(id=\"sub_9ZVy143Hd1HODql1\").Get()\n```\n\n### Listar\n\n```python\n assinaturas = pagarmepy.Subscription().List()\n```\n\n### Cancelar\n\n```python\n assinaturas = pagarmepy.Subscription(id=\"sub_9ZVy143Hd1HODql1\").Delete()\n```\n\n\n### Editar cart\u00e3o da assinatura\n\n```python\n assinatura = pagarmepy.Subscription(id=\"sub_Gdg4m3BTrqTyoK01\").ChangePaymentMethod(pagarmepy.Payment(**{\n \"payment_method\":\"credit_card\",\n 'card_id': \"card_G4QnR6ck7cgBn8XR\",\n }))\n```\n\n### Editar metadados da assinatura\n\n```python\n assinatura = pagarmepy.Subscription(id=\"sub_9ZVy143Hd1HODql1\").ChangeMetadata(\n campo1 = 'valor 1',\n campo2 = 'valor 2',\n camponumero = 3\n )\n```\n\n### Editar meio de pagamento da assinatura\n\n```python\n assinatura = pagarmepy.Subscription(id=\"sub_9ZVy143Hd1HODql1\").ChangePaymentMethod(pagarmepy.Payment(**{\n \"payment_method\":\"boleto\",\n \"boleto\": {\n \"instructions\": \"Instru\u00e7\u00e3o de boleto de teste\",\n \"due_at\" : \"2022-10-20T14:30:22\",\n \"document_number\" : \"123456\",\n \"type\": \"DM\"\n }\n }))\n```\nou\n\n```python\n assinatura = pagarmepy.Subscription(id=\"sub_9ZVy143Hd1HODql1\").ChangePaymentMethod(pagarmepy.Payment(**{\n \"payment_method\":\"credit_card\",\n \"credit_card\": {\n 'card_id': \"card_G4QnR6ck7cgBn8XR\",\n }\n }))\n```\n\n### Editar data de in\u00edcio da assinatura\n\n```python\n assinatura = pagarmepy.Subscription(id=\"sub_9ZVy143Hd1HODql1\").ChangeStarteDate('2022-10-21')\n```\n\n\n### Editar pre\u00e7o m\u00ednimo da assinatura\n\n```python\n assinatura = pagarmepy.Subscription(id=\"sub_9ZVy143Hd1HODql1\").ChangeMinimumPrice(10000)\n```\n\n\n### Ativar faturamento manual\n\n```python\n assinatura = pagarmepy.Subscription(id=\"sub_9ZVy143Hd1HODql1\").SetManualBilling(True)\n```\n\n\n### Desativar faturamento manual\n\n```python\n assinatura = pagarmepy.Subscription(id=\"sub_9ZVy143Hd1HODql1\").SetManualBilling(False)\n```\n\n\n## Items de Assinatura\n\n### Adicionar Item\n\n```python\n items_asssinaturas = pagarmepy.Subscription(id=\"sub_brJdw1jTlTa89zyQ\").AddItem(pagarmepy.Item(**{\n \"description\": \"Chaveiro do Alternativo\",\n \"quantity\": 1,\n \"pricing_scheme\": {\n \"price\": 2000,\n \"scheme_type\": \"unit\"\n }\n }))\n```\n\n### Atualizar Item\n\n```python\n items_asssinaturas = pagarmepy.Subscription(id=\"sub_brJdw1jTlTa89zyQ\").UpdateItem(pagarmepy.Item(**{\n \"id\": \"oi_d478RMAS3bC74PrL\",\n \"description\": \"Chaveiro do Tesseract Antigo\",\n \"status\": \"active\",\n \"quantity\": 1,\n \"pricing_scheme\": {\n \"price\": 3000,\n \"scheme_type\": \"unit\"\n }\n }))\n```\n\n### Listar Items\n\n```python\n items_asssinaturas = pagarmepy.Subscription(id=\"sub_brJdw1jTlTa89zyQ\").ListItems()\n```\n\n### Excluir Item\n\n```python\n pagarmepy.Subscription(id=\"sub_brJdw1jTlTa89zyQ\").DeleteItem(\"oi_d478RMAS3bC74PrL\")\n```\n\n## Uso de Items de Assinatura\n\n### Incluir Uso\n\n```python\n uso = pagarmepy.Usage()\n uso.quantity = 1\n uso.description = \"Uso de teste\"\n uso.Create(subscription_id=\"sub_brJdw1jTlTa89zyQ\", item_id=\"si_Ww2DP2eHzHnolqbn\")\n```\n\n### Remover Uso\n\n```python\n pagarmepy.Usage(id=\"usage_2VBDB53fWfjgnZpX\").Delete(subscription_id=\"sub_1VRDB5AfWfjBnZpx\", item_id=\"si_QjGb0BZUkUD0Eyag\")\n```\n\n### Listar Uso\n\n```python\n usos = pagarmepy.Usage().List(subscription_id=\"sub_1VRDB5AfWfjBnZpx\", item_id=\"si_QjGb0BZUkUD0Eyag\")\n```\n\n\n## Descontos\n\n### Incluir\n\n```python\n desconto = pagarmepy.Discount()\n desconto.uso.value = 100\n desconto.increment_type = 'flat'\n desconto.Create(subscription_id=\"sub_brJdw1jTlTa89zyQ\")\n```\n\n### Obter\n\n```python\n desconto = pagarmepy.Discount(id=\"dis_2VBDB53fWfjgnZpX\").Get(subscription_id=\"sub_brJdw1jTlTa89zyQ\")\n```\n\n### Remover\n\n```python\n pagarmepy.Discount(id=\"dis_2VBDB53fWfjgnZpX\").Delete(subscription_id=\"sub_brJdw1jTlTa89zyQ\")\n```\n\n### Listar\n\n```python\n descontos = pagarmepy.Discount().List(subscription_id=\"sub_brJdw1jTlTa89zyQ\")\n```\n\n\n## Incremento\n\n### Incluir\n\n```python\n incremento = pagarmepy.Increment()\n desconto.uso.value = 100\n desconto.increment_type = 'flat'\n desconto.Create(subscription_id=\"sub_brJdw1jTlTa89zyQ\")\n```\n\n### Obter\n\n```python\n incremento = pagarmepy.Increment(id=\"inc_2VBDB53fWfjgnZpX\").Get(subscription_id=\"sub_brJdw1jTlTa89zyQ\")\n```\n\n### Remover\n\n```python\n pagarmepy.Increment(id=\"inc_2VBDB53fWfjgnZpX\").Delete(subscription_id=\"sub_brJdw1jTlTa89zyQ\")\n```\n\n### Listar\n\n```python\n incrementos = pagarmepy.Increment().List(subscription_id=\"sub_brJdw1jTlTa89zyQ\")\n```\n\n\n## Modificar Regras Split\n\n\n```python\n assinatura = pagarmepy.Subscription()\n assinatura.id = \"sub_brJdw1jTlTa89zyQ\"\n assinatura.split.add(pagarmepy.Split(**{\n \"amount\": 50,\n \"recipient_id\": \"rp_n9voQ2QT0SQrMwOL\",\n \"type\": \"percentage\",\n \"options\": {\n \"charge_processing_fee\": True,\n \"charge_remainder_fee\": True,\n \"liable\": True\n }\n }))\n\n assinatura.split.add(pagarmepy.Split(**{\n \"amount\": 50,\n \"type\": \"percentage\",\n \"recipient_id\": \"rp_6gyn5oIvAcwjrNej\",\n \"options\": {\n \"charge_processing_fee\": False,\n \"charge_remainder_fee\": False,\n \"liable\": False\n }\n }))\n\n assinatura.ChangeSplitRule(enabled=True)\n```\n\n\n\n## Ciclos\n\n### Renovar Ciclo\n\n```python\n ciclo = pagarmepy.Cycle(id=\"cycle_brJdw1jTlTa89zyQ\").Renew()\n```\n\n### Obter\n\n```python\n ciclos = pagarmepy.Cycle(id=\"cycle_VWk4gY6TMPHN7A0g\").Get(subscription_id=\"sub_9ZVy143Hd1HODql1\")\n```\n\n### Listar\n\n```python\n ciclos = pagarmepy.Cycle().List(subscription_id=\"sub_9ZVy143Hd1HODql1\")\n```\n\n## Faturas\n\n### Criar\n\n```python\n fatura = pagarmepy.Invoice().Create(subscription_id='sub_brJdw1jTlTa89zyQ', cycle_id='cycle_v0dxrO3i2iyr5J9X')\n```\n\n### Obter\n\n```python\n fatura = pagarmepy.Invoice(id=\"in_VWk4gY6TMPHN7A0g\").Get()\n```\n\n### Listar\n\n```python\n fatura = pagarmepy.Invoice().List()\n```\n\n### Modificar Metadata\n\n```python\n fatura = pagarmepy.Invoice(id=\"in_VWk4gY6TMPHN7A0g\").ChangeMetadata(\n campo1 = 'valor 1',\n campo2 = 'valor 2',\n camponumero = 3\n )\n```\n\n### Cancelar Fatura\n\n```python\n fatura = pagarmepy.Invoice(id=\"in_VWk4gY6TMPHN7A0g\").Delete()\n```\n\n\n## Recebedores\n\n### Criar\n\n```python\n recebedor = pagarmepy.Recipient()\n recebedor.name = 'Joao da Silva'\n recebedor.email = \"joaodasilva@gmail.com\"\n recebedor.document = '000011233000'\n recebedor.description = 'Recebedor teste de cadastro'\n recebedor.type = 'individual'\n recebedor.default_bank_account = pagarmepy.BankAccount(**{\n \"holder_name\": \"Joao da Silva\",\n \"holder_type\": \"individual\",\n \"holder_document\": '000011233000',\n \"bank\": \"033\",\n \"type\": \"checking\",\n \"branch_number\": \"4444\",\n \"branch_check_digit\": \"0\",\n \"account_number\": \"11223344\",\n \"account_check_digit\": \"5\",\n })\n recebedor.Create()\n print(recebedor.toJSON())\n```\n\n### Obter\n\n```python\n recebedor = pagarmepy.Recipient(id=\"rp_JPx17b8H9HgwY5zo\").Get()\n```\n\n### Atualizar\n\n```python\n recebedor = pagarmepy.Recipient(id=\"rp_WGAn6Q4SySWZBlRy\").Get()\n recebedor.description = \"Descri\u00e7\u00e3o Alterada de Recebedor\"\n recebedor.Update()\n```\n\n### Listar\n\n```python\n recebedores = pagarmepy.Recipient().List()\n```\n\n### Saldo\n\n```python\n saldo = pagarmepy.Recipient(id=\"rp_JPx17b8H9HgwY5zo\").GetBalance()\n```\n\n### Alterar Conta Banc\u00e1ria Padr\u00e3o\n\n```python\n recebedor = pagarmepy.Recipient(id=\"rp_JPx17b8H9HgwY5zo\").ChangeDefaultBankAccount(pagarmepy.BankAccount(**{\n \"holder_name\": \"Roberto Neves da Silva\",\n \"holder_type\": \"individual\",\n \"holder_document\": '09292800752',\n \"bank\": \"033\",\n \"type\": \"checking\",\n \"branch_number\": \"4316\",\n \"branch_check_digit\": \"0\",\n \"account_number\": \"01001647\",\n \"account_check_digit\": \"3\",\n })) \n```\n### Alterar Configura\u00e7\u00f5es de Transfer\u00eancia\n\n```python\n recebedor = pagarmepy.Recipient(id=\"rp_WGAn6Q4SySWZBlRy\").ChangeTransferSettings(transfer_enabled=True, transfer_interval=\"monthly\", transfer_day=\"1\")\n```\n\n### Alterar Configura\u00e7\u00f5es de Antecipa\u00e7\u00e3o de Receb\u00edveis\n\n```python\n pagarmepy.Recipient(id=\"rp_WGAn6Q4SySWZBlRy\").ChangeAnticipationSettings(enabled=True, type=\"full\", volume_percentage=\"100\", days=[\"1\",\"2\"], delay=\"1\")\n```\n\n### Criar Saque\n\n```python\nsaque = pagarmepy.Recipient(id=\"rp_WGAn6Q4SySWZBlRy\").DoWithdraw(100)\n```\n\n### Obter Saque\n\n```python\nsaque = pagarmepy.Recipient(id=\"rp_WGAn6Q4SySWZBlRy\").GetWithdraw(\"with_LR4Wxpqt68ul2W9M\")\n```\n\n### Listar Saques\n\n```python\n saques = pagarmepy.Recipient(id=\"rp_WGAn6Q4SySWZBlRy\").ListWithdrawals()\n```\n\n## Suporte Oficial da Safe2Pay\n\nEm caso de d\u00favidas, problemas ou sugest\u00f5es: [suporte@safe2pay.com.br](mailto:suporte@safe2pay.com.br)\n\n## Change log\n\nVeja em [CHANGELOG](CHANGELOG.md) para maiores informa\u00e7\u00f5es sobre as mudan\u00e7as recentes\n\n## Contribui\u00e7\u00f5es\n\nAs contribui\u00e7\u00f5es por meio de `Pull Requests` s\u00e3o bem-vindas e ser\u00e3o totalmente creditadas.\n\n## Seguran\u00e7a\n\nSe voc\u00ea descobrir qualquer problema relacionado \u00e0 seguran\u00e7a, envie um e-mail para robertonsilva@gmail.com\n\n## Cr\u00e9ditos\n\n- Autor [Roberto Neves](https://github.com/robertons)\n\n## Licen\u00e7a\nVeja em [LICEN\u00c7A](LICENSE) para maiores informa\u00e7\u00f5es sobre a licen\u00e7a de uso.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "SDK Python3 para Integra\u00e7\u00e3o com Safe2Pay",
"version": "0.0.16",
"project_urls": {
"Homepage": "https://github.com/robertons/safe2pay"
},
"split_keywords": [
"safe2pay",
"pagamento",
"cart\u00e3o de cr\u00e9dito",
"boleto",
"pix",
"pagamentos",
"transa\u00e7\u00f5es",
"payment",
"payments",
"credit-card"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ef421ed06bf0fdadefded15c83b3ec25b5494bf9b8553d01cd97329a7f573195",
"md5": "5ed3c767786939d3123f59134b000f03",
"sha256": "c6de22ef860bb911c90c192ad71a6461e26c092818be36993ea6dc1b2a42b603"
},
"downloads": -1,
"filename": "safe2pay-0.0.16.tar.gz",
"has_sig": false,
"md5_digest": "5ed3c767786939d3123f59134b000f03",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 31838,
"upload_time": "2023-10-09T19:57:03",
"upload_time_iso_8601": "2023-10-09T19:57:03.746956Z",
"url": "https://files.pythonhosted.org/packages/ef/42/1ed06bf0fdadefded15c83b3ec25b5494bf9b8553d01cd97329a7f573195/safe2pay-0.0.16.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-09 19:57:03",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "robertons",
"github_project": "safe2pay",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "certifi",
"specs": [
[
"==",
"2020.12.5"
]
]
},
{
"name": "charset-normalizer",
"specs": [
[
"==",
"3.1.0"
]
]
},
{
"name": "idna",
"specs": [
[
"==",
"2.10"
]
]
},
{
"name": "requests",
"specs": [
[
"==",
"2.25.1"
]
]
},
{
"name": "requests-toolbelt",
"specs": [
[
"==",
"0.9.1"
]
]
},
{
"name": "urllib3",
"specs": [
[
"==",
"1.26.4"
]
]
}
],
"lcname": "safe2pay"
}