Skip to main content

TapPay Client Library for Python

Project description

TapPay Python SDK

CI PyPI version Python Versions Code style: black License: MIT

[!IMPORTANT] Python 2 Support Dropped: As of version 0.5.0, this library no longer supports Python 2.7. Please use Python 3.8 or newer.

This is the unofficial Python client library for TapPay's Backend API. To use it you'll need a TapPay account. Sign up at tappaysdk.com.

Installation

Install using pip:

pip install tappay

Usage

Initialization

import tappay

# Initialize the client
client = tappay.Client(
    is_sandbox=True, 
    partner_key="YOUR_PARTNER_KEY", 
    merchant_id="YOUR_MERCHANT_ID"
)

For production, you can set TAPPAY_PARTNER_KEY and TAPPAY_MERCHANT_ID environment variables and omit them in the constructor:

client = tappay.Client(is_sandbox=False)

Pay by Prime

# Create cardholder data
card_holder = tappay.Models.CardHolderData(
    phone_number="0912345678",
    name="Wang Xiao Ming",
    email="test@example.com"
)

# Make payment
response = client.pay_by_prime(
    prime="prime_token_from_frontend",
    amount=100,
    details="Order #123",
    card_holder_data=card_holder
)
print(response)

Pay by Token

response = client.pay_by_token(
    card_key="card_key",
    card_token="card_token",
    amount=100,
    details="Subscription"
)

Refunds

response = client.refund(
    rec_trade_id="rec_trade_id",
    amount=100
)

For more API details, please refer to the TapPay Backend API Documentation.

Development

Setup

git clone https://github.com/shihweilo/tappay-python.git
cd tappay-python
pip install -e ".[dev]"

Testing

Run tests using pytest:

pytest

Contributing

Please see CONTRIBUTING.md for details.

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

tappay-0.5.2.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

tappay-0.5.2-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file tappay-0.5.2.tar.gz.

File metadata

  • Download URL: tappay-0.5.2.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for tappay-0.5.2.tar.gz
Algorithm Hash digest
SHA256 67fa5d2ce0f85fc796fa51fa1145a493c47ff2962734a700018c41708da6cd92
MD5 318f9c369155c78cf2cbe7acc0b657aa
BLAKE2b-256 b174e3a31f8ef6ac157b3e8214321bace09e16531cc08216fdf153928d2e8bd8

See more details on using hashes here.

File details

Details for the file tappay-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: tappay-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for tappay-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 82cf2ff96257ee23fc781df3d31fdc6ad3d15a5892e448239cc155ee763bcf6e
MD5 7f9609a0b7b7418e7d6990238411d9f8
BLAKE2b-256 1cdbdd0de54e8b6ddde8c1860af5ac54ac5778ad84819e8ea2cb2100fcb44716

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