Wirecard API asyncio wrapper
Project description
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
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
aiowirecard-0.0.8.tar.gz
(3.6 kB
view details)
File details
Details for the file aiowirecard-0.0.8.tar.gz
.
File metadata
- Download URL: aiowirecard-0.0.8.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd94dcb4d23ad80e223a0e1c92cdef9a09c0bf87ea45068f7a438fc73e789b6d |
|
MD5 | 0012f9f5675d088218e58e5d888cdf60 |
|
BLAKE2b-256 | d07fe436e77eb4e979daa5a61f80b2c45c1ee5d2119dcb7466f2c6796dfa83a6 |