From 9e2db24f5da2b8e5a34b21933fa075a01ae99d5a Mon Sep 17 00:00:00 2001 From: ThomasV Date: Sat, 10 May 2014 20:35:00 +0200 Subject: [PATCH] return error status for payment requests --- lib/paymentrequest.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/paymentrequest.py b/lib/paymentrequest.py index a565c3f84..ac4af009f 100644 --- a/lib/paymentrequest.py +++ b/lib/paymentrequest.py @@ -193,7 +193,7 @@ class PaymentRequest: pay_det = self.payment_details if not pay_det.payment_url: - return + return False, "no url" paymnt = paymentrequest_pb2.Payment() paymnt.merchant_data = pay_det.merchant_data @@ -212,18 +212,20 @@ class PaymentRequest: try: r = requests.post(payurl.geturl(), data=pm, headers=ACK_HEADERS, verify=False) except Exception as e: - print "Payment Message/PaymentACK Failed" print e - return + return False, "Payment Message/PaymentACK Failed" + + if r.status_code >= 500: + return False, r.reason + try: paymntack = paymentrequest_pb2.PaymentACK() paymntack.ParseFromString(r.content) except Exception: - print "PaymentACK could not be processed. Payment was sent; please manually verify that payment was received." - return + return False, "PaymentACK could not be processed. Payment was sent; please manually verify that payment was received." print "PaymentACK message received: %s" % paymntack.memo - return paymntack.memo + return True, paymntack.memo