Python SDK

Installation

pip install paypack-py

Initialization

from paypack.client import HttpClient

client_id="xxxxxxx", 
client_secret="xxxxxxx"

HttpClient(client_id=client_id, client_secret=client_secret)

cashin

from paypack.transactions import Transaction

//paramaters are required
cashin = Transaction().cashin(amount=100, phone_number="078xxxxx")
print(cashin)

Response

{
  "amount": 1000,
  "created_at": "2005-11-09T21:19:07.459Z",
  "kind": "CASHIN",
  "ref": "d0bb2807-1d52-4795-b373-3feaf63dceb1",
  "status": "pending"
}

cashout

from paypack.transactions import Transaction

//paramaters are required
cashout = Transaction().cashout(amount=100, phone_number="078xxxxx")
print(cashout)

Response

{
  "amount": 1000,
  "created_at": "2005-11-09T21:19:07.459Z",
  "kind": "CASHOUT",
  "ref": "d0bb2807-1d52-4795-b373-3feaf63dceb1",
  "status": "pending"
}

Authorization

from paypack.oauth2 import Oauth

//Login
auth = Oauth().auth()
print(auth)

//Refresh access token
refresh = Oauth().refresh_access_token()
print(refresh)

Response

{
  "access": "xxxxxxxxxxxxxxxxxxxx",
  "refresh": "xxxxxxxxxxxxxxxxxxxx",
  "expires": "xxxxxxxx"
}

Events

from paypack.events import Event

kind='cashout'
limit=10
offset=0

//Optional parameters
events = Event().list(kind,limit,offset)
print(events)

Response

{
  "amount": 100,
  "client": "078xxxxxxx",
  "event-kind": "transaction:created",
  "kind": "CASHIN",
  "limit": 20,
  "offset": 0,
  "ref": "d0bb2807-1d52-4795-b373-3feaf63dceb1",
  "status": "failed",
  "total": 250,
  "transactions": [{
    "event_id": "bf76c3a8-cafe-11ec-9478-dead2ba023b5",
    "event_kind": "transaction:processed",
    "created_at": "2022-05-03T16:33:22.434606Z",
    "data": {
      "ref": "ajsfh44w3j-4h4r-28438-efnef-e9f44a5b4c2d",
      "kind": "CASHIN",
      "fee": 2.3,
      "merchant": "XXXXX",
      "client": "078xxxxxxx",
      "amount": 100,
      "status": "successful",
      "created_at": "2022-05-03T16:27:01.292808134Z",
      "processed_at": "2022-05-03T16:33:22.434351492Z"
      }
    }]
}

Account Information

from paypack.merchant import Merchant

print(Merchant().me())

Response

{
"balance": 10000,
"email": "email@example.com",
"id": "XXXXX",
"in_rate": 0.05,
"name": "Company Name",
"out_rate": 0.05,
}