Flutterwave / Python-v2

Python library for Flutterwave for Business (F4B) v2 APIs
https://developer.flutterwave.com/
MIT License
21 stars 15 forks source link

CardCharge Exception #98

Closed azeez010 closed 2 years ago

azeez010 commented 2 years ago

I have tried all I could but it throws an exception without specifying what to fix. Why can't this library just generate a payment link? See this error, it;'s very vague "Your card charge call failed with message: An error occured while attempting to decrypt some parameter" How is this supposed to be helpful, I am very frustrated and angry rn. Which parameter is it trying to decrypt? is it my fault? is it the test cards? I don't know, somebody pls help.

azeez010 commented 2 years ago

No help on this anywhere like this problem doesn't exist, even after copying the payment flow on the docs to replicate the possible success, Infact I will prefer to just generate payment link like stripe and paypal does instead of processing the payments myself. But this library doesn't seems to do that.

azeez010 commented 2 years ago

Bugs are just everywhere on the platform, tried using flutterwave standard, Its returning "str.replace is not a function" imagine. tried ravepay.co, I am just tried at this point

spaceofmiah commented 2 years ago

Hello @azeez010, how are you making your request ? Can you drop the code snippet.

I was having similar issue str.replace is not a function , which i just resolved.

spaceofmiah commented 2 years ago

So here is how I was able to get past this error:

First off, I checked this library documentation, i couldn't find anywhere it was documented to generate payment link ( i must've missed it or it's not included yet ), so my implementation was solely through httpx library ( requests library can also work in this case or any other http client library ).

    request_headers = {
        'Authorization': f'Bearer {SK}',
        'Content-Type': 'application/json'               # <--- without this i got str.replace is not a function error
    }

    data = json.dumps({                              # <- without this json.dumps() i got server error from flutterwave
        "redirect_url": "https://your-redirect-url",
        "tx_ref": transaction_ref,
        "customer": customer,
        "amount": amount,
    })

Flutterwave Docs Ref

azeez010 commented 2 years ago

Thanks @spaceofmiah, I appreciate your kind gesture, I already fixed the str.replace error, even I had made mistake the error response was too vague and doesn't help. I solve the issue by passing the data to the Json argument not body

requests.post(headers=headers, Json=data) instead of body=data, what I eventually noticed was that the str.replace error was happening because the line probably got null value instead of a string, but I am not closing this because the card issues hasn't been responded to, some might need this

corneliusyaovi commented 2 years ago

Hello @azeez010

Thank you for sharing how you resolved this. We definitely would look into improving the error messaging so the corrective steps are intuitive.

@spaceofmiah Thank you for helping out with the issue.