Registry / payments / mastercard-api-core

mastercard-api-core

JSON →
library1.4.12pypypiunverified

Official Mastercard SDK for Python, providing core authentication, encryption, and HTTP client utilities for interacting with Mastercard APIs. Version 1.4.12 is the latest release; updates are periodic.

pip install mastercard-api-core
INSTALL
IMPORT
SIG · MASTERCARD-API-COR
M
mastercard-api-core
paymentspythonv1.4.12
Install
4.3s avg
Import
Disk
42MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.4.12 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 43.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 4.3s · import 0.000s · 44MB
42MB installed
● package 42MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ApiConfig
from mastercard_api_core import ApiConfig
from mastercard.api import ApiConfig
The correct package name is mastercard_api_core (with underscores), not mastercard.api.
MasterCardApi
from mastercard_api_core import MasterCardApi

Initialize the SDK with a configuration object from environment variables and make an authenticated GET request.

import os from mastercard_api_core import ApiConfig, MasterCardApi config = ApiConfig( consumer_key=os.environ.get('MASTERCARD_CONSUMER_KEY', ''), key_file_path=os.environ.get('MASTERCARD_KEY_FILE_PATH', ''), p12_path=os.environ.get('MASTERCARD_P12_PATH', '') ) api = MasterCardApi(config) # Example: get a resource (generic, adjust per API) response = api.get('/api/v1/resource') print(response.status_code, response.json())
Debug
Known issues
gotchaThe package name on PyPI is 'mastercard-api-core', but the import uses underscores: 'mastercard_api_core'. Using hyphens in import will fail.
fix
Use 'pip install mastercard-api-core' and then 'import mastercard_api_core'.
affects: all
deprecatedSupport for Python 3.6 and 3.7 may be dropped in future versions; current version is tested on 3.8+.
fix
Upgrade to Python 3.8 or higher.
affects: >=1.4.0
gotchaThe SDK expects a .p12 file for mutual TLS authentication. Provide the path to the file, not the raw string content.
fix
Set 'p12_path' to the file path, not the base64 or string content.
affects: all
breakingIn version 1.4.0, the API client initialization changed from positional arguments to keyword arguments. Direct instantiation without keyword arguments will raise TypeError.
fix
Use keyword arguments: ApiConfig(consumer_key=..., key_file_path=..., p12_path=...).
affects: >=1.4.0
Upgrade
Version history
1.4.12latest on PyPI · released Jan 31, 2018
Audit
Dependencies
requestsrequiredHTTP library used for API calls
pycryptodomexrequiredCryptographic operations (OpenSSL wrapper)
Agent activity
37 hits · last 30 days
node
33
Resources
mastercard-api-core — pip install mastercard-api-core · libregistry