def build_pay_system_url(payment: Payment, transaction_id: uuid, pay_return_url: str): """Build pay system url which will be used to redirect to the payment system.""" current_app.logger.debug('<build_pay_system_url') pay_system_service: PaymentSystemService = PaymentSystemFactory.create_from_system_code( payment_system=payment.payment_system_code ) invoice = InvoiceModel.find_by_payment_id(payment.id) invoice_reference = InvoiceReference.find_active_reference_by_invoice_id(invoice.id) return_url = f'{pay_return_url}/{payment.id}/transaction/{transaction_id}' current_app.logger.debug('>build_pay_system_url') return pay_system_service.get_payment_system_url(Invoice.populate(invoice), invoice_reference, return_url)
def build_pay_system_url(payment: Payment, transaction_id: uuid): """Build pay system url which will be used to redirect to the payment system.""" current_app.logger.debug('<build_pay_system_url') pay_system_service: PaymentSystemService = PaymentSystemFactory.create( payment_system=payment.payment_system_code) invoice = InvoiceModel.find_by_payment_id(payment.id) pay_web_transaction_url = current_app.config.get( 'AUTH_WEB_PAY_TRANSACTION_URL') return_url = f'{pay_web_transaction_url}/returnpayment/{payment.id}/transaction/{transaction_id}' current_app.logger.debug('>build_pay_system_url') return pay_system_service.get_payment_system_url( Invoice.populate(invoice), return_url)
def asdict(self): """Return the payment as a python dict.""" invoices = [] for invoice in self._invoices: current_invoice = Invoice.populate(invoice) if current_invoice.invoice_status_code != Status.CANCELLED.value: invoices.append(current_invoice.asdict()) d = { 'id': self._id, 'payment_system_code': self._payment_system_code, 'payment_method_code': self._payment_method_code, 'payment_status_code': self._payment_status_code, 'payment_create_date': self._created_on, 'payment_create_by': self._created_by, 'payment_update_date': self._updated_on, 'payment_update_by': self._updated_by, 'payment_invoices': invoices } return d