def authenticate() -> str: """ User authentication token """ print("================== start authentication ==================") client.api_base = Seerbit.LIVE_API_BASE client.environment = EnvironmentEnum.LIVE.value client.private_key = "private_key" client.public_key = "public_key" client.timeout = 20 auth_service = Authentication(client) auth_service.auth() print("================== stop authentication ==================") return auth_service.get_token()
def card_payment_cancel(token_str: str): """ Initiate Card Payment Cancel """ print("================== start card payment cancel ==================") random_number = randint(10000000, 99999999) payment_ref = "SBT_" + str(random_number) card_payload = { "paymentReference": payment_ref, "publicKey": client.public_key, "country": "KE", "productDescription": "test cancel" } card_service = CardService(client, token_str) json_response = card_service.payment_cancel(card_payload) print("================== stop card payment cancel ==================") return json_response client.api_base = Seerbit.LIVE_API_BASE client.environment = EnvironmentEnum.LIVE.value client.private_key = "private_key" client.public_key = "public_key" client.timeout = 20 client.authentication_scheme = AuthTypeEnum.BASIC.value auth_service = Authentication(client) token = auth_service.get_basic_auth_encoded_string() if token: print("card cancel payment response: " + str(card_payment_cancel(token))) else: print("authentication failure")