Skip to main content

SDK that allows you to access PostFinance Checkout

Project description

Build Status

PostFinance Checkout Python Library

The PostFinance Checkout Python library wraps around the PostFinance Checkout API. This library facilitates your interaction with various services such as transactions, accounts, and subscriptions.

Documentation

PostFinance Checkout Web Service API

Requirements

  • Python 3.5+

Installation

pip install (recommended)

pip install --upgrade postfinancecheckout

pip install from source via github

pip install git+http://github.com/pfpayments/python-sdk.git

(you may need to run pip with root permission: sudo pip install git+http://github.com/pfpayments/python-sdk.git )

install from source via Setuptools

Install via Setuptools.

python setup.py install

(or sudo python setup.py install to install the package for all users)

Usage

The library needs to be configured with your account's space id, user id, and secret key which are available in your PostFinance Checkout account dashboard. Set space_id, user_id, and api_secret to their values. You can also optionally set default_headers to set some headers that will be sent to all requests

Configuring a Service

from postfinancecheckout import Configuration
from postfinancecheckout.api import TransactionServiceApi, TransactionPaymentPageServiceApi
from postfinancecheckout.models import LineItem, LineItemType, TransactionCreate

space_id = 405

# default_headers is an optional param, that represents headers sent to all requests
config = Configuration(
    user_id=512,
    api_secret='FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=',
    default_headers={'x-meta-custom-header': 'value-1', 'x-meta-custom-header-2': 'value-2'},
    # set a custom request timeout if needed. (If not set, then the default value is: 25 seconds)
    request_timeout = 30
)

transaction_service = TransactionServiceApi(configuration=config)
transaction_payment_page_service = TransactionPaymentPageServiceApi(configuration=config)

To get started with sending transactions, please review the example below:

from postfinancecheckout import Configuration
from postfinancecheckout.api import TransactionServiceApi, TransactionPaymentPageServiceApi
from postfinancecheckout.models import LineItem, LineItemType, TransactionCreate

space_id = 405

config = Configuration(
    user_id=512,
    api_secret='FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=',
    # set a custom request timeout if needed. (If not set, then the default value is: 25 seconds)
    request_timeout = 30
)

transaction_service = TransactionServiceApi(configuration=config)
transaction_payment_page_service = TransactionPaymentPageServiceApi(configuration=config)

# create line item
line_item = LineItem(
    name='Red T-Shirt',
    unique_id='5412',
    sku='red-t-shirt-123',
    quantity=1,
    amount_including_tax=29.95,
    type=LineItemType.PRODUCT
)

# create transaction model
transaction = TransactionCreate(
    line_items=[line_item],
    auto_confirmation_enabled=True,
    currency='EUR',
)

transaction_create = transaction_service.create(space_id=space_id, transaction=transaction)
payment_page_url = transaction_payment_page_service.payment_page_url(space_id=space_id, id=transaction_create.id)
# redirect your customer to this payment_page_url

License

Please see the license file for more information.

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

postfinancecheckout-3.3.0.tar.gz (242.7 kB view details)

Uploaded Source

File details

Details for the file postfinancecheckout-3.3.0.tar.gz.

File metadata

  • Download URL: postfinancecheckout-3.3.0.tar.gz
  • Upload date:
  • Size: 242.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for postfinancecheckout-3.3.0.tar.gz
Algorithm Hash digest
SHA256 627c543fb4f4007574d411c05e833d0af0f3390be0d70726e1d714f284c2712e
MD5 79ae11ca7deefc32f82161b6642c0195
BLAKE2b-256 23262ff492f77f0232cfd17ad82bf4f0c123935a9f66ec37f199d72e6866dac7

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