Skip to main content

A Python package for wirecard payment gateway

Project description

Pyrecard

Build Status codecov

A Python lib for brazilian Wirecard platform.

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

Recomended setup with pipenv:

$ 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 Plano Especial', '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'}
>>>

More information and json structure check the plan documentation

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]>

More information and json structure check the customer documentation

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 and json structure 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)

set_payment_method allows CREDIT_CARD or BOLETO

>>> 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'}}

More information and json structure check the payments documentation

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.0.tar.gz (9.7 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.0-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyrecard-0.1.0.tar.gz
  • Upload date:
  • Size: 9.7 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.0.tar.gz
Algorithm Hash digest
SHA256 fbfb29c531d1b9f330694ac5845646f0c6ae7a5695be0dda222fb252c681c9e9
MD5 2311e71e64b5cf08d427b9a7616eeced
BLAKE2b-256 206c0ce6782cb5894da5c562f1bd6cd28122c013441ae29dabc068cba4000c55

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyrecard-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.7 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f78cd66761274bb7372ff288fd9d7d1387d8f285e23f2f33083751de4191d4a
MD5 17b6df123a1988798fb13eb8823ca7db
BLAKE2b-256 64396032c1e82df0c0d319e100c6ef0a641955f9af7dd4488b6bde1978699b5d

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