Skip to main content

aiowirecard

Asyncio wirecard API wrapper based on moip providing asyncronous requests.

Usage

$ export WIRECARD_KEY=<your_wirecard_key>
$ export WIRECARD_TOKEN=<your_wirecard_token>
import asyncio
import json
import os
import random

import aiowirecard


async def main():
    wirecard = aiowirecard.Wirecard(environment='sandbox', key=os.environ['WIRECARD_KEY'],
                                    token=os.environ['WIRECARD_TOKEN'])
    print('Creating customer...')
    customer = {
        "ownId": "%0.11d" % random.randint(0, 99999999999),
        "fullname": "Maria Oliveira",
        "email": "maria@email.com",
        "birthDate": "1980-5-10",
        "taxDocument": {
            "type": "CPF",
            "number": "%0.11d" % random.randint(0, 99999999999)
        },
        "phone": {
            "countryCode": "55",
            "areaCode": "11",
            "number": "22226842"
        },
        "shippingAddress": {
            "city": "Rio de Janeiro",
            "district": "Ipanema",
            "street": "Avenida Atlântica",
            "streetNumber": "60",
            "zipCode": "02446000",
            "state": "RJ",
            "country": "BRA"
        },
        "fundingInstrument": {
            "method": "CREDIT_CARD",
            "creditCard": {
                "expirationMonth": "06",
                "expirationYear": "22",
                "number": "6362970000457013",
                "cvc": "123",
                "holder": {
                    "fullname": "Maria Oliveira",
                    "birthdate": "1980-05-10",
                    "taxDocument": {
                        "type": "CPF",
                        "number": "10013390023"
                    },
                    "billingAddress": {
                        "city": "Rio de Janeiro",
                        "district": "Copacabana",
                        "street": "Rua Raimundo Corrêa",
                        "streetNumber": "1200",
                        "zipCode": "05246200",
                        "state": "RJ",
                        "country": "BRA"
                    },
                    "phone": {
                        "countryCode": "55",
                        "areaCode": "11",
                        "number": "22226842"
                    }
                }
            }
        }
    }
    print('Customer data: ', customer)
    create_user = await wirecard.post_customer(parameters=customer)
    user_id = json.loads(create_user)['id']
    print('Customer id: ', user_id)
    get_user = await wirecard.get_customer(user_id)
    print('Customer info:', get_user)
    order = {
        "ownId": "%0.11d" % random.randint(0, 99999999999),
        "amount": {
            "currency": "BRL",
            "subtotals": {
                "shipping": 1500
            }
        },
        "items": [
            {
                "product": "Descrição do pedido",
                "category": "CLOTHING",
                "quantity": 1,
                "detail": "Camiseta estampada branca",
                "price": 9500
            }
        ],
        "customer": {
            "id": user_id
        }
    }
    new_order = await wirecard.post_order(order)
    print('Creating an order... ')
    order_id = json.loads(new_order)['id']
    print('Order id: ', order_id)
    order = await wirecard.get_order(order_id)
    print('Getting order info: ', order)


loop = asyncio.get_event_loop()
loop.run_until_complete(main())

Functions

post_customer(parameters) # create new customer 
get_customer(parameters) # get customer data
post_creditcard(customer_id, parameters) # add new credit card to customer account
delete_creditcard(creditcard_id) # delete credit card
post_order(parameters) # create a new order
get_order(order_id) # get order by id
post_payment(order_id, parameters) # create a payment
get_payment(payment_id) # get payment data by id
capture_payment(payment_id) # capture of a preauthorized payment
void_payment(payment_id) # cancel the capture of a preauthorized payment
account_exists(account_id) # check if account exists

params examples here

Metadata

Release files for aiowirecard 0.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiowirecard 0.0.8
File Size Uploaded
aiowirecard-0.0.8.tar.gz 3.6 kB Details

Release files / aiowirecard-0.0.8.tar.gz

Download URL aiowirecard-0.0.8.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
cd94dcb4d23ad80e223a0e1c92cdef9a09c0bf87ea45068f7a438fc73e789b6d
BLAKE2b-256 checksum
How to use checksums
d07fe436e77eb4e979daa5a61f80b2c45c1ee5d2119dcb7466f2c6796dfa83a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.4

Release history Release notifications | RSS feed

This release

0.0.8 This release

1 release file

0.0.7

2 release files

0.0.6

2 release files

0.0.5

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page