def generate_invoice(request): """ Generates invoice to user from PayU """ txnid = request.data.get("txnid") amount = request.data.get("amount") productinfo = request.data.get("productinfo") firstname = request.data.get("firstname") email = request.data.get("email") phone = request.data.get("phone") validation_period = request.POST["validation_period"] send_email_now = request.POST["send_email_now"] command = "create_invoice" var1 = json.dumps({"amount": amount, "txnid": txnid, "productinfo": productinfo, "firstname": firstname, "email": email, "phone": phone, "validation_period": validation_period, "send_email_now": send_email_now}) hashh = create_hash_for_post_payment(command=command, var1=var1) payload = {"key": key, "command": command, "var1": var1, "hash": hashh} response = get_invoice(payload) return send_200({"message": response})
def payment_verify(request): """ Verifies transaction returns related details """ txnid = request.POST['txnid'] command = "verify_payment" hashh = create_hash_for_post_payment(command=command, var1=txnid) payload = {"key": key, "command": command, "var1": txnid, "hash": hashh} response = payment_verification(payload) return send_200({"message": response})
def payment_status(request): """ Verifies transaction returns some extra details as compared with payment_verify """ mihpayid = request.POST['mihpayid'] command = "check_payment" hashh = create_hash_for_post_payment(command=command, var1=mihpayid) payload = {"key": key, "command": command, "var1": mihpayid, "hash": hashh} response = payment_check(payload) return send_200({"message": response})
def cancel_refund_status(request): """ Returns status of cancel or refund request transaction """ request_id = request.POST['request_id'] command = 'check_action_status' hashh = create_hash_for_post_payment(command=command, var1=request_id) payload = { 'key': key, 'command': command, 'hash': hashh, 'var1': request_id} response = check_action_status(payload) return send_200({"message": response})
def transaction_detail(request): """ Returns transaction detail between window of date """ old_date = request.POST['old_date'] recent_date = request.POST['recent_date'] command = 'get_Transaction_Details' hashh = create_hash_for_post_payment(command=command, var1=old_date) payload = { 'key': key, 'command': command, 'hash': hashh, 'var1': old_date, 'var2': recent_date} response = get_transaction_detail(payload) return send_200({"message": response})
def cancel_refund_request(request): """ Request for cancel or refund transaction """ mihpayid = request.POST['payu_id'] token_id = uuid4().hex amount = request.POST['amount'] key = settings.PAYU_INFO["merchant_key"] command = 'cancel_refund_transaction' hashh = create_hash_for_post_payment( command=command, var1=mihpayid, var2=token_id, var3=amount) payload = { 'key': key, 'command': command, 'hash': hashh, 'var1': mihpayid, 'var2': token_id, 'var3': amount} response = cancel_or_refund_request(payload) return send_200({"message": response})