Skip to main content

Wirecard API v2 Wrapper

Project description

Wirecard API v2 Wrapper - Python3

Integração com a API v2 de pagamentos e notificações da Wirecard utilizando requests.

Consulte a documentação oficial e as referências API v2 Wirecard

Instalação

Instalação utilizando Pip

pip install py3wirecard

Git/Clone

git clone https://github.com/robertons/py3wirecard
cd py3wirecard
pip install -r requirements.txt
python setup.py install

Configuração

from py3wirecard import *

WireCard("API TOKEN", "API KEY",sandbox=True)

Cliente

Cadastro

cliente = Customer()
cliente.ownId = "1201"
cliente.fullname = "Fulando da Silva"
cliente.email = "fulano@email.com"
cliente.birthDate = datetime(1980,1,1)
cliente.taxDocument = TaxDocument(type="CPF", number = "000000000")
cliente.shippingAddress = Address(street= "Nome da Rua", streetNumber="01", complement="SN", district="Bairro", city="Cidade", state="UF", zipCode=00000000, country="BRA")
cliente.phone = Phone(countryCode=55, areaCode=11, number=999999999)
cliente.create()

Consulta

cliente = Customer().get("CUS-PCVTIJ37EWBZ")

Lista

clientes = Customer().list()

Atualização

Para atualizar um cliente basta criar um novo pedido com os dados do cliente existente informando seu id ou ownId.

Pedido

Cadastro

compra = Order()
compra.ownId = "1234"
compra.amount = Amount()
compra.items.append(Product(product="Nome Produto", detail="Descrição Produto", quantity=1, price=23999))
compra.customer = Customer()
compra.customer.ownId = "1201"
compra.customer.fullname = "Fulando da Silva"
compra.customer.email = "fulano@email.com"
compra.customer.birthDate = datetime(1980,1,1)
compra.customer.taxDocument = TaxDocument(type="CPF", number = "000000000")
compra.customer.shippingAddress = Address(street= "Nome da Rua", streetNumber="01", complement="SN", district="Bairro", city="Cidade", state="UF", zipCode=00000000, country="BRA")
compra.customer.phone = Phone(countryCode=55, areaCode=11, number=999999999)
compra.shippingAddress = Address(street= "Nome da Rua", streetNumber="01", complement="SN", district="Bairro", city="Cidade", state="UF", zipCode=00000000, country="BRA")
compra.receivers.append(Receiver(type = 'SECONDARY', feePayor = False, moipAccount = MoipAccount(id='IDCONTA'), amount = Amount(fixed = 10000)))
compra.create()

Consulta

compra = Order().get("ORD-01KHBJSQ9QB0")

Pagamento

pagamento = Payment()
pagamento.fundingInstrument = FundingInstrument(method = "CREDIT_CARD")

Cartão de Crédito (hash)

pagamento.fundingInstrument.creditCard = CreditCard(hash = "HASH...", holder = Holder(fullname = "Fulando da Silva", TaxDocument(type="CPF", number = "000000000"), phone =  Phone(countryCode=55, areaCode=11, number=999999999), birthdate =  datetime(1980,1,1)))

Cartão de Crédito (dados) (Necessário certificação PCI)

pagamento.fundingInstrument.creditCard = CreditCard(number="5555666677778884", expirationMonth="06", expirationYear="2022", cvc="123", holder = Holder(fullname = "Fulando da Silva", TaxDocument(type="CPF", number = "000000000"), phone =  Phone(countryCode=55, areaCode=11, number=999999999), birthdate =  datetime(1980,1,1)))

Envio do Pagamento

pagamento.create(order_id="ORD-01F0UADQ9QB0")

Consulta

pagamento = Payment().get("PAY-1A24BB9K8DX4")

Reembolso

Completo de Pagamento

reembolso = Refund().create("PAY-1W24IB9J0DX4")

Parcial de Pagamento

reembolso = Refund().create("PAY-U67EYCMPR8C4", amount=1000)

Completo de Compra

reembolso = Refund().create("ORD-01F8CQ9QB0")

Parcial de Compra

reembolso = Refund().create("ORD-01F8CQ9QB0", amount=1000)

Consulta

reembolso = Refund().get("REF-VRK1K0N6GOXA")

Notificações

Cadastro de Preferências de Notificações

notificacoes.events = [
            "ORDER.*",
            "PAYMENT.AUTHORIZED",
            "PAYMENT.CANCELLED"
            ]
notificacoes.target = "https://myapi.com/notifications"
notificacoes.media = "WEBHOOK"
notificacoes.create()

Consulta

notificacao = Notification().get("NPR-S1VEAS06KBAXA")

Lista Preferências de Notificações

notificacoes = Notification().list()

Excluir Preferências de Notificações

Notification().delete("NPR-U18BA1ME2MTB")

Webhooks

Consultar Webhooks enviados com Código Identificador do Evento

webhooks = WebHooks().get("ORD-01F0UJSQ9QB0")

Consultar Todos Webhooks enviados

webhooks = WebHooks().get()

Reenviar Webhook

webhook = WebHooks().resend(resource_id="PAY-U67EYHGCR8C4", event="PAYMENT.AUTHORIZED")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py3wirecard-0.0.4.tar.gz (14.3 kB view details)

Uploaded Source

File details

Details for the file py3wirecard-0.0.4.tar.gz.

File metadata

  • Download URL: py3wirecard-0.0.4.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for py3wirecard-0.0.4.tar.gz
Algorithm Hash digest
SHA256 095da0745c633850f5541272b8eab624d6ed4569bf8dc40e80bdf405dfd79458
MD5 b766129fe8865d4a59f8b7cff71e3e17
BLAKE2b-256 c31afc78d8cedca86016314f9115ac539a4a60f2101ca7595a4f5cfb401985ab

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page