Git Product home page Git Product logo

python-sdk's Introduction

Build Status

wallee Python SDK

Python SDK to access wallee web services API.

Library facilitates your interaction with various services such as transactions, accounts, and subscriptions.

API documentation

wallee Web Service API

Requirements

  • Python 3.7+

Installation

pip3 install (recommended)

pip3 install --upgrade wallee

pip3 install from source via GitHub

pip3 install git+http://github.com/wallee-payment/python-sdk.git

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

install from source via Setuptools

Install via Setuptools.

pip3 install 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 wallee 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 wallee import Configuration
from wallee.api import TransactionServiceApi, TransactionPaymentPageServiceApi

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 wallee import Configuration
from wallee.api import TransactionServiceApi, TransactionPaymentPageServiceApi
from wallee.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

Integrating Webhook Payload Signing Mechanism into webhook callback handler

The HTTP request which is sent for a state change of an entity now includes an additional field state, which provides information about the update of the monitored entity's state. This enhancement is a result of the implementation of our webhook encryption mechanism.

Payload field state provides direct information about the state update of the entity, making additional API calls to retrieve the entity state redundant.

⚠️ Warning: Generic Pseudocode

The provided pseudocode is intentionally generic and serves to illustrate the process of enhancing your API to leverage webhook payload signing. It is not a complete implementation.

Please ensure that you adapt and extend this code to meet the specific needs of your application, including appropriate security measures and error handling. For a detailed webhook payload signing mechanism understanding we highly recommend referring to our comprehensive Webhook Payload Signing Documentation.

@app.route('/webhook/callback', methods=['POST'])
def handle_webhook():
    request_payload = request.data.decode('utf-8')
    signature = request.headers.get('x-signature')

    if not signature:
        # Make additional API call to retrieve the entity state
        # ...
    else:
        if webhook_encryption_service().is_content_valid(signature_header=signature, content_to_verify=request_payload):
            # Parse request_payload to extract 'state' value
            # Process entity's state change
            # ...

    # Process the received webhook data
    # ...

License

Please see the license file for more information.

python-sdk's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-sdk's Issues

Wallee's python-sdk 4.2.0 not installable on Windows

pip install fails:

Traceback (most recent call last):
          File "<string>", line 2, in <module>
          File "<pip-setuptools-caller>", line 34, in <module>
          File "C:\Users\pierr\AppData\Local\Temp\pip-resolver-oj4jea2g\wallee\setup.py", line 6, in <module>
            long_description = fh.read()
          File "c:\users\pierr\appdata\local\programs\python\python38\lib\encodings\cp1252.py", line 23, in decode
            return codecs.charmap_decode(input,self.errors,decoding_table)[0]
        UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 3960: character maps to <undefined>

The culprit is here:

with open("README.md", "r") as fh:

It could be fixed with:

 with open("README.md", "r",  encoding="utf8") as fh: 

Temporary workaround:

define PYTHONUTF8=1

Error installing Walle Python SDK under Divio

Can you help me with ?
root@c806add2de40:/app# pip install --upgrade wallee
Looking in indexes: https://wheels.aldryn.net/v1/aldryn-extras+pypi/aldryn-baseproject-v4-py36/+simple/
Collecting wallee
Using cached https://wheels-cdn.aldryn.net/pypi/aldryn-baseproject-v4-py36/wallee/2.0.0/1571062149/51453e6658c002daebf54eb4d5ff7874/wallee-2.0.0-py3-none-any.whl
Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in /usr/local/lib/python3.6/site-packages (from wallee) (2019.6.16)
Requirement already satisfied, skipping upgrade: urllib3>=1.23 in /usr/local/lib/python3.6/site-packages (from wallee) (1.25.3)
Requirement already satisfied, skipping upgrade: python-dateutil>=2.1 in /usr/local/lib/python3.6/site-packages (from wallee) (2.8.0)
Requirement already satisfied, skipping upgrade: six>=1.10 in /usr/local/lib/python3.6/site-packages (from wallee) (1.12.0)
Collecting enum34>=1.1.6
Using cached https://wheels.aldryn.net/v1/pypi/aldryn-baseproject-v4-py36/%2Bsimple/enum34/1.1.6/download/89931/enum34-1.1.6.tar.gz
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_xen8sum/enum34/setup.py'"'"'; file='"'"'/tmp/pip-install-_xen8sum/enum34/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-_xen8sum/enum34/pip-egg-info
cwd: /tmp/pip-install-_xen8sum/enum34/
Complete output (11 lines):
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.6/site-packages/setuptools/init.py", line 6, in
import distutils.core
File "/usr/local/lib/python3.6/distutils/core.py", line 16, in
from distutils.dist import Distribution
File "/usr/local/lib/python3.6/distutils/dist.py", line 9, in
import re
File "/usr/local/lib/python3.6/re.py", line 142, in
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
root@c806add2de40:/app# python -V
Python 3.6.8
root@c806add2de40:/app#

AttributeError: TAX_NOT_INCLUDED

Could you please add TAX_ to wallee/models/tax_calculation.py

class TaxCalculation(Enum):
    
    INCLUDED = "TAX_INCLUDED"
    TAX_NOT_INCLUDED = "TAX_NOT_INCLUDED"

thank yoU)

Documentation lack!!!

Hello, I see, you created a big wonderful project, but I cannot find any examples or descriptions about how it should be properly integrate. I have written to your support, but nothing! I would be lovely to help you with that, but please give me a response, How I can integrate. You have a lot of ifs and strategies but no one good described example.

Thank you)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.