Ejemplo n.º 1
0
def makeCardPayment(data, amount):

    error = validatePaymentDetails(data)

    if error['status'] == 'bad':
        return jsonify(error), 400

    cardno = data['cardno']
    cvv = data['cvv']
    pin = data['pin']
    amount = amount
    userId = data['userId']
    expiryyear = data['expiryyear']
    expirymonth = data['expirymonth']

    try:
        user = Users.objects(pk=userId).first()
        rave = FlutterWave(cardno, cvv, expirymonth, expiryyear, pin, amount,
                           user)

        res = rave.pay_via_card()

        return res
    except Exception as e:
        print(e)
        return {
            "status":
            "failed",
            "msg":
            "something happened server cannot  \
            handle this request at the moment try again later"
        }
Ejemplo n.º 2
0
def makePayment():
    data = None
    if request.method == 'POST':
        data = request.get_json()

    print(request.get_json())

    error = validatePaymentDetails(data)

    print(error)

    if error['status'] == 'bad':
        return jsonify(error), 400

    cardno = data['cardno']
    cvv = data['cvv']
    pin = data['pin']
    amount = data['amount']
    userId = ObjectId(data['userId'])
    expiryyear = data['expiryyear']
    expirymonth = data['expirymonth']

    try:
        user = Users.objects(pk=userId).first()
        rave = FlutterWave(cardno, cvv, expirymonth, expiryyear, pin, amount,
                           user)
        wallet = None

        res = rave.pay_via_card()

        if res['status'] == 'success':
            if res['data']["chargeResponseCode"] == "02":
                return jsonify(res), 200
        else:
            return jsonify({
                "status":
                "failed",
                'msg':
                "Something happened cannot\
                            initiate payment please try again later",
            }), 400

    except Exception as e:
        print(e)
        return jsonify({
            "status":
            "failed",
            "msg":
            "something happened server cannot  \
            handle this request at the moment try again later"
        }), 500