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