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 only.

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(customer_code, json)
  • customer.fetch(customer_code)
  • customer.fetch_all()
  • customer.change_card(customer_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(subscription_code, json)
  • subscription.fetch(subscription_code)
  • subscription.fetch_all()
  • subscription.set_status(subscription_code, status)
  • subscription.set_payment_method(subscription_code, method)
  • subscription.fetch_all_invoices(subscription_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(invoice_id)
  • payment.fetch_invoice_payments(invoice_code)
  • payment.payment_details(payment_code)
  • payment.retry_invoice_payment(invoice_code)
  • payment.generate_bank_slip(invoice_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'}

subscription.coupon

The coupon module performs the following operations:

  • coupon.create(json)
  • coupon.apply(subscription_code, coupon_code)
  • coupon.fetch(coupon_code)
  • coupon.fetch_all()
  • coupon.set_status(coupon_code, status)
  • coupon.remove(coupon_code)
>>> from pyrecard.subscription import coupon
>>> response = coupon.set_status('coupon-0001', 'active')
>>> response
<Response [400]>
>>> response.json()
{'errors': [{'code': 'MA174', 'description': 'Coupon expirado.'}]}

More information check the coupon 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-1.0.0.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

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

pyrecard-1.0.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyrecard-1.0.0.tar.gz
  • Upload date:
  • Size: 11.0 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-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1ba3241bc0280d5b97847582709c358bc475a8feb35a75468deb7afb1c1c297b
MD5 b90eb108cd0a00e19ce8d5afac60c79f
BLAKE2b-256 50123dbae2a83469003effc214fdb36dd07f3cf4aa6522625ee45830efab7d03

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyrecard-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.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-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f05d406bb1ef9a8ce017fdbcfc73ce0e2574455f9bb776859362c7fed276c156
MD5 fefa2c49a5567168bf462f4c1fd756d2
BLAKE2b-256 0c07e8740304496cb7fcd3d5e5d095a229be198d0b1d0f471363406a98735240

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