Skip to content

shihweilo/tappay-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TapPay Client Library for Python

Code style: black

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

Installation

To install the Python client library using pip:

pip install tappay

To upgrade your installed client library using pip:

pip install tappay --upgrade

Alternatively, you can clone the repository via the command line:

git clone git@github.com:shihweilo/tappay-python.git

or by opening it on GitHub desktop.

Usage

Begin by importing the tappay module:

import tappay

Then construct a client object with your partner_key and merchant_id:

client = tappay.Client(is_sandbox, partner_key, merchant_id)

For production, you can specify the TAPPAY_PARTNER_KEY and TAPPAY_MERCHANT_ID environment variables instead of specifying the key and secret explicitly.

You will have to provide a boolean flag is_sandbox as first parameter to indicate if using sandbox(test) environment.

Backend API

Make a payment by prime token

card_holder_data = tappay.Models.CardHolderData(phone, name, email)
response_data_dict = client.pay_by_prime(prime_token, amount, payment_details, card_holder_data)

Docs: https://docs.tappaysdk.com/tutorial/zh/back.html#pay-by-prime-api

Make a payment by card token

response_data_dict = client.pay_by_token(card_key, card_token, amount, payment_details)

Docs: https://docs.tappaysdk.com/tutorial/zh/back.html#pay-by-card-token-api

Refund

response_data_dict = client.refund(rec_trade_id, refund_amount)

Docs: https://docs.tappaysdk.com/tutorial/zh/back.html#refund-api

Cancel Refund

response_data_dict = client.cancel_refund(rec_trade_id)

Docs: https://docs.tappaysdk.com/tutorial/zh/advanced.html#refund-cancel-api

Get payment record

response_data_dict = client.get_records({
    "bank_transaction_id": bank_transaction_id
})

Docs: https://docs.tappaysdk.com/tutorial/zh/back.html#record-api

Capture payment

response_data_dict = client.capture_today(rec_trade_id)

Docs: https://docs.tappaysdk.com/tutorial/zh/advanced.html#cap-today-api

Cancel Capture

response_data_dict = client.cancel_capture(rec_trade_id)

Docs: https://docs.tappaysdk.com/tutorial/zh/advanced.html#cap-cancel-api

Get transaction record

response_data_dict = client.get_trade_history(rec_trade_id)

Docs: https://docs.tappaysdk.com/tutorial/zh/advanced.html#trade-history-api

Bind card

response_data_dict = client.bind_card(prime, card_holder_data)

Docs: https://docs.tappaysdk.com/tutorial/zh/advanced.html#bind-card-api

Remove card

response_data_dict = client.remove_card(card_key, card_token

Docs: https://docs.tappaysdk.com/tutorial/zh/advanced.html#remove-card-api

License

This library is released under the MIT License.

Releases

No releases published

Packages

No packages published

Languages