Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add use_contact field support to Transfers API #8

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from

Conversation

jim-junior
Copy link

@jim-junior jim-junior commented Oct 5, 2022

Add use_contact field since it is now required according to the API
Currently if you use the zengapay python client to request for a transfer. The use_contact field is either not posted or is posted wrongly and the request returns an error.
https://developers.zengapay.com/#the-transfer-request-object
Nobody seemed to answer this issue #7 so i just edited the source code my self

Reproduce error

transfer.py

import os
from zengapay import Collections, Transfers


config = {
    "ZENGAPAY_ENVIRONMENT": "sandbox",
    "ZENGAPAY_BASE_URL": "https://api.sandbox.zengapay.com/v1",
    "ZENGAPAY_USER_API_TOKEN": "<API-TOKEN>"
}

collection_client = Collections(config)
transfer_client = Transfers(config)

payload = {
    # The phone number that the collection request is intended for.
    "msisdn": "<phone number>",
    "amount": 30000,  # The collection request amount.
    # Internal description or reason for this collection request and must be unique for every request.
    "external_reference": f"loantrans",
    # Textual narrative describing the transaction.
    "narration": f"Get loan trans  -",
    "use_contact": False
}
resp = transfer_client.transfer(payload)
print(resp)

Error in console

/home/junior/dev/github/zengapay/.venv/lib/python3.10/site-packages/urllib3/connectionpool.py:1043: InsecureRequestWarning: Unverified HTTPS request is being made to host 'api.sandbox.zengapay.com'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
  warnings.warn(
{'use_contact': ['The use contact field must be true or false.'], 'contact_id': ['The contact id field is required.']}

Since we are posting json data we should remove the `data` attribute and replace it with the `json` attribute
Add `use_contact` field since it is now required according to the API
https://developers.zengapay.com/#the-transfer-request-object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant