Skip to main content

WayForPay API python implementation

version 0.0.1

Installation

    pip install wayforpay-python

or add wayforpay-python to requirements.txt

Project structure

wayforpaymodule.py

Made requests to WFP API

payments.py

Create objects for payment API section

invoice.py

Create objects for invoice API section

USAGE

Available methods sections

  • Payment methods
    • Payment form ( html )
    • Payment widget ( html )
    • Payment widget ( json obj )
  • Invoices
    • Create invoice
    • Edit invoice
    • Pause invoice
    • Resume invoice
    • Remove invoice

You can create objects to made requests by yourself or lett lib make requests and return json response object

Examples

Status invoice object

    from invoice import statusInvoiceObject
    account_data = {
        'merchant_account': 'XXXXXXXXXXXXXXXXXXXXXX',
        'merchant_password': 'XXXXXXXXXXXXXXXXXXXXXX',
    }
    order_reference = 'XXXXXXXXXXXXXXXXXXXXXXXXXX'
    print(statusInvoiceObject(
        accound_data,
        order_reference
    ))
    """
        {
            "requestType": "STATUS",
            "merchantAccount": 'XXXXXXXXXXXXXXXXXXXXXX',
            "merchantPassword": 'XXXXXXXXXXXXXXXXXXXXXX',
            "orderReference": 'XXXXXXXXXXXXXXXXXXXXXX',
        }
    """

Create widget json object

    from wayforpay import WayForPayAPI
    import calendar
    import time
    ts = calendar.timegm(time.gmtime())
    wp = WayForPayAPI(
            'XXXXXXXXXXXXX',
            'XXXXXXXXXXXXX',
            'XXXXXXXXXXXXX',
            'XXXXXXXXXXXXX'
    )
    names = ['value', 'value2']
    cost = ['1', '2']
    amount = ['1', '1']
    data = {
        'orderReference': ts,
        'orderDate': ts,
        'amount': '3',
        'currency': 'UAH',
        'productName': names,
        'productPrice': cost,
        'serviceUrl': 'http://127.0.0.1:8000/finish-order/',
        'returnUrl': 'http://127.0.0.1:8000/finish-order/',
        'productCount': amount,
        'straightWidget': True
    }
    print(wp.generateWidgetJson(data))
    """
        {
            'merchantAccount': 'XXXXXXXXXXXXX',
            'merchantDomainName': 'XXXXXXXXXXXXX',
            'merchantTransactionType': 'AUTO',
            'merchantTransactionSecureType': 'AUTO',
            'orderReference': '1234243234324',
            'orderDate': '1234243234324',
            'amount': '3',
            'authorizationType': 'SimpleSignature',
            'currency': 'USD',
            'productName':   ['value', 'value2'],
            'productPrice':  ['1', '2'],
            'productCount':  ['1', '1'],
            'merchantSignature': signature,
            'language': 'EN',
            'straightWidget': True
        }
    """

Create widget html script

    from wayforpay import WayForPayAPI
    import calendar
    import time
    ts = calendar.timegm(time.gmtime())
    wp = WayForPayAPI(
            'XXXXXXXXXXXXX',
            'XXXXXXXXXXXXX',
            'XXXXXXXXXXXXX',
            'XXXXXXXXXXXXX'
    )
    names = ['value', 'value2']
    cost = ['1', '2']
    amount = ['1', '1']
    data = {
        'orderReference': ts,
        'orderDate': ts,
        'amount': '3',
        'currency': 'UAH',
        'productName': names,
        'productPrice': cost,
        'serviceUrl': 'http://127.0.0.1:8000/finish-order/',
        'returnUrl': 'http://127.0.0.1:8000/finish-order/',
        'productCount': amount,
        'straightWidget': True
    }
    widget = wp.generateWidget(data)
    print(widget)
    """

        <script type="text/javascript">
        function pay(){
            var payment = new Wayforpay();
                payment.run({
                    'merchantAccount': 'XXXXXXXXXXXXX',
                    'merchantDomainName': 'XXXXXXXXXXXXX',
                    'merchantTransactionType': 'AUTO',
                    'merchantTransactionSecureType': 'AUTO',
                    'orderReference': '1234243234324',
                    'orderDate': '1234243234324',
                    'amount': '3',
                    'authorizationType': 'SimpleSignature',
                    'currency': 'USD',
                    'productName':   ['value', 'value2'],
                    'productPrice':  ['1', '2'],
                    'productCount':  ['1', '1'],
                    'merchantSignature': signature,
                    'language': 'EN',
                    'straightWidget': True
                }
            );
        }
        window.addEventListener("message", function () {
            if (event.data == 'WfpWidgetEventClose') {
                location.reload()
            }
        }, false);
        </script>
    """

Jinja

<button onclick="pay()"><span style="color:white">Оплата</span></button>
<script id='widget-wfp-script' language='javascript' type='text/javascript' src='https://secure.wayforpay.com/server/pay-widget.js'></script>
{{ widget|safe }}

Metadata

Release files for wayforpay-python 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wayforpay-python 1.0.1
File Size Uploaded Provenance
wayforpay-python-1.0.1.tar.gz 5.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for wayforpay-python 1.0.1
File Interpreter ABI Platform
wayforpay_python-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 11.7 kB

Release files / wayforpay-python-1.0.1.tar.gz

Download URL wayforpay-python-1.0.1.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
bc356a3c4708c4ecc2f309afbf17f6dce80a616c128a5fcc1552fd868cb79f8f
BLAKE2b-256 checksum
How to use checksums
6104c1871f149a373d108605bb05a8c800af47998575a7a874b76135f34d6c23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.5.0.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

Release files / wayforpay_python-1.0.1-py3-none-any.whl

Download URL wayforpay_python-1.0.1-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
be33b2167773fa147afc92881236a24365504ff29b62824562b8012187774793
BLAKE2b-256 checksum
How to use checksums
21b3310aab787b0c86559c7071c84b566f9d2ce0919337bf447b673261270be0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.5.0.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

Security for wayforpay-python 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page