def getPaypalById(self, paypal_id): dao = PaypalDAO() row = dao.getPaypalById(paypal_id) if not row: return jsonify(Error="Paypal Not Found"), 404 else: paypal = self.build_paypal_dict(row) return jsonify(AthMovil=paypal)
def deletePaypal(self, paypal_id): paypal_dao = PaypalDAO() if not paypal_dao.getPaypalById(paypal_id): return jsonify(Error="Paypal not found."), 404 else: payment_id = paypal_dao.delete(paypal_id) payment_dao = PaymentDAO() payment_dao.delete(payment_id) return jsonify(DeleteStatus="OK"), 200
def updatePaypal(self, paypal_id, json): paypal_dao = PaypalDAO() if not paypal_dao.getPaypalById(paypal_id): return jsonify(Error="Paypal not found."), 404 else: customer_id = json["customer_id"] paypal_username = json["paypal_username"] paypal_password = json["paypal_password"] if customer_id and paypal_username and paypal_password: payment_id = paypal_dao.update(paypal_id, paypal_username, paypal_password) payment_dao = PaymentDAO() payment_dao.update(payment_id, customer_id) result = self.build_paypal_attributes(paypal_id, payment_id, customer_id, paypal_username, paypal_password) return jsonify(Paypal=result), 200 else: return jsonify( Error="Unexpected attributes in post request"), 400