Skip to main content

A Python lib for brazilian Wirecard payment gateway.

Project description

Pyrecard

pipy pyver Build Status codecov

A Python lib for brazilian Wirecard payment gateway.

Wirecard works with a base64 hash made up of its TOKEN:KEY in its operations. Pyrecard uses two environment variables with these sets SANDBOX_KEY and PRODUCTION_KEY and generates the necessary hash for an operation. This lib works in SANDBOX by default, to use PRODUCTION mode set environment variable PYRECARD_ENV=production

Currently working with subscriptions operations above.

  • Plans
  • Customers
  • Subscriptions
  • Invoices
  • Payments
  • Coupon [WIP]
  • Payment retry

Table of Contents

  1. Installation
  2. Usage
  3. Used by

Installation

Minimal setup:

$ pip install pyrecard
$ export SANDBOX_KEY=TOKEN:KEY
$ export PRODUCTION_KEY=TOKEN:KEY

Setup with pipenv (recomended):

$ pipenv install pyrecard

Create a .env file with required data:

SANDBOX_KEY=TOKEN:KEY
PRODUCTION_KEY=TOKEN:KEY

Usage

subscriptions.plan

The plan module performs the following operations:

  • plan.create(json)
  • plan.alter(plan_code, json)
  • plan.activate(plan_code)
  • plan.inactivate(plan_code)
  • plan.fetch(plan_code)
  • plan.fetch_all()

All operations above returns a response.

>>> from pyrecard.subscription import plan
>>> response = plan.fetch("plan101")
>>> response
<Response [200]>
>>> response.json()
{'setup_fee': 500, 'amount': 990, 'code': 'plan101', 'name': 'Plano Especial', 'billing_cycles': 12, 'description': 'Descrição do PlanoEspecial', 'interval': {'unit': 'MONTH', 'length': 1}, 'creation_date': {'month': 1, 'hour': 0, 'year': 2016, 'day': 8, 'minute': 0, 'second':0}, 'payment_method': 'CREDIT_CARD', 'max_qty': 1, 'trial': {'hold_setup_fee': True, 'days': 30, 'enabled': True}, 'status': 'ACTIVE'}
>>>

subscriptions.customer

The customer module performs the following operations:

  • customer.create(json, new_vault=False)
  • customer.alter(code, json)
  • customer.fetch(code)
  • customer.fetch_all()
  • customer.change_card(code, json)

Set new_vault True to create a user with billing data.

>>> from pyrecard.subscription import customer
>>> customer_data = customer.fetch('cliente01').json()
>>> customer_data['address']['state'] = 'MG'
>>> response = customer.alter('cliente01', customer_data)
>>> response
<Response [200]>

subscription.subscription

The subscription module performs the following operations:

  • subscription.create(json, new_customer=False)
  • subscription.alter(code, json)
  • subscription.fetch(code)
  • subscription.fetch_all()
  • subscription.set_status(code, status)
  • subscription.set_payment_method(code, method)
  • subscription.fetch_all_invoices(code)

Set new_customer True to create a subscription with a new user.

set_status allows suspend, activate or cancel

set_payment_method allows CREDIT_CARD or BOLETO

>>> from pyrecard.subscription import subscription
>>> response = subscription.set_status('assinatura01',  'suspend')
>>> response
<Response [200]>

More information check the subscription documentation

subscription.payment

The payment module performs the following operations:

  • payment.fetch_invoice(code)
  • payment.fetch_invoice_payments(code)
  • payment.payment_details(code)
  • payment.fetch_all_invoices(code)
  • payment.retry_invoice_payment(code)
  • payment.generate_bank_slip(code, json)
>>> from pyrecard.subscription import payment
>>> response = payment.fetch_invoice('1025240')
>>> response
<Response [200]>
>>> response.json()
{'subscription_code': 'assinatura01', 'amount': 0, 'id': 1025240, 'creation_date': {'month': 1, 'hour': 14, 'year': 2016, 'day': 8, 'minute':28, 'second': 52}, 'occurrence': 1, 'plan': {'code': 'plan101', 'name': 'Plano Especial'}, 'items': [{'amount': 0, 'type': 'Período de trial'}, 'customer': {'code': 'cliente03', 'fullname': 'Nome Sobrenome', 'email': 'nome@exemplo.com.br'}, 'status': {'code': 3, 'description': 'Pago'}

For additional information, check Wirecard docs.

Used by:

Markdown Monster icon

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

pyrecard-0.1.2.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyrecard-0.1.2-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file pyrecard-0.1.2.tar.gz.

File metadata

  • Download URL: pyrecard-0.1.2.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2

File hashes

Hashes for pyrecard-0.1.2.tar.gz
Algorithm Hash digest
SHA256 932e7df4923e4841dabb45970c3e00c574ccf1b1d604a3bd4bb112497b923bd3
MD5 a7415a78e48a38dcabb37644ad2f9234
BLAKE2b-256 63c8b195bb36157922ee5348dde77d6c17d1594022c2c1f5d3285f5e0424460e

See more details on using hashes here.

File details

Details for the file pyrecard-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pyrecard-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2

File hashes

Hashes for pyrecard-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 acc235403827da9d4b906d3cc58cc07d677bf9d0b05d1e0ea33da6e6d2025b7e
MD5 59eedeb5100f2073abd08af2e45c42e7
BLAKE2b-256 d9d0ab0a7157b17a9455ae88c18e72c21a610208387e5733f7f361505cdbdd5d

See more details on using hashes here.

Supported by

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