Skip to main content

PC4Store

SDK for work with PC4Store API

Installation

pip install pc4store requires Python 3.6 or higher

Examples

Sync client

Initialize client
from pc4store.clients import Pc4StoreClient

my_store_id = 'unique identifier of your store'
my_store_secret_key = 'secret'

client = Pc4StoreClient(store_id=my_store_id, store_key=my_store_secret_key)
Create order
from pc4store.data import CreateOrderInput, OrderData

res = client.create_order(
    CreateOrderInput(
        currency_name='USDCASH',
        currency_smart_contract='token.pcash',
        amount_to_pay='99.99999',
        response_url='https://api.my-store/payment-callback/',
        expiration_time=30 * 60,  # 30 min
        merchant_order_id='12345',
        description='optional description for this order',
        success_payment_redirect_url='https://my-store/orders/12345/success',
        failed_payment_redirect_url='https://my-store/orders/12345/failed',
    )
)

if res.status == 'OK':
    order: OrderData = res.payload.order  # all data about order
    payment_link = order.payment_url  # link to redirect user for payment
    order_id = order.id  # unique order id in payment system
else:
    print(res.error)
Get order info
order_id = 'order_id_in_payment_system'

order: OrderData = client.get_order(order_id)

if order:
    # do some staff
    print('Actual order status: ', order.status)
else:
    print('Opps, order not found...')
Create transfer
from pc4store.data import TransferInput

if __name__ == '__main__':
    # create order
    # print(client.get_transfer('eb94786b-c0e3-43af-b5f9-218128fe3db5'))
    res = client.transfer(TransferInput(
        currency_name='USDCASH',
        currency_smart_contract='token.pcash',
        amount='100.00002',
        eos_account='myeosusername',
        response_url='https://api.my-store/transfer-callback/',
    ))

    if res.status == 'OK':
        print(res.payload.transfer)  # all data about transfer
    else:
        print(res.error)
Get order info
from pc4store.data import Transfer

transfer_id = 'transfer_id_in_payment_system'
transfer: Transfer = client.get_transfer(transfer_id)

if transfer:
    # do some staff
    print('Actual transfer status: ', transfer.status, transfer.action.is_irreversible)
else:
    print('Opps, transfer not found...')
Verify callback request
request = MultiDict()  # callback request that you receive from PC4Store API

if client.is_signature_correct(request.json(), request.headers):
    # you can trust this callback
    ...
else:
    # it could be cheating
    ...

Async client

Async client has absolutely same interface.

from pc4store.clients import Pc4StoreAsyncClient

my_store_id = 'unique identifier of your store'
my_store_secret_key = 'secret'

client = Pc4StoreAsyncClient(store_id=my_store_id, store_key=my_store_secret_key)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pc4store-1.1.0.tar.gz (6.5 kB view details)

Uploaded Source

File details

Details for the file pc4store-1.1.0.tar.gz.

File metadata

  • Download URL: pc4store-1.1.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.7

File hashes

Hashes for pc4store-1.1.0.tar.gz
Algorithm Hash digest
SHA256 37eaeb1871dcccd0db75837568c77178d54ff3c232ec56677e7a470eb2829dfb
MD5 c3d1c4f382645e4ddee6aa3cfbfe63f4
BLAKE2b-256 04108f5f3422fcfc7b8545eddfdc297bb7bb5ef1e9478000c477cfe03728f3f8

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.1.0 This release

1 file

1.0.0

1 file

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