Flutterwave / Python-v2

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

How do you update the payload with an OTP suggest auth required - Python Flutter wave SDK {'error': True, 'txRef': None, 'errMsg': 'otp is required'} #88

Closed Br3mah closed 3 years ago

Br3mah commented 3 years ago

from rave_python import Rave, RaveExceptions, Misc

def payslo(self): rave = Rave("FLWPUBK_TEST-MY-PUBKEY", "FLWSECK_TEST_MY-SEC_KEY", usingEnv = False) payload = { "cardno": "5531886652142950", "cvv": "564", "expirymonth": "09", "expiryyear": "32", "amount": "1300", "email": "python@gmail.com", "phonenumber": "0902620185", "firstname": "temi", "lastname": "desola", } try: res = rave.Card.charge(payload)

        if res["suggestedAuth"]:
            arg = Misc.getTypeOfArgsRequired(res["suggestedAuth"])

            if arg == "pin":
                Misc.updatePayload(res["suggestedAuth"], payload, pin="3310")

            if arg == "address":
                Misc.updatePayload(res["suggestedAuth"], payload, address= {"billingzip": "07205", "billingcity": "Hillside", "billingaddress": "470 Mundet PI", "billingstate": "NJ", "billingcountry": "US"})

            if arg == "otp":
                Misc.updatePayload(res["suggestedAuth"], payload, otp = 12345)

            res = rave.Card.charge(payload)

        if res["validationRequired"]:
            rave.Card.validate(res["flwRef"], "")

        res = rave.Card.verify(res["txRef"])
        print(res["transactionComplete"])

    except RaveExceptions.CardChargeError as e:
        print(e.err["errMsg"])
        print(e.err["flwRef"])

    except RaveExceptions.TransactionValidationError as e:
        print(e.err)
        print(e.err["flwRef"])

    except RaveExceptions.TransactionVerificationError as e:
        print(e.err["errMsg"])
        print(e.err["txRef"])

otp

corneliusyaovi commented 3 years ago

Hello @Br3mah ,

Please pass the value of the OTP (12345) into the validate method rave.Card.validate(res["flwRef"], "12345")