/python-postfinance

Python library for the PostFinance PSP integration.

Primary LanguagePythonMIT LicenseMIT

PostFinance Python Library

Python 3.6 V TravisCI Coverage Status License MIT

The PostFinance Python library provides an API for creating payment forms and payment validation according to PostFinance PSP integration guide.

NOTE: This project is not a officially supported by PostFinance or any affiliated organisation

Installation:

pip install postfinance

Integration

This library can be used with popular frameworks like Flask or Django. For more information please refer to integration guide.

Features

  • Natual currency formatting, i.e. 12.00CHF, 5CHF, 12.99CHF - no decimal conversion headache
  • Payment form signing including order preservation for ITEM*XX* fields and filtering against SHA-IN allowed parameters list
  • Support for incoming transaction data validation SHA-OUT

Example use

>>> from postfinance import PostFinance
>>> from postfinance.constants Environment
>>> client = PostFinance(psp_id="clientDEMO", env=Environment.PROD, sha_password="SuperSecret123?!")
>>> payment = client.payments.create("", "12.99", "CHF")
>>> payment.url
'https://e-payment.postfinance.ch/ncol/prod/orderstandard_utf8.asp'
>>> payment.form_data
{'LANGUAGE': 'en_US',
 'ORDERID': 'order-1',
 'PSPID': 'clientDEMO',
 'AMOUNT': 1299,
 'CURRENCY': 'CHF',
 'SHASIGN': '29ad8a6946bbca5fcb82197f4dff1145d413ec72'}