Browse Source

return error status for payment requests

283
ThomasV 11 years ago
parent
commit
9e2db24f5d
  1. 14
      lib/paymentrequest.py

14
lib/paymentrequest.py

@ -193,7 +193,7 @@ class PaymentRequest:
pay_det = self.payment_details pay_det = self.payment_details
if not pay_det.payment_url: if not pay_det.payment_url:
return return False, "no url"
paymnt = paymentrequest_pb2.Payment() paymnt = paymentrequest_pb2.Payment()
paymnt.merchant_data = pay_det.merchant_data paymnt.merchant_data = pay_det.merchant_data
@ -212,18 +212,20 @@ class PaymentRequest:
try: try:
r = requests.post(payurl.geturl(), data=pm, headers=ACK_HEADERS, verify=False) r = requests.post(payurl.geturl(), data=pm, headers=ACK_HEADERS, verify=False)
except Exception as e: except Exception as e:
print "Payment Message/PaymentACK Failed"
print e print e
return return False, "Payment Message/PaymentACK Failed"
if r.status_code >= 500:
return False, r.reason
try: try:
paymntack = paymentrequest_pb2.PaymentACK() paymntack = paymentrequest_pb2.PaymentACK()
paymntack.ParseFromString(r.content) paymntack.ParseFromString(r.content)
except Exception: except Exception:
print "PaymentACK could not be processed. Payment was sent; please manually verify that payment was received." return False, "PaymentACK could not be processed. Payment was sent; please manually verify that payment was received."
return
print "PaymentACK message received: %s" % paymntack.memo print "PaymentACK message received: %s" % paymntack.memo
return paymntack.memo return True, paymntack.memo

Loading…
Cancel
Save