# africastalking-python
![](https://img.shields.io/pypi/v/africastalking.svg)
> The SDK provides convenient access to the Africa's Talking APIs to python apps.
## Documentation
Take a look at the [API docs here](https://developers.africastalking.com).
## Install
```bash
$ pip install africastalking # python 2.7.x
OR
$ python -m pip install africastalking # python 2.7.x
OR
$ pip3 install africastalking # python 3.6.x
OR
$ python3 -m pip install africastalking # python 3.6.x
```
## Usage
The package needs to be configured with your app username and API key, which you can get from the [dashboard](https://account.africastalking.com/).
> You can use this SDK for either production or sandbox apps. For sandbox, the app username is **ALWAYS** `sandbox`
```python
# import package
import africastalking
# Initialize SDK
username = "YOUR_USERNAME" # use 'sandbox' for development in the test environment
api_key = "YOUR_API_KEY" # use your sandbox app API key for development in the test environment
africastalking.initialize(username, api_key)
# Initialize a service e.g. SMS
sms = africastalking.SMS
# Use the service synchronously
response = sms.send("Hello Message!", ["+2547xxxxxx"])
print(response)
# Or use it asynchronously
def on_finish(error, response):
if error is not None:
raise error
print(response)
sms.send("Hello Message!", ["+2547xxxxxx"], callback=on_finish)
```
See [example](example/) for more usage examples.
## Initialization
Initialize the SDK by calling `africastalking.initialize(username, api_key)`. After initialization, you can get instances of offered services as follows:
- [SMS](#sms): `africastalking.SMS`
- [Airtime](#airtime): `africastalking.Airtime`
- [Voice](#voice): `africastalking.Voice`
- [Token](#token): `africastalking.Token`
- [Application](#application): `africastalking.Application`
- [MobileData](#mobiledata): `africastalking.MobileData`
### `Application`
- `fetch_application_data()`: Get app information. e.g balance.
### `Airtime`
- `send(recipients: [dict])`: Send airtime
- `recipients`: Contains an array of arrays containing the following keys
- `phone_number`: Recipient of airtime
- `amount`: Amount to send with currency e.g `100`
- `currency_code`: 3-digit ISO format currency code (e.g `KES`, `USD`, `UGX` etc).
- `max_num_retry`: This allows you to specify the maximum number of retries in case of failed airtime deliveries due to various reasons such as telco unavailability. The default retry period is 8 hours and retries occur every 60 seconds. For example, setting `max_num_retry=4` means the transaction will be retried every 60 seconds for the next 4 hours. `OPTIONAL`.
### `Sms`
- `send(message: str, recipients: [str], sender_id: str = None, enqueue: bool = False)`: Send a message.
- `message`: SMS content. `REQUIRED`
- `recipients`: An array of phone numbers. `REQUIRED`
- `sender_id`: Shortcode or alphanumeric ID that is registered with your Africa's Talking account.
- `enqueue`: Set to `true` if you would like to deliver as many messages to the API without waiting for an acknowledgement from telcos.
- `send_premium(message: str, short_code: str, recipients: [str], link_id: [str] = None, retry_duration_in_hours [int] = None)`: Send a premium SMS
- `message`: SMS content. `REQUIRED`
- `short_code`: Your premium product shortCode. `REQUIRED`
- `recipients`: An array of phone numbers. `REQUIRED`
- `keyword`: Your premium product keyword.
- `link_id`: We forward the `linkId` to your application when a user sends a message to your onDemand service
- `retry_duration_in_hours`: This specifies the number of hours your subscription message should be retried in case it's not delivered to the subscriber
- `fetch_messages(last_received_id: int = 0)`: Fetch your messages
- `last_received_id`: This is the id of the message you last processed. Defaults to `0`
- `create_subscription(short_code: str, keyword: str, phone_number: str)`: Create a premium subscription
- `short_code`: Premium short code mapped to your account. `REQUIRED`
- `keyword`: Premium keyword under the above short code and is also mapped to your account. `REQUIRED`
- `phone_number`: PhoneNumber to be subscribed `REQUIRED`
- `fetch_subscriptions(short_code: str, keyword: str, last_received_id: int = 0)`: Fetch your premium subscription data
- `short_code`: Premium short code mapped to your account. `REQUIRED`
- `keyword`: Premium keyword under the above short code and mapped to your account. `REQUIRED`
- `last_received_id`: ID of the subscription you believe to be your last. Defaults to `0`
- `delete_subscription(short_code: str, keyword: str, phone_number: str)`: Delete a phone number from a premium subscription
- `short_code`: Premium short code mapped to your account. `REQUIRED`
- `keyword`: Premium keyword under the above short code and is also mapped to your account. `REQUIRED`
- `phone_number`: PhoneNumber to be subscribed `REQUIRED`
<!-- ### `Payments`
- `mobile_checkout(product_name: str, phone_number: str, currency_code: str, amount: float, metadata: dict = {}, provider_channel:str)`: Charge a customers mobile money account
- `product_name`: Payment product on Africa's Talking. `REQUIRED`
- `phone_number`: Customer phone number (in international format). `REQUIRED`
- `currency_code`: 3-digit ISO format currency code (e.g `KES`, `USD`, `UGX` etc). `REQUIRED`
- `amount`: Amount to charge. `REQUIRED`
- `metadata`: Additional data to associate with the transaction. `REQUIRED`
- `provider_channel`: The provider channel the payment will be initiated from e.g a paybill number. `OPTIONAL`
- `mobile_b2c(product_name: str, consumers: [dict])`: Send mobile money to customers:
- `product_name`: Payment product on Africa's Talking. `REQUIRED`
- `consumers`: A list of **up to 10** recipients. Each recipient has:
- `phoneNumber`: Customer phone number (in international format). `REQUIRED`
- `currencyCode`: 3-digit ISO format currency code (e.g `KES`, `USD`, `UGX` etc). `REQUIRED`
- `amount`: Amount to pay. `REQUIRED`
- `reason`: The purpose of the payment. See `payments::REASON*` for supported reasons. `REQUIRED`
- `metadata`: Additional data to associate with the tranasction. `REQUIRED`
- `mobile_b2b(product_name: str, business: dict)`: Send mobile money to business.
- `product_name`: Payment product on Africa's Talking. `REQUIRED`
- `business`: Business details
- `provider`: Payment provider that is facilitating this transaction. See `payments::PROVIDER*` for supported providers. `REQUIRED`
- `transferType`: Describes the type of payment being made. See `payments::TRANSFER_TYPE*` for supported transfer types. `REQUIRED`
- `currencyCode`: 3-digit ISO format currency code (e.g `KES`, `USD`, `UGX` etc). `REQUIRED`
- `destinationChannel`: Name or number of the channel that will receive payment by the provider. `REQUIRED`
- `destinationAccount`: Name used by the business to receive money on the provided destinationChannel. `REQUIRED`
- `amount`: Amount to pay. `REQUIRED`
- `requester`: PhoneNumber through which KPLC will send tokens when using B2B to buy electricity tokens.
- `metadata`: Additional data to associate with the transaction. `REQUIRED`
- `bank_checkout(product_name: str, currency_code: str, amount: float, bank_account: dict, narration: str, metadata: dict = {})`: Initiate bank checkout.
- `product_name`: Payment product on Africa's Talking. `REQUIRED`
- `bank_account`: Bank account to be charged:
- `accountName`: Name of the bank account. `REQUIRED`
- `accountNumber`: Account number. `REQUIRED`
- `bankCode`: A [6-Digit Integer Code](https://developers.africastalking.com/docs/payments/bank/checkout) for the bank that we allocate. See `payments::BANK*` for supported banks. `REQUIRED`
- `dateOfBirth`: Date of birth of the account owner (in the format `YYYY-MM-DD`). Required for Zenith Bank Nigeria.
- `currency_ode`: 3-digit ISO format currency code (only `NGN` is supported at present). `REQUIRED`
- `amount`: Amount to charge. `REQUIRED`
- `narration`: A short description of the transaction. `REQUIRED`
- `metadata`: Additional data to associate with the transaction. `REQUIRED`
- `validate_bank_checkout(transaction_id: str, otp: str)`: Validate a bank checkout
- `transactionId`: Transaction id returned from a bank charge request. `REQUIRED`
- `otp`: One Time Password provided by the customer you're charging. `REQUIRED`
- `bank_transfer(product_name: str, recipients: [dict])`: Move money form payment wallet to bank account.
- `product_name`: Payment product on Africa's Talking. `REQUIRED`
- `recipients`: A list of recipients. Each recipient has:
- `bankAccount`: Bank account to receive money:
- `accountName`: Name of the bank account. `REQUIRED`
- `accountNumber`: Account number. `REQUIRED`
- `bankCode`: A [6-Digit Integer Code](https://developers.africastalking.com/docs/payments/bank/checkout) for the bank that we allocate. See `payments::BANK*` for supported banks. `REQUIRED`
- `dateOfBirth`: Date of birth of the account owner (in the format `YYYY-MM-DD`). Required for Zenith Bank Nigeria.
- `currencyCode`: 3-digit ISO format currency code (only `NGN` is supported at present). `REQUIRED`
- `amount`: Amount to pay. `REQUIRED`
- `narration`: A short description of the transaction. `REQUIRED`
- `metadata`: Additonal data to associate with the transaction. `REQUIRED`
- `card_checkout(product_name: str, currency_code:str, amount: float, payment_card: dict, narration: str, metadata: dict = {})`: Initiate card checkout.
- `product_name`: Payment product on Africa's Talking. `REQUIRED`
- `payment_card`: Payment card to be charged:
- `number`: Payment card number. `REQUIRED`
- `cvvNumber`: 3 or 4 digit card verification Value. `REQUIRED`
- `expiryMonth`: Expiration month on the card (e.g `8`). `REQUIRED`
- `authToken`: Payment card's ATM PIN. `REQUIRED`
- `countryCode`: 2-Digit countryCode where the card was issued (only `NG` is supported at present). `REQUIRED`
- `checkout_token`: A token that has been generated by our APIs as as result of charging a customers payment card in a previous transaction. When using a `checkoutToken`, the `paymentCard` data should NOT be populated.
- `currency_code`: 3-digit ISO format currency code (only `NGN` is supported at present). `REQUIRED`
- `amount`: Amount to charge. `REQUIRED`
- `narration`: A short description of the transaction. `REQUIRED`
- `metadata`: Additonal data to associate with the transaction. `REQUIRED`
- `validate_card_checkout(transaction_id: str, otp: str)`: Validate a card checkout
- `transactionId`: Transaction id returned from a card charge request. `REQUIRED`
- `otp`: One Time Password provided by the customer you're charging. `REQUIRED`
- `wallet_transfer(product_name: str, target_product_code: int, currency_code: str, amount: float, metadata: dict)`: Transfer money from one Payment Product to another Payment Product hosted on Africa's Talking.
- `product_name`: Payment product on Africa's Talking. `REQUIRED`
- `target_product_code`: Unique code ode of payment product receiving funds on Africa's Talking. `REQUIRED`
- `currency_code`: 3-digit ISO format currency code (only `NGN` is supported at present). `REQUIRED`
- `amount`: Amount to transfer. `REQUIRED`
- `metadata`: Additional data to associate with the transation. `REQUIRED`
- `topup_stash(product_name: str, currency_code: str, amount: float, metadata: dict)`: Move money from a Payment Product to an app's stash.
- `product_name`: Payment product on Africa's Talking. `REQUIRED`
- `currency_code`: 3-digit ISO format currency code (only `NGN` is supported at present). `REQUIRED`
- `amount`: Amount to transfer. `REQUIRED`
- `metadata`: Additonal data to associate with the transaction. `REQUIRED`
- `fetch_product_transactions(product_name: str, filters: dict)`: Fetch transactions of a particular payment product.
- `productName`: Payment product on Africa's Talking. `REQUIRED`
- `filters`: Transaction filters.
- `pageNumber`: Page number to fetch results from. Starts from `1`. `REQUIRED`
- `count`: Number of results to fetch. `REQUIRED`
- `startDate`: Start Date to consider when fetching.
- `endDate`: End Date to consider when fetching.
- `category`: Category to consider when fetching.
- `provider`: Provider to consider when fetching.
- `status`: Status to consider when fetching.
- `source`: Source to consider when fetching.
- `destination`: Destination to consider when fetching.
- `providerChannel`: Provider channel to consider when fetching.
- `wallet_transactions(filters: dict)`: Fetch your wallet transactions.
- `filters`: Wallet transactions filters. `REQUIRED`
- `pageNumber`: Page number to fetch results from. Starts from `1`. `REQUIRED`
- `count`: Number of results to fetch. `REQUIRED`
- `startDate`: Start Date to consider when fetching.
- `endDate`: End Date to consider when fetching.
- `category`: Comma delimited list of categories to consider when fetching.
- `find_transaction(transaction_id: str)`: Find a particular payment transaction.
- `transaction_id`: ID of trancation to find. `REQUIRED`
- `wallet_balance()`: Fetch your wallet balance.
### `Voice`
- `call(callFrom: str, callTo: [str])`: Initiate a phone call
- `callFrom`: Phone number on Africa's Talking (in international format). `REQUIRED`
- `callTo`: An array of phone numbers that you wish to dial (in international format). `REQUIRED`
- `fetch_queued_calls(phone_number: str)`: Get queued calls
- `phone_number`: Phone number mapped to your Africa's Talking account (in international format). `REQUIRED`
- `upload_media_file(phone_number: str, url: str)`: Upload voice media file
- `phone_number`: phone number mapped to your Africa's Talking account (in international format). `REQUIRED`
- `url`: The url of the file to upload. Should start with `http(s)://`. `REQUIRED` -->
### `MobileData`
- `send(product_name: str, recipients: dict)`: Send mobile data to customers.
- `product_name`: Payment product on Africa's Talking. `REQUIRED`
- `recipients`: A list of recipients. Each recipient has:
- `phoneNumber`: Customer phone number (in international format). `REQUIRED`
- `quantity`: Mobile data amount. `REQUIRED`
- `unit`: Mobile data unit. Can either be `MB` or `GB`. `REQUIRED`
- `validity`: How long the mobile data is valid for. Must be one of `Day`, `Week` and `Month`. `REQUIRED`
- `isPromoBundle`: This is an optional field that can be either`true` and `false`. `OPTIONAL`
- `metadata`: Additional data to associate with the transaction. `OPTIONAL`
- `find_transaction(transaction_id: str)`: Find a mobile data transaction.
- `fetch_wallet_balance()`: Fetch a mobile data product balance.
### `Token`
- `generate_auth_token()`: Generate an auth token to use for authentication instead of an API key.
### `Ussd`
For more information, please read [https://developers.africastalking.com/docs/ussd](https://developers.africastalking.com/docs/ussd/overview)
## Development
```shell
$ git clone https://github.com/AfricasTalkingLtd/africastalking-python.git
$ cd africastalking-python
$ touch .env
```
Make sure your `.env` file has the following content then run `python -m unittest discover -v`
```ini
# AT API
USERNAME=sandbox
API_KEY=some_key
```
## Issues
If you find a bug, please file an issue on [our issue tracker on GitHub](https://github.com/AfricasTalkingLtd/africastalking-python/issues).
Raw data
{
"_id": null,
"home_page": "https://github.com/AfricasTalkingLtd/africastalking-python",
"name": "africastalking",
"maintainer": "",
"docs_url": null,
"requires_python": ">=2.7.10",
"maintainer_email": "",
"keywords": "ussd voice sms mpesa card bank b2b b2c sender_id payments airtime africastalking",
"author": "Africa's Talking",
"author_email": "info@africastalking.com",
"download_url": "https://files.pythonhosted.org/packages/e7/fe/3d6d7bb61ef6c7e793b6798c0f654be7703aa68e0e749946804d08915098/africastalking-1.2.7.tar.gz",
"platform": null,
"description": "# africastalking-python\n\n![](https://img.shields.io/pypi/v/africastalking.svg)\n\n> The SDK provides convenient access to the Africa's Talking APIs to python apps.\n\n\n## Documentation\nTake a look at the [API docs here](https://developers.africastalking.com).\n\n## Install\n\n```bash\n$ pip install africastalking # python 2.7.x\n\nOR\n\n$ python -m pip install africastalking # python 2.7.x\n\nOR\n\n$ pip3 install africastalking # python 3.6.x\n\nOR\n\n$ python3 -m pip install africastalking # python 3.6.x\n\n```\n\n## Usage\n\nThe package needs to be configured with your app username and API key, which you can get from the [dashboard](https://account.africastalking.com/).\n\n> You can use this SDK for either production or sandbox apps. For sandbox, the app username is **ALWAYS** `sandbox`\n\n```python\n# import package\nimport africastalking\n\n\n# Initialize SDK\nusername = \"YOUR_USERNAME\" # use 'sandbox' for development in the test environment\napi_key = \"YOUR_API_KEY\" # use your sandbox app API key for development in the test environment\nafricastalking.initialize(username, api_key)\n\n\n# Initialize a service e.g. SMS\nsms = africastalking.SMS\n\n\n# Use the service synchronously\nresponse = sms.send(\"Hello Message!\", [\"+2547xxxxxx\"])\nprint(response)\n\n# Or use it asynchronously\ndef on_finish(error, response):\n if error is not None:\n raise error\n print(response)\n\nsms.send(\"Hello Message!\", [\"+2547xxxxxx\"], callback=on_finish) \n\n```\n\nSee [example](example/) for more usage examples.\n\n\n## Initialization\n\nInitialize the SDK by calling `africastalking.initialize(username, api_key)`. After initialization, you can get instances of offered services as follows:\n\n- [SMS](#sms): `africastalking.SMS`\n- [Airtime](#airtime): `africastalking.Airtime`\n- [Voice](#voice): `africastalking.Voice`\n- [Token](#token): `africastalking.Token`\n- [Application](#application): `africastalking.Application`\n- [MobileData](#mobiledata): `africastalking.MobileData`\n\n### `Application`\n\n- `fetch_application_data()`: Get app information. e.g balance.\n\n### `Airtime`\n\n- `send(recipients: [dict])`: Send airtime\n\n - `recipients`: Contains an array of arrays containing the following keys\n \n - `phone_number`: Recipient of airtime\n - `amount`: Amount to send with currency e.g `100`\n - `currency_code`: 3-digit ISO format currency code (e.g `KES`, `USD`, `UGX` etc).\n\n- `max_num_retry`: This allows you to specify the maximum number of retries in case of failed airtime deliveries due to various reasons such as telco unavailability. The default retry period is 8 hours and retries occur every 60 seconds. For example, setting `max_num_retry=4` means the transaction will be retried every 60 seconds for the next 4 hours. `OPTIONAL`.\n\n### `Sms`\n\n- `send(message: str, recipients: [str], sender_id: str = None, enqueue: bool = False)`: Send a message.\n\n - `message`: SMS content. `REQUIRED`\n - `recipients`: An array of phone numbers. `REQUIRED`\n - `sender_id`: Shortcode or alphanumeric ID that is registered with your Africa's Talking account.\n - `enqueue`: Set to `true` if you would like to deliver as many messages to the API without waiting for an acknowledgement from telcos.\n\n- `send_premium(message: str, short_code: str, recipients: [str], link_id: [str] = None, retry_duration_in_hours [int] = None)`: Send a premium SMS\n\n - `message`: SMS content. `REQUIRED`\n - `short_code`: Your premium product shortCode. `REQUIRED`\n - `recipients`: An array of phone numbers. `REQUIRED`\n - `keyword`: Your premium product keyword.\n - `link_id`: We forward the `linkId` to your application when a user sends a message to your onDemand service\n - `retry_duration_in_hours`: This specifies the number of hours your subscription message should be retried in case it's not delivered to the subscriber\n\n- `fetch_messages(last_received_id: int = 0)`: Fetch your messages\n\n - `last_received_id`: This is the id of the message you last processed. Defaults to `0`\n \n- `create_subscription(short_code: str, keyword: str, phone_number: str)`: Create a premium subscription\n\n - `short_code`: Premium short code mapped to your account. `REQUIRED`\n - `keyword`: Premium keyword under the above short code and is also mapped to your account. `REQUIRED`\n - `phone_number`: PhoneNumber to be subscribed `REQUIRED`\n\n- `fetch_subscriptions(short_code: str, keyword: str, last_received_id: int = 0)`: Fetch your premium subscription data\n\n - `short_code`: Premium short code mapped to your account. `REQUIRED`\n - `keyword`: Premium keyword under the above short code and mapped to your account. `REQUIRED`\n - `last_received_id`: ID of the subscription you believe to be your last. Defaults to `0`\n\n- `delete_subscription(short_code: str, keyword: str, phone_number: str)`: Delete a phone number from a premium subscription\n\n - `short_code`: Premium short code mapped to your account. `REQUIRED`\n - `keyword`: Premium keyword under the above short code and is also mapped to your account. `REQUIRED`\n - `phone_number`: PhoneNumber to be subscribed `REQUIRED`\n \n \n<!-- ### `Payments`\n\n- `mobile_checkout(product_name: str, phone_number: str, currency_code: str, amount: float, metadata: dict = {}, provider_channel:str)`: Charge a customers mobile money account\n\n - `product_name`: Payment product on Africa's Talking. `REQUIRED`\n - `phone_number`: Customer phone number (in international format). `REQUIRED`\n - `currency_code`: 3-digit ISO format currency code (e.g `KES`, `USD`, `UGX` etc). `REQUIRED`\n - `amount`: Amount to charge. `REQUIRED`\n - `metadata`: Additional data to associate with the transaction. `REQUIRED`\n - `provider_channel`: The provider channel the payment will be initiated from e.g a paybill number. `OPTIONAL`\n \n- `mobile_b2c(product_name: str, consumers: [dict])`: Send mobile money to customers:\n\n - `product_name`: Payment product on Africa's Talking. `REQUIRED`\n - `consumers`: A list of **up to 10** recipients. Each recipient has:\n\n - `phoneNumber`: Customer phone number (in international format). `REQUIRED`\n - `currencyCode`: 3-digit ISO format currency code (e.g `KES`, `USD`, `UGX` etc). `REQUIRED`\n - `amount`: Amount to pay. `REQUIRED`\n - `reason`: The purpose of the payment. See `payments::REASON*` for supported reasons. `REQUIRED`\n - `metadata`: Additional data to associate with the tranasction. `REQUIRED`\n\n- `mobile_b2b(product_name: str, business: dict)`: Send mobile money to business.\n\n - `product_name`: Payment product on Africa's Talking. `REQUIRED`\n - `business`: Business details\n - `provider`: Payment provider that is facilitating this transaction. See `payments::PROVIDER*` for supported providers. `REQUIRED`\n - `transferType`: Describes the type of payment being made. See `payments::TRANSFER_TYPE*` for supported transfer types. `REQUIRED`\n - `currencyCode`: 3-digit ISO format currency code (e.g `KES`, `USD`, `UGX` etc). `REQUIRED`\n - `destinationChannel`: Name or number of the channel that will receive payment by the provider. `REQUIRED`\n - `destinationAccount`: Name used by the business to receive money on the provided destinationChannel. `REQUIRED`\n - `amount`: Amount to pay. `REQUIRED`\n - `requester`: PhoneNumber through which KPLC will send tokens when using B2B to buy electricity tokens.\n - `metadata`: Additional data to associate with the transaction. `REQUIRED`\n\n\n- `bank_checkout(product_name: str, currency_code: str, amount: float, bank_account: dict, narration: str, metadata: dict = {})`: Initiate bank checkout.\n\n - `product_name`: Payment product on Africa's Talking. `REQUIRED`\n - `bank_account`: Bank account to be charged:\n\n - `accountName`: Name of the bank account. `REQUIRED`\n - `accountNumber`: Account number. `REQUIRED`\n - `bankCode`: A [6-Digit Integer Code](https://developers.africastalking.com/docs/payments/bank/checkout) for the bank that we allocate. See `payments::BANK*` for supported banks. `REQUIRED`\n - `dateOfBirth`: Date of birth of the account owner (in the format `YYYY-MM-DD`). Required for Zenith Bank Nigeria.\n\n - `currency_ode`: 3-digit ISO format currency code (only `NGN` is supported at present). `REQUIRED`\n - `amount`: Amount to charge. `REQUIRED`\n - `narration`: A short description of the transaction. `REQUIRED`\n - `metadata`: Additional data to associate with the transaction. `REQUIRED`\n\n- `validate_bank_checkout(transaction_id: str, otp: str)`: Validate a bank checkout\n\n - `transactionId`: Transaction id returned from a bank charge request. `REQUIRED`\n - `otp`: One Time Password provided by the customer you're charging. `REQUIRED`\n\n- `bank_transfer(product_name: str, recipients: [dict])`: Move money form payment wallet to bank account.\n\n - `product_name`: Payment product on Africa's Talking. `REQUIRED`\n - `recipients`: A list of recipients. Each recipient has:\n\n - `bankAccount`: Bank account to receive money:\n\n - `accountName`: Name of the bank account. `REQUIRED`\n - `accountNumber`: Account number. `REQUIRED`\n - `bankCode`: A [6-Digit Integer Code](https://developers.africastalking.com/docs/payments/bank/checkout) for the bank that we allocate. See `payments::BANK*` for supported banks. `REQUIRED`\n - `dateOfBirth`: Date of birth of the account owner (in the format `YYYY-MM-DD`). Required for Zenith Bank Nigeria.\n\n - `currencyCode`: 3-digit ISO format currency code (only `NGN` is supported at present). `REQUIRED`\n - `amount`: Amount to pay. `REQUIRED`\n - `narration`: A short description of the transaction. `REQUIRED`\n - `metadata`: Additonal data to associate with the transaction. `REQUIRED`\n\n- `card_checkout(product_name: str, currency_code:str, amount: float, payment_card: dict, narration: str, metadata: dict = {})`: Initiate card checkout.\n\n - `product_name`: Payment product on Africa's Talking. `REQUIRED`\n - `payment_card`: Payment card to be charged:\n\n - `number`: Payment card number. `REQUIRED`\n - `cvvNumber`: 3 or 4 digit card verification Value. `REQUIRED`\n - `expiryMonth`: Expiration month on the card (e.g `8`). `REQUIRED`\n - `authToken`: Payment card's ATM PIN. `REQUIRED`\n - `countryCode`: 2-Digit countryCode where the card was issued (only `NG` is supported at present). `REQUIRED`\n\n - `checkout_token`: A token that has been generated by our APIs as as result of charging a customers payment card in a previous transaction. When using a `checkoutToken`, the `paymentCard` data should NOT be populated.\n - `currency_code`: 3-digit ISO format currency code (only `NGN` is supported at present). `REQUIRED`\n - `amount`: Amount to charge. `REQUIRED`\n - `narration`: A short description of the transaction. `REQUIRED`\n - `metadata`: Additonal data to associate with the transaction. `REQUIRED`\n\n- `validate_card_checkout(transaction_id: str, otp: str)`: Validate a card checkout\n\n - `transactionId`: Transaction id returned from a card charge request. `REQUIRED`\n - `otp`: One Time Password provided by the customer you're charging. `REQUIRED`\n\n- `wallet_transfer(product_name: str, target_product_code: int, currency_code: str, amount: float, metadata: dict)`: Transfer money from one Payment Product to another Payment Product hosted on Africa's Talking.\n\n - `product_name`: Payment product on Africa's Talking. `REQUIRED`\n - `target_product_code`: Unique code ode of payment product receiving funds on Africa's Talking. `REQUIRED`\n - `currency_code`: 3-digit ISO format currency code (only `NGN` is supported at present). `REQUIRED`\n - `amount`: Amount to transfer. `REQUIRED`\n - `metadata`: Additional data to associate with the transation. `REQUIRED`\n\n\n- `topup_stash(product_name: str, currency_code: str, amount: float, metadata: dict)`: Move money from a Payment Product to an app's stash.\n\n - `product_name`: Payment product on Africa's Talking. `REQUIRED`\n - `currency_code`: 3-digit ISO format currency code (only `NGN` is supported at present). `REQUIRED`\n - `amount`: Amount to transfer. `REQUIRED`\n - `metadata`: Additonal data to associate with the transaction. `REQUIRED`\n\n- `fetch_product_transactions(product_name: str, filters: dict)`: Fetch transactions of a particular payment product.\n\n - `productName`: Payment product on Africa's Talking. `REQUIRED`\n - `filters`: Transaction filters.\n - `pageNumber`: Page number to fetch results from. Starts from `1`. `REQUIRED`\n - `count`: Number of results to fetch. `REQUIRED`\n - `startDate`: Start Date to consider when fetching.\n - `endDate`: End Date to consider when fetching.\n - `category`: Category to consider when fetching.\n - `provider`: Provider to consider when fetching.\n - `status`: Status to consider when fetching.\n - `source`: Source to consider when fetching.\n - `destination`: Destination to consider when fetching.\n - `providerChannel`: Provider channel to consider when fetching.\n \n- `wallet_transactions(filters: dict)`: Fetch your wallet transactions.\n\n - `filters`: Wallet transactions filters. `REQUIRED`\n - `pageNumber`: Page number to fetch results from. Starts from `1`. `REQUIRED`\n - `count`: Number of results to fetch. `REQUIRED`\n - `startDate`: Start Date to consider when fetching.\n - `endDate`: End Date to consider when fetching.\n - `category`: Comma delimited list of categories to consider when fetching.\n\n- `find_transaction(transaction_id: str)`: Find a particular payment transaction.\n\n - `transaction_id`: ID of trancation to find. `REQUIRED`\n\n- `wallet_balance()`: Fetch your wallet balance. \n\n\n### `Voice`\n\n- `call(callFrom: str, callTo: [str])`: Initiate a phone call\n\n\t- `callFrom`: Phone number on Africa's Talking (in international format). `REQUIRED`\n - `callTo`: An array of phone numbers that you wish to dial (in international format). `REQUIRED` \n\n- `fetch_queued_calls(phone_number: str)`: Get queued calls\n\n - `phone_number`: Phone number mapped to your Africa's Talking account (in international format). `REQUIRED`\n\n- `upload_media_file(phone_number: str, url: str)`: Upload voice media file\n\n - `phone_number`: phone number mapped to your Africa's Talking account (in international format). `REQUIRED`\n - `url`: The url of the file to upload. Should start with `http(s)://`. `REQUIRED` -->\n\n### `MobileData`\n\n- `send(product_name: str, recipients: dict)`: Send mobile data to customers.\n\n - `product_name`: Payment product on Africa's Talking. `REQUIRED`\n - `recipients`: A list of recipients. Each recipient has:\n - `phoneNumber`: Customer phone number (in international format). `REQUIRED`\n - `quantity`: Mobile data amount. `REQUIRED`\n - `unit`: Mobile data unit. Can either be `MB` or `GB`. `REQUIRED`\n - `validity`: How long the mobile data is valid for. Must be one of `Day`, `Week` and `Month`. `REQUIRED`\n - `isPromoBundle`: This is an optional field that can be either`true` and `false`. `OPTIONAL`\n - `metadata`: Additional data to associate with the transaction. `OPTIONAL`\n\n- `find_transaction(transaction_id: str)`: Find a mobile data transaction.\n\n- `fetch_wallet_balance()`: Fetch a mobile data product balance.\n\n### `Token`\n\n- `generate_auth_token()`: Generate an auth token to use for authentication instead of an API key.\n\n\n### `Ussd`\n\nFor more information, please read [https://developers.africastalking.com/docs/ussd](https://developers.africastalking.com/docs/ussd/overview)\n\n\n## Development\n```shell\n$ git clone https://github.com/AfricasTalkingLtd/africastalking-python.git\n$ cd africastalking-python\n$ touch .env\n```\n\nMake sure your `.env` file has the following content then run `python -m unittest discover -v`\n\n```ini\n# AT API\nUSERNAME=sandbox\nAPI_KEY=some_key\n```\n\n## Issues\n\nIf you find a bug, please file an issue on [our issue tracker on GitHub](https://github.com/AfricasTalkingLtd/africastalking-python/issues).\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Official Africa's Talking Python SDK",
"version": "1.2.7",
"project_urls": {
"Download": "https://codeload.github.com/AfricasTalkingLtd/africastalking-python/tar.gz/1.2.7",
"Homepage": "https://github.com/AfricasTalkingLtd/africastalking-python"
},
"split_keywords": [
"ussd",
"voice",
"sms",
"mpesa",
"card",
"bank",
"b2b",
"b2c",
"sender_id",
"payments",
"airtime",
"africastalking"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7fdb564f8a631f5368ba29e17e301c60d00fb2a1f10e851109237d985058e46a",
"md5": "f56ab33ccc14fffffa263f146b50f7fd",
"sha256": "8fbb5fe0b3d0330dd29ae8f12df90830a56e6823153d7d57c970ec4811c5dae9"
},
"downloads": -1,
"filename": "africastalking-1.2.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f56ab33ccc14fffffa263f146b50f7fd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=2.7.10",
"size": 19506,
"upload_time": "2023-11-07T13:43:56",
"upload_time_iso_8601": "2023-11-07T13:43:56.449199Z",
"url": "https://files.pythonhosted.org/packages/7f/db/564f8a631f5368ba29e17e301c60d00fb2a1f10e851109237d985058e46a/africastalking-1.2.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e7fe3d6d7bb61ef6c7e793b6798c0f654be7703aa68e0e749946804d08915098",
"md5": "3518ee557fa0d24ad9e86796923790fd",
"sha256": "fd3a2368755b5b7c5f5718b75231a4f6151013e6f4818b141428958be32a8637"
},
"downloads": -1,
"filename": "africastalking-1.2.7.tar.gz",
"has_sig": false,
"md5_digest": "3518ee557fa0d24ad9e86796923790fd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=2.7.10",
"size": 16510,
"upload_time": "2023-11-07T13:43:58",
"upload_time_iso_8601": "2023-11-07T13:43:58.937985Z",
"url": "https://files.pythonhosted.org/packages/e7/fe/3d6d7bb61ef6c7e793b6798c0f654be7703aa68e0e749946804d08915098/africastalking-1.2.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-07 13:43:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "AfricasTalkingLtd",
"github_project": "africastalking-python",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "africastalking"
}