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.
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.
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.
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
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
response_data_dict = client.refund(rec_trade_id, refund_amount)
Docs: https://docs.tappaysdk.com/tutorial/zh/back.html#refund-api
response_data_dict = client.cancel_refund(rec_trade_id)
Docs: https://docs.tappaysdk.com/tutorial/zh/advanced.html#refund-cancel-api
response_data_dict = client.get_records({
"bank_transaction_id": bank_transaction_id
})
Docs: https://docs.tappaysdk.com/tutorial/zh/back.html#record-api
response_data_dict = client.capture_today(rec_trade_id)
Docs: https://docs.tappaysdk.com/tutorial/zh/advanced.html#cap-today-api
response_data_dict = client.cancel_capture(rec_trade_id)
Docs: https://docs.tappaysdk.com/tutorial/zh/advanced.html#cap-cancel-api
response_data_dict = client.get_trade_history(rec_trade_id)
Docs: https://docs.tappaysdk.com/tutorial/zh/advanced.html#trade-history-api
response_data_dict = client.bind_card(prime, card_holder_data)
Docs: https://docs.tappaysdk.com/tutorial/zh/advanced.html#bind-card-api
response_data_dict = client.remove_card(card_key, card_token
Docs: https://docs.tappaysdk.com/tutorial/zh/advanced.html#remove-card-api
This library is released under the MIT License.